spateo.tools.architype
#
Gene Expression Cartography M Nitzan*, N Karaiskos*, N Friedman†, N Rajewsky† Nature (2019)
code adapted from: https://github.com/rajewsky-lab/novosparc
Module Contents#
Functions#
|
Clusters the expression data and finds gene archetypes. Current implementation is based on hierarchical |
Get a list of genes which are the best representatives of the archetype. |
|
|
Given a gene, find other genes which correlate well spatially. |
|
Identify archetypes from the anndata object. |
|
Identify genes that belong to each expression archetype. |
- spateo.tools.architype.find_spatial_archetypes(num_clusters: int, exp_mat: numpy.ndarray) Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray] [source]#
Clusters the expression data and finds gene archetypes. Current implementation is based on hierarchical clustering with the Ward method. The archetypes are simply the average of genes belong to the same cell cluster.
- Parameters:
- num_clusters
number of gene clusters or archetypes.
- exp_mat
expression matrix. Rows are genes and columns are buckets.
- Returns:
Returns the archetypes, the gene sets (clusters) and the Pearson correlations of every gene with respect to each archetype.
- spateo.tools.architype.get_genes_from_spatial_archetype(exp_mat: numpy.ndarray, gene_names: numpy.ndarray | list, archetypes: numpy.ndarray, archetype: int, pval_threshold: float = 0) numpy.ndarray | list [source]#
Get a list of genes which are the best representatives of the archetype.
- Parameters:
- exp_mat
expression matrix.
- gene_names
the gene names list that associates with the rows of expression matrix
- archetypes
the archetypes output of find_spatial_archetypes
- archetype
a number denoting the archetype
- pval_threshold
the pvalue returned from the pearsonr function
- Returns:
a list of genes which are the best representatives of the archetype
Given a gene, find other genes which correlate well spatially.
- Parameters:
- exp_mat
expression matrix.
- gene_names
gene name list that associates with the rows of expression matrix.
- archetypes
the archetypes output of find_spatial_archetypes
- gene
the index of the gene to be queried
- pval_threshold
the pvalue returned from the pearsonr function
- Returns:
a list of genes which are the best representatives of the archetype
- spateo.tools.architype.archetypes(adata: anndata.AnnData, moran_i_genes: numpy.ndarray | list, num_clusters: int = 5, layer: str | None = None) numpy.ndarray [source]#
Identify archetypes from the anndata object.
- Parameters:
- adata
Anndata object of interests.
- moran_i_genes
genes that are identified as singificant autocorrelation genes in space based on Moran’s I.
- num_clusters
number of archetypes.
- layers
the layer for the gene expression, can be None which corresponds to adata.X.
- Returns:
the archetypes within the genes with high moran I scores.
- Return type:
archetypes
Examples
>>> archetypes = st.tl.archetypes(adata) >>> adata.obs = pd.concat((adata.obs, df), 1) >> arch_cols = adata.obs.columns >>> st.pl.space(adata, basis="spatial", color=arch_cols, pointsize=0.1, alpha=1)
- spateo.tools.architype.archetypes_genes(adata: anndata.AnnData, archetypes: numpy.ndarray, num_clusters: int, moran_i_genes: numpy.ndarray | list, layer: str | None = None) dict [source]#
Identify genes that belong to each expression archetype.
- Parameters:
- adata
Anndata object of interests.
- archetypes
the archetypes output of find_spatial_archetypes
- num_clusters
number of archetypes.
- moran_i_genes
genes that are identified as singificant autocorrelation genes in space based on Moran’s I.
- layer
the layer for the gene expression, can be None which corresponds to adata.X.
- Returns:
a dictionary where the key is the index of the archetype and the values are the top genes for that particular archetype.
- Return type:
archetypes_dict
Examples
>>> st.tl.archetypes_genes(adata) >>> dyn.pl.scatters(subset_adata, >>> basis="spatial", >>> color=['archetype %d'% i] + typical_genes.to_list(), >>> pointsize=0.03, >>> alpha=1, >>> figsize=(3, ptp_vec[1]/ptp_vec[0] * 3) >>> )