spared.layer_operations.tpm_normalization

spared.layer_operations.tpm_normalization(organism: str, adata: AnnData, from_layer: str, to_layer: str) AnnData[source]

Normalize expression using TPM normalization.

This function applies TPM normalization to an AnnData object with raw counts. It also removes genes that are not fount in the .gtf annotation file. The counts are taken from adata.layers[from_layer] and the results are stored in adata.layers[to_layer]. It can perform the normalization for human and mouse reference genomes. To specify which GTF annotation file should be used, the 'organism' parameter must be 'mouse' or 'human'.

Parameters:
  • adata (ad.Anndata) – The Anndata object to normalize.

  • organism (str) – Organism of the dataset. Must be 'mouse' or 'human'.

  • from_layer (str) – The layer to take the counts from. The data in this layer should be in raw counts.

  • to_layer (str) – The layer to store the results of the normalization.

Returns:

The updated Anndata object with TPM values in adata.layers[to_layer].

Return type:

ad.Anndata