scrnatools.tools.create_cell_type_signature
- scrnatools.tools.create_cell_type_signature(adata: AnnData, save_path: str | None = None, cell_type_labels: str = 'cell_type', data_loc: str = 'raw') DataFrame[source]
Creates a pseudobulked cell type gene signature from scRNAseq data.
- Parameters:
adata (AnnData) – The AnnData object containing the cell type expression data, with cell labels as a key in ‘adata.obs’ and library size corrected and log-normalized counts in adata.X, adata.raw, or a layer in adata.layers.
save_path (str, optional) – The path to save a csv containing the cell type gene signatures to. Defaults to None.
cell_type_labels (str, optional) – The column name in ‘adata.obs’ containing the cell type labels for each cell. Defaults to “cell_type”.
data_loc (str, optional) – The location of the library size corrected and log-normalized gene expression data in ‘adata’. Default is ‘raw’ but can also be ‘X’ or a valid key from ‘adata.layers’. Defaults to “raw”.
- Raises:
ValueError – If ‘cell_type_labels’ is not a valid column in ‘adata.obs’
ValueError – If ‘data_loc’ is not ‘X’, ‘raw’, or a valid layer in ‘adata.layers’
- Returns:
A DataFrame containing the psuedobulked gene signatures for each cell type in adata.obs[cell_type_labels] with columns containing data each cell type and rows containing the average expression for each gene within that call
- Return type:
pd.DataFrame