snapatac2.metrics.tsse#

snapatac2.metrics.tsse(adata, gene_anno, *, inplace=True, n_jobs=8)[source]#

Compute the TSS enrichment score (TSSe) for each cell.

import_data must be ran first in order to use this function.

Parameters:
  • adata (AnnData | list[AnnData]) – The (annotated) data matrix of shape n_obs x n_vars. Rows correspond to cells and columns to regions. adata could also be a list of AnnData objects. In this case, the function will be applied to each AnnData object in parallel.

  • gene_anno (Genome | Path) – A Genome object or a GTF/GFF file containing the gene annotation.

  • inplace (bool) – Whether to add the results to adata.obs or return it as a dictionary.

  • n_jobs (int) – Number of jobs to run in parallel when adata is a list. If n_jobs=-1, all CPUs will be used.

Returns:

If inplace = True, directly adds the results to adata.obs['tsse']. Otherwise return the results.

Return type:

np.ndarray | list[np.ndarray] | None

Examples

>>> import snapatac2 as snap
>>> data = snap.pp.import_data(snap.datasets.pbmc500(downsample=True), chrom_sizes=snap.genome.hg38, sorted_by_barcode=False)
>>> snap.metrics.tsse(data, snap.genome.hg38)
>>> print(data.obs['tsse'].head())
AAACTGCAGACTCGGA-1    32.129514
AAAGATGCACCTATTT-1    22.052786
AAAGATGCAGATACAA-1    27.109808
AAAGGGCTCGCTCTAC-1    24.990329
AAATGAGAGTCCCGCA-1    33.264463
Name: tsse, dtype: float64