atlas.pp.preprocessing

Contents

atlas.pp.preprocessing#

atlas.pp.preprocessing(mudata, n_pcs_rna=50, n_pcs_act=50, knn_rna=15, knn_act=15, use_rep=None, n_neighbors=30, n_bandwidth_neighbors=20, n_multineighbors=200, metric='euclidean', stranded=False, fragment_path=None, features=None, random_state=42, copy=False, count_reads=False)#

Preprocess multimodal single-cell data stored in a MuData object.

This function runs a preprocessing workflow on a MuData object containing scRNA-seq data and either a precomputed gene activity modality or raw scATAC-seq data. If gene activity is not available, it is computed from ATAC-seq fragment data.

The workflow includes:

  • Optional gene activity computation from scATAC-seq

  • Normalization and PCA on the activity modality

  • Construction of modality-specific k-nearest neighbor (kNN) graphs

  • Construction of a weighted nearest neighbor (WNN) graph

  • Computation of a multimodal UMAP embedding

Parameters:
  • mudata (MuData) – MuData object containing at least the "rna" modality and either an "activity" or "atac" modality.

  • n_pcs_rna (int (default: 50)) – Number of principal components used for the RNA kNN graph.

  • n_pcs_act (int (default: 50)) – Number of principal components used for the activity kNN graph.

  • knn_rna (int (default: 15)) – Number of neighbors for the RNA kNN graph.

  • knn_act (int (default: 15)) – Number of neighbors for the activity kNN graph.

  • use_rep (str | None (default: None)) – Key of the representation to use for neighbor graph construction, as in scanpy.pp.neighbors(). If None, the default representation is used.

  • n_neighbors (int | None (default: 30)) – Number of neighbors for constructing the weighted nearest neighbor (WNN) graph, as in muon.pp.neighbors(). If None, the arithmetic mean of the knn modalities is used.

  • n_bandwidth_neighbors (int (default: 20)) – Number of neighbors used for bandwidth estimation in the WNN graph, as in muon.pp.neighbors().

  • n_multineighbors (int (default: 200)) – Number of neighbors used for multimodal neighbor construction, as in muon.pp.neighbors().

  • metric (str (default: 'euclidean')) – Distance metric used for neighbor graph construction, as in :func:muon.pp.neighbors.

  • stranded (bool (default: False)) – Whether to consider strand information when computing gene activity.

  • fragment_path (str | None (default: None)) – Path to the fragment file used for gene activity computation if not already present in the ATAC modality. See muon.atac.tl.count_fragments_features() for more infomation.

  • random_state (int (default: 42)) – Random seed used for reproducibility.

  • copy (bool (default: False)) – If True, return a copy of the input MuData object. Otherwise, the input object is modified in place.

  • count_reads (bool (default: False)) – Parameter for muon.atac.tl.count_fragments_features(). Determines which columns in the fragment file to use for feature aggregation.

Return type:

MuData

Returns:

MuData MuData object restricted to the "rna" and "activity" modalities, containing:

  • modality-specific kNN graphs in .obsp

  • weighted nearest neighbor graph stored under .uns["wnn"]

  • multimodal UMAP embedding stored in .obsm["X_umap"]

Raises:
  • KeyError – If required modalities are missing (e.g., "rna" or "atac" when gene activity must be computed).

  • ValueError – If required inputs for gene activity computation are not provided, such as fragment file or feature annotations.

Examples

>>> preprocess(mdata, n_pcs_rna=30, knn_rna=20)