thor.analy.SPARKX
- class thor.analy.SPARKX(rscript_path='R/run_SPARKX.R', **kwargs)
Bases:
objectClass for running SPARKX.
- Parameters:
rscript_path (str, default: "R/run_SPARKX.R") – Path to the R script for running SPARKX.
Methods
Run SPARKX.
Compute the mean expression of each gene module.
Run hierarchical clustering with sklearn's AgglomerativeClustering on the residual matrix.
Run k-means clustering with sklearn's KMeans on the residual matrix.
Load the gene modules of SPARKX.
Load the result of SPARKX.
- RUN_SPARKX_R(adata_path=None, layer=None, out_path=None)
Run SPARKX.
- Parameters:
adata_path (str) – Path to the AnnData object.
layer (str, default: None) – Layer of the AnnData object to use.
out_path (str, default: None) – Path to the output directory.
- static compute_pattern_mean(adata, data, pattern, obskey_prefix)
Compute the mean expression of each gene module.
- Parameters:
adata (AnnData) – (n_sig_genes x n_cells)
data (dataframe (n_sig_genes x n_cells)) –
pattern (dataframe (n_sig_genes x 1), column is cluster, index is gene) –
- hierarchy_clustering(**hc_kwargs)
Run hierarchical clustering with sklearn’s AgglomerativeClustering on the residual matrix.
- Parameters:
hc_kwargs (dict) – Keyword arguments for AgglomerativeClustering.
- Returns:
labels – Cluster labels.
- Return type:
array (n_cells,)
- kmeans_clustering(n_patterns, **kmeans_kwargs)
Run k-means clustering with sklearn’s KMeans on the residual matrix.
- Parameters:
n_patterns (int) – Number of clusters.
kmeans_kwargs (dict) – Keyword arguments for KMeans.
- Returns:
labels – Cluster labels.
- Return type:
array (n_cells,)
- load_gene_modules(pattern_prefix='SP')
Load the gene modules of SPARKX.
- Parameters:
pattern_prefix (str, default: "SP") – Prefix of the gene modules.
- load_result()
Load the result of SPARKX.
- Returns:
residual – (n_genes x n_cells)
- Return type:
dataframe