scrnatools.tools.get_expression_matrix
- scrnatools.tools.get_expression_matrix(anndata: AnnData, gene_data: str) DataFrame[source]
Extracts the cell x gene expression matrix from an AnnData object.
- Parameters:
anndata (AnnData) – The AnnData to pull the expression matrix from.
gene_data (str) – Where to get the expression data from the AnnData object. If a layer from the AnnData[‘layers’] is passed, that is used, otherwise ‘X’ or ‘raw’ can be used.
- Raises:
ValueError – When ‘gene_data’ is not one of the layers in ‘anndata.layers’ or ‘X’ or ‘raw’
- Returns:
A Pandas DataFrame containing the expression matrix (cells x genes).
- Return type:
DataFrame