Skip to content

Api module

Bases: GeneExp

A class used to do weighted gene co-expression network analysis.

:param name: name of the WGCNA we used to visualize data (default: 'WGCNA') :type name: str :param save: indicate if you want to save result of important steps in a figure directory (default: False) :type save: bool :param species: species of the data you use i.e mouse, human :type species: str :param level: which type of data you use including gene, transcript (default: gene) :type level: str :param outputPath: path you want to save all you figures and object (default: '', where you rau your script) :type outputPath: str :param anndata: if the expression data is in anndata format you should pass it through this parameter. X should be expression matrix. var is a gene information and obs is a sample information. :type anndata: anndata :param geneExp: expression matrix which genes are in the rows and samples are columns :type geneExp: pandas dataframe :param geneExpPath: path of expression matrix :type geneExpPath: str :param sep: separation symbol to use for reading data in geneExpPath properly :type sep: str :param geneInfo: dataframe that contains genes information it should have a same index as gene expression column names (gene/transcript ID) :type geneInfo: pandas dataframe :param sampleInfo: dataframe that contains samples information it should have a same index as gene expression index (sample ID) :type sampleInfo: pandas dataframe :param TPMcutoff: cut off for removing genes that expressed under this number along samples :type TPMcutoff: int :param cut: number to remove outlier sample (default: 'inf') By default we don't remove any sample by hierarchical clustering :type cut: float :param powers: different powers to test to have scale free network (default: [1:10, 11:21:2]) :type powers: list of int :param RsquaredCut: R squaered cut to choose power for having scale free network; between 0 to 1 (default: 0.9) :type RsquaredCut: float :param MeanCut: mean connectivity to choose power for having scale free network (default: 100) :type MeanCut: int :param networkType: Type of network we can create including "unsigned", "signed" and "signed hybrid" (default: "signed hybrid") :type networkType: str :param TOMType: Type of topological overlap matrix(TOM) including "unsigned", "signed" (default: "signed") :type TOMType: str :param minModuleSize: We like large modules, so we set the minimum module size relatively high (default: 50) :type minModuleSize: int :param naColor: color we used to identify genes we don't find any cluster for them (default: "grey") :type naColor: str :param MEDissThres: diss similarity threshold (default: 0.2) :type MEDissThres: float :param figureType: extension of figure (default: "pdf") :type figureType: str :param MEs: eigengenes :type MEs: ndarray :param geneExpr: gene expression object that contains raw gene expression along with gene and sample information. :type geneExpr: geneExp class :param datExpr: data expression data that contains preprocessed data :type datExpr: anndata :param dynamicMods: name of modules by clustering similar genes together :type dynamicMods: list :param TOM: topological overlap measure using average linkage hierarchical clustering which inputs a measure of interconnectedness :param TOM: ndarray :param adjacency: adjacency matrix calculating base of the type of network :type adjacency: ndarray :param geneTree: average hierarchical clustering of dissTOM matrix :type geneTree: ndarray :param power: power to have scale free network (default: 6) :type power: int :param sft: soft threshold table which has information for each powers :type sft: pandas dataframe :param datME: :type datME: pandas dataframe :param signedKME:(signed) eigengene-based connectivity (module membership) :type signedKME: pandas dataframe :param moduleTraitCor: correlation between each module and metadata :type moduleTraitCor: pandas dataframe :param moduleTraitPvalue: p-value of correlation between each module and metadata :type moduleTraitPvalue: pandas dataframe

__init__(name='WGCNA', TPMcutoff=1, powers=None, RsquaredCut=0.9, MeanCut=100, networkType='signed hybrid', TOMType='signed', minModuleSize=50, naColor='grey', cut=float('inf'), MEDissThres=0.2, species=None, level='gene', anndata=None, geneExp=None, geneExpPath=None, sep=',', geneInfo=None, sampleInfo=None, save=False, outputPath=None, figureType='pdf')

calculate_soft_threshold(colorlist=None, **kwargs)

calculate_geneTree()

calculate_dynamicMods(kwargs_function={'cutreeHybrid': {'deepSplit': 2, 'pamRespectsDendro': False}})

calculate_gene_module(kwargs_function={'cutreeHybrid': {'deepSplit': 2, 'pamRespectsDendro': False}})

get_sub_module(mod_list, mod_type='module_color')

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, mod_type='module_color', 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, mod_type='module_color', 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

figure

ax

axis

plot_matrix(cmap='RdBu_r', save=True, figsize=(8, 9), legene_ncol=2, legene_bbox_to_anchor=(5, 2.95), legene_fontsize=12, color_type='dynamicColors', **kwargs)

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