Api module
Bases: object
pyWGCNA: Weighted correlation network analysis in Python
__init__(data, save_path='')
¶
Initialize the pyWGCNA module
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
pd.DataFrame
|
The dataframe of gene expression data |
required |
save_path |
str
|
The path to save the results |
''
|
calculate_correlation_direct(method='pearson', save=False)
¶
calculate the correlation coefficient matrix
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method |
str
|
The method to calculate the correlation coefficient matrix |
'pearson'
|
save |
bool
|
Whether to save the result |
False
|
calculate_correlation_indirect(save=False)
¶
calculate the indirect correlation coefficient matrix
Parameters:
Name | Type | Description | Default |
---|---|---|---|
save |
bool
|
Whether to save the result |
False
|
calculate_soft_threshold(threshold_range=12, plot=True, save=False, figsize=(6, 3))
¶
calculate the soft threshold
Parameters:
Name | Type | Description | Default |
---|---|---|---|
threshold_range |
int
|
The range of threshold |
12
|
plot |
bool
|
Whether to plot the result |
True
|
save |
bool
|
Whether to save the result |
False
|
Returns:
Type | Description |
---|---|
pd.DataFrame
|
The dataframe of soft threshold |
calculate_corr_matrix()
¶
calculate the correlation matrix
calculate_distance(trans=True)
¶
calculate the distance matrix
Parameters:
Name | Type | Description | Default |
---|---|---|---|
trans |
bool
|
Whether to transpose the correlation matrix |
True
|
calculate_geneTree(linkage_method='ward')
¶
calculate the geneTree
Parameters:
Name | Type | Description | Default |
---|---|---|---|
linkage_method |
str
|
The method to calculate the geneTree, it can be found in |
'ward'
|
calculate_dynamicMods(minClusterSize=30, deepSplit=2)
¶
calculate the dynamicMods
Parameters:
Name | Type | Description | Default |
---|---|---|---|
minClusterSize |
int
|
The minimum size of cluster |
30
|
deepSplit |
int
|
The deep of split |
2
|
calculate_gene_module(figsize=(25, 10), save=True, colorlist=None)
¶
calculate the gene module
Parameters:
Name | Type | Description | Default |
---|---|---|---|
figsize |
tuple
|
The size of figure |
(25, 10)
|
save |
bool
|
Whether to save the figure |
True
|
colorlist |
list
|
The color list of module |
None
|
Returns:
Type | Description |
---|---|
pd.DataFrame
|
The dataframe of gene module |
get_sub_module(mod_list)
¶
Get sub-module of a module
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mod_list |
list
|
module number |
required |
Returns:
Name | Type | Description |
---|---|---|
sub_module |
pd.DataFrame
|
sub-module of a module |
get_sub_network(mod_list, correlation_threshold=0.95)
¶
Get sub-network of a module
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mod_list |
list
|
module number |
required |
Returns:
Name | Type | Description |
---|---|---|
sub_network |
nx.Graph
|
sub-network of a module |
plot_sub_network(mod_list, correlation_threshold=0.95, plot_genes=None, plot_gene_num=5, **kwargs)
¶
plot sub-network of a module
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mod_list |
list
|
module number |
required |
correlation_threshold |
float
|
correlation threshold |
0.95
|
plot_genes |
genes to plot in the sub-network. If None, the hub genes will be ploted |
None
|
|
plot_gene_num |
int
|
number of genes to plot |
5
|
Returns:
Name | Type | Description |
---|---|---|
fig |
matplotlib.figure.Figure
|
figure |
ax |
matplotlib.axes._axes.Axes
|
axis |
analysis_meta_correlation(meta_data)
¶
Analysis meta correlation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
meta_data |
pd.DataFrame
|
meta data of samples |
required |
Returns:
Name | Type | Description |
---|---|---|
meta_cor |
pd.DataFrame
|
meta correlation |
meta_p |
pd.DataFrame
|
meta p-value |
plot_meta_correlation(cor_matrix, label_fontsize=10, label_colors='red')
¶
Plot meta correlation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cor_matrix |
tuple
|
meta correlation and meta p-value |
required |
label_fontsize |
int
|
label fontsize |
10
|
label_colors |
str
|
label colors |
'red'
|
Returns:
Name | Type | Description |
---|---|---|
ax |
matplotlib.axes._axes.Axes
|
axis |
plot_matrix(cmap='RdBu_r', save=True, figsize=(8, 9), legene_ncol=2, legene_bbox_to_anchor=(5, 2.95), legene_fontsize=12)
¶
plot the matrix of correlation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cmap |
The color of matrix |
'RdBu_r'
|
|
save |
bool
|
Whether to save the figure |
True
|
figsize |
tuple
|
The size of figure |
(8, 9)
|
legene_ncol |
int
|
The number of column of legene |
2
|
legene_bbox_to_anchor |
tuple
|
The position of legene |
(5, 2.95)
|
legene_fontsize |
int
|
The size of legene |
12
|
Returns:
Name | Type | Description |
---|---|---|
ax | The axis of figure |
show_root_heading: true
show_source: true