snapatac2.pp.mnc_correct#

snapatac2.pp.mnc_correct(adata, *, batch, n_neighbors=5, n_clusters=40, n_iter=1, use_rep='X_spectral', use_dims=None, groupby=None, key_added=None, inplace=True, n_jobs=8)[source]#

A modified MNN-Correct algorithm based on cluster centroid.

Parameters:
  • data – Matrice or AnnData object. Matrices should be shaped like n_obs x n_vars.

  • batch – Batch labels for cells. If a string, labels will be obtained from obs.

  • n_neighbors – Number of mutual nearest neighbors.

  • n_clusters – Number of clusters

  • n_iter – Number of iterations.

  • use_rep – Use the indicated representation in .obsm.

  • use_dims – Use these dimensions in use_rep.

  • groupby – If specified, split the data into groups and perform batch correction on each group separately.

  • key_added – If specified, add the result to adata.obsm with this key. Otherwise, it will be stored in adata.obsm[use_rep + "_mnn"].

  • inplace – Whether to store the result in the anndata object.

  • n_jobs – Number of jobs to use for parallelization.

Returns:

if inplace=True it updates adata with the field adata.obsm[`use_rep`_mnn], containing adjusted principal components. Otherwise, it returns the result as a numpy array.

Return type:

np.ndarray | None