snapatac2.pp.import_data#
- snapatac2.pp.import_data(fragment_file, *, file=None, genome=None, gff_file=None, chrom_size=None, min_num_fragments=200, min_tsse=1, sorted_by_barcode=True, low_memory=True, whitelist=None, chunk_size=2000, tempdir=None)[source]#
Import dataset and compute QC metrics.
This function will store fragments as base-resolution TN5 insertions in the resulting h5ad file (in
.obsm['insertion']), along with the chromosome sizes (in.uns['reference_sequences']). Various QC metrics, including TSSe, number of unique fragments, duplication rate, fraction of mitochondrial DNA reads, will be computed.- Parameters
fragment_file (
Path) – File name of the fragment file.file (
Optional[Path]) – File name of the output h5ad file used to store the result. If provided, result will be saved to a backed AnnData, otherwise an in-memory AnnData is used.genome (
Optional[Genome]) – A Genome object. If not set,gff_fileandchrom_sizemust be provided.gff_file (
Optional[Path]) – File name of the gene annotation file in GFF format. This is required ifgenomeis not set.chrom_size (
Optional[dict[str,int]]) – A dictionary containing chromosome sizes, for example,{"chr1": 2393, "chr2": 2344, ...}. This is required ifgenomeis not set.min_num_fragments (
int) – Number of unique fragments threshold used to filter cellsmin_tsse (
float) – TSS enrichment threshold used to filter cellssorted_by_barcode (
bool) – Whether the fragment file has been sorted by cell barcodes. Ifsorted_by_barcode == True, this function makes use of small fixed amout of memory. Ifsorted_by_barcode == Falseandlow_memory == False, all data will be kept in memory. Seelow_memoryfor more details.low_memory (
bool) – Whether to use the low memory mode whensorted_by_barcode == False. It does this by first sort the records by barcodes and then process them in batch. The parameter has no effect whensorted_by_barcode == True.whitelist (
Union[Path,list[str],None]) – File name or a list of barcodes. If it is a file name, each line must contain a valid barcode. When provided, only barcodes in the whitelist will be retained.chunk_size (
int) – Increasing the chunk_size speeds up I/O but uses more memory.tempdir (
Optional[Path]) – Location to store temporary files. IfNone, system temporary directory will be used.
- Returns
An annotated data matrix of shape
n_obsxn_vars. Rows correspond to cells and columns to regions. Iffile=None, an in-memory AnnData will be returned, otherwise a backed AnnData is returned.- Return type
AnnData | ad.AnnData