snapatac2.pp.make_peak_matrix#
- snapatac2.pp.make_peak_matrix(adata, *, use_rep=None, inplace=False, file=None, backend='hdf5', peak_file=None, chunk_size=500, use_x=False)[source]#
Generate cell by peak count matrix.
This function will generate a cell by peak count matrix and store it in a new .h5ad file.
import_data()
must be ran first in order to use this function.- Parameters:
adata (
AnnData
|AnnDataSet
) – The (annotated) data matrix of shapen_obs
xn_vars
. Rows correspond to cells and columns to regions.use_rep (
Union
[str
,list
[str
],None
]) – This is used to read peak information from.uns[use_rep]
. The peaks can also be provided by a list of strings: [“chr1:1-100”, “chr2:2-200”].inplace (
bool
) – Whether to add the tile matrix to the AnnData object or return a new AnnData object.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. This has no effect wheninplace=True
.backend (
Literal
['hdf5'
]) – The backend to use for storing the result. IfNone
, the default backend will be used.peak_file (
Optional
[Path
]) – Bed file containing the peaks. If provided, peak information will be read from this file.chunk_size (
int
) – Chunk sizeuse_x (
bool
) – If True, use the matrix stored in.X
as raw counts. Otherwise the.obsm['insertion']
is used.
- Returns:
An annotated data matrix of shape
n_obs
xn_vars
. Rows correspond to cells and columns to peaks. Iffile=None
, an in-memory AnnData will be returned, otherwise a backed AnnData is returned.- Return type:
AnnData | ad.AnnData | None