fraction_counts

besca.pp.fraction_counts(adata, species='human', name='percent_mito', use_genes='SYMBOL', specific_file=None)[source]

Function to calculate fraction of counts per cell from a gene list. This function calculates the fraction of counts per cell for a list of genes (for example mito genes) if no specific file is given. Note that the input file consists of two columns (ENSEMBL gene id and gene symbol) tab separated

Parameters:
  • adata (AnnData) – AnnData object

  • species (str | default = human) – species for mitochondrial content evaluation

  • name (str | default = percent_mito) – String identifying the column name to which the results should be written to in the AnnData.obs object

  • use_genes (SYMBOL or ENSEMBL | default = SYMBOL) – String defining whether ENSEMBL id’s or gene symbols are used in the adata.var_names (defines which column of input gene list is read)

  • specific_file (str | default None.) – if indicated, the file will be used to extract the gene list

Returns:

Returns None but updates adata with new column named ‘name’ containing calculated fraction of counts.

Return type:

None

Example

>>> import besca as bc
>>> import os
>>> adata = bc.datasets.simulated_pbmc3k_raw()
>>> bc.pp.fraction_counts(adata,  'human', use_genes='SYMBOL', specific_file=f"{os.path.dirname(__file__)[:-3]}/datasets/mito_files/test.mito.tsv")
>>> counts = adata.obs.head(5)