Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
kaizhang committed Nov 5, 2023
1 parent 156c6b7 commit a39f755
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions snapatac2-python/snapatac2/export/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from typing_extensions import Literal

from pathlib import Path
import numpy as np

import snapatac2._snapatac2 as internal

Expand Down Expand Up @@ -48,6 +47,10 @@ def export_fragments(
dict[str, str]
A dictionary contains `(groupname, filename)` pairs. The file names are
formatted as `{prefix}{groupname}{suffix}`.
See Also
--------
export_coverage
"""
if isinstance(groupby, str):
groupby = adata.obs[groupby]
Expand Down Expand Up @@ -81,7 +84,7 @@ def export_coverage(
max_frag_length: int | None = 2000,
out_dir: Path = "./",
prefix: str = "",
suffix: str = ".bedgraph.zst",
suffix: str = ".bw",
output_format: Literal["bedgraph", "bigwig"] | None = None,
compression: Literal["gzip", "zstandard"] | None = None,
compression_level: int | None = None,
Expand Down Expand Up @@ -142,6 +145,41 @@ def export_coverage(
dict[str, str]
A dictionary contains `(groupname, filename)` pairs. The file names are
formatted as `{prefix}{groupname}{suffix}`.
See Also
--------
export_fragments
Examples
--------
>>> import snapatac2 as snap
>>> data = snap.read(snap.datasets.pbmc5k(type="annotated_h5ad"), backed='r')
>>> snap.ex.export_coverage(data, groupby='cell_type', suffix='.bedgraph.zst')
{'cDC': './cDC.bedgraph.zst',
'Memory B': './Memory B.bedgraph.zst',
'CD4 Naive': './CD4 Naive.bedgraph.zst',
'pDC': './pDC.bedgraph.zst',
'CD8 Naive': './CD8 Naive.bedgraph.zst',
'CD8 Memory': './CD8 Memory.bedgraph.zst',
'CD14 Mono': './CD14 Mono.bedgraph.zst',
'Naive B': './Naive B.bedgraph.zst',
'NK': './NK.bedgraph.zst',
'CD4 Memory': './CD4 Memory.bedgraph.zst',
'CD16 Mono': './CD16 Mono.bedgraph.zst',
'MAIT': './MAIT.bedgraph.zst'}
>>> snap.ex.export_coverage(data, groupby='cell_type', suffix='.bw')
{'Naive B': './Naive B.bw',
'CD4 Memory': './CD4 Memory.bw',
'CD16 Mono': './CD16 Mono.bw',
'CD8 Naive': './CD8 Naive.bw',
'pDC': './pDC.bw',
'CD8 Memory': './CD8 Memory.bw',
'NK': './NK.bw',
'Memory B': './Memory B.bw',
'CD14 Mono': './CD14 Mono.bw',
'MAIT': './MAIT.bw',
'CD4 Naive': './CD4 Naive.bw',
'cDC': './cDC.bw'}
"""
if isinstance(groupby, str):
groupby = adata.obs[groupby]
Expand Down

0 comments on commit a39f755

Please sign in to comment.