snapatac2.pp.recipe_10x_metrics#
- snapatac2.pp.recipe_10x_metrics(bam_file, output_fragment_file, output_h5ad_file, peaks=None, **kwargs)[source]#
Generate 10x-style ATAC QC metrics from a raw BAM file.
Use this recipe to convert a BAM file to fragments, import the fragments into an h5ad file, compute targeting metrics, call peaks when needed, and summarize library-level QC values in one dictionary. Keyword arguments are forwarded to the individual preprocessing and metric functions when their signatures accept those names.
Anti-Patterns#
Do NOT use this recipe when you only need an existing fragment file imported; call
snap.pp.import_fragmentsdirectly.Do NOT omit required downstream inputs such as
chrom_sizesandgene_anno; they are supplied through**kwargsand used by the called functions.
- type bam_file:
- param bam_file:
Path to the input BAM file.
- type output_fragment_file:
- param output_fragment_file:
Path where the generated fragment file is written.
- type output_h5ad_file:
- param output_h5ad_file:
Path where the intermediate AnnData object is written.
- type peaks:
- param peaks:
Path to a BED-like peak file or a list of peak regions formatted as
"chrom:start-end". IfNone, MACS3 is run to call peaks.- type **kwargs:
- param **kwargs:
Additional arguments accepted by functions used in the recipe, including
make_fragment_file,import_fragments,metrics.tsse, and related calls.- returns:
Nested dictionary containing sequencing, cell, library-complexity, mapping, and targeting QC metrics.
- rtype:
Examples
>>> import snapatac2 as snap >>> bam_file = snap.datasets.pbmc500(type='bam') >>> metrics = snap.pp.recipe_10x_metrics( ... bam_file, ... 'fragments.tsv.gz', ... 'data.h5ad', ... barcode_tag='CB', ... source='10x', ... chrom_sizes=snap.genome.hg38, ... gene_anno=snap.genome.hg38, ... ) >>> sorted(metrics) ['Cells', 'Library Complexity', 'Mapping', 'Sequencing', 'Targeting']