scrnatools.tools.cell_type_similarity
- scrnatools.tools.cell_type_similarity(adata: AnnData, signatures: DataFrame, normalize: str = 'cell') AnnData[source]
Calculates the cosine similarity of cells to provided cell type signatures.
- Parameters:
adata (AnnData) – The AnnData object containing cells to score, with library size rescaled and log-normalized counts stored in ‘adata.raw’.
signatures (pd.DataFrame) – A DataFrame containing transcriptome signatures for each cell type to be tested. Columns are cell types and rows are the log-normalized expression of each gene in that cell type. Can be created from cell type clusters of a scRNAseq dataset using ‘create_cell_type_signature’
normalize (str, optional) – How to rescale the cosine similarity scores. Default is ‘cell’, which calculates a z-score normalized for each cell across all cell types in ‘signatures’. Other possible values are ‘cell type’ which calculates a z-score normalized for each cell type in ‘signatures’ across all cells and ‘none’ which returns the raw cosine similarity values. Defaults to “cell”.
- Returns:
The AnnData passed in with ‘adata’ with the cosine similarity scores for each immgen cell type added as a column to ‘adata.obs’
- Return type:
AnnData