snapatac2.ex.export_fragments#

snapatac2.ex.export_fragments(adata, groupby, selections=None, ids=None, min_frag_length=None, max_frag_length=None, out_dir='./', prefix='', suffix='.bed.zst', compression=None, compression_level=None)[source]#

Export and save fragments in a BED format file.

Parameters:
  • adata (AnnData | AnnDataSet) – The (annotated) data matrix of shape n_obs x n_vars. Rows correspond to cells and columns to regions.

  • groupby (str | list[str]) – Group the cells. If a str, groups are obtained from .obs[groupby].

  • selections (Optional[list[str]]) – Export only the selected groups.

  • ids (Union[str, list[str], None]) – Cell ids add to the bed records. If None, .obs_names is used.

  • min_frag_length (Optional[int]) – Minimum fragment length to be included in the computation.

  • max_frag_length (Optional[int]) – Maximum fragment length to be included in the computation.

  • out_dir (Path) – Directory for saving the outputs.

  • prefix (str) – Text added to the output file name.

  • suffix (str) – Text added to the output file name.

  • compression (Optional[Literal['gzip', 'zstandard']]) – Compression type. If None, it is inferred from the suffix.

  • compression_level (Optional[int]) – Compression level. 1-9 for gzip, 1-22 for zstandard. If None, it is set to 6 for gzip and 3 for zstandard.

Returns:

A dictionary contains (groupname, filename) pairs. The file names are formatted as {prefix}{groupname}{suffix}.

Return type:

dict[str, str]

See also

export_coverage