snapatac2.metrics.tsse#
- snapatac2.metrics.tsse(adata, gene_anno, *, exclude_chroms=['chrM', 'M'], inplace=True, n_jobs=8)[source]#
Compute transcription start site enrichment for each cell.
Run this metric after
import_fragmentshas attached fragment metadata to the AnnData object. Withinplace=True, the function writes cell-level scores toadata.obs["tsse"]and library-level summaries toadata.uns.Anti-Patterns#
Do NOT call this function on an AnnData object that lacks imported fragments.
Do NOT pass a genome object without an annotation file;
gene_annomust resolve to a GTF/GFF annotation.
- param adata:
AnnData object, or a list of AnnData objects, with imported fragments. When a list is provided, compute TSSe for each object in parallel.
- type adata:
AnnData|list[AnnData]- param gene_anno:
Genome object with an
annotationpath, or a GTF/GFF annotation file path used to define transcription start sites.- type gene_anno:
- param exclude_chroms:
Chromosome names to exclude when computing the TSS profile. Use None to include all chromosomes.
- type exclude_chroms:
- param inplace:
If True, store results in
adata.obsandadata.uns. If False, return the result dictionary instead.- type inplace:
- param n_jobs:
Number of jobs to run when
adatais a list. Ifn_jobs=-1, use all available CPUs.- type n_jobs:
- returns:
If
inplace=True, returns None after storingtsseinadata.obsandlibrary_tsse,frac_overlap_TSS, andTSS_profileinadata.uns. Ifinplace=False, returns the same values in a dictionary, or a list of dictionaries whenadatais a list.- rtype:
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