snapatac2.metrics.tsse#
- snapatac2.metrics.tsse(adata, gene_anno, *, exclude_chroms=['chrM', 'M'], inplace=True, n_jobs=8)[source]#
Compute the TSS enrichment score (TSSe) for each cell.
import_fragmentsmust be ran first in order to use this function.- Parameters:
adata (
AnnData|list[AnnData]) – The (annotated) data matrix of shapen_obsxn_vars. Rows correspond to cells and columns to regions.adatacould 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) – AGenomeobject or a GTF/GFF file containing the gene annotation.exclude_chroms (
list[str] |str|None) – A list of chromosomes to exclude.inplace (
bool) – Whether to add the results toadata.obsor return it as a dictionary.n_jobs (
int) – Number of jobs to run in parallel whenadatais a list. Ifn_jobs=-1, all CPUs will be used.
- Returns:
If
inplace = True, cell-level TSSe scores are computed and stored inadata.obs['tsse']. Library-level TSSe scores are stored inadata.uns['library_tsse']. Fraction of fragments overlapping TSS are stored inadata.uns['frac_overlap_TSS']. Ifinplace = False, return a tuple containing all these values.- Return type:
tuple[np.ndarray, tuple[float, float]] | list[tuple[np.ndarray, tuple[float, float]]] | None
Examples
>>> import snapatac2 as snap >>> data = snap.pp.import_fragments(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