ocelli.tl.imputation#
- ocelli.tl.imputation(adata: AnnData, t: int = 5, kappa: float = 1.0, features: list | None = None, eigvals: str = 'eigenvalues', eigvecs: str = 'eigenvectors', scale: float = 1.0, copy: bool = False)#
Diffusion-based multimodal imputation.
This function performs iterative imputation of a count matrix (adata.X) using multimodal eigenvectors and eigenvalues. The imputation amplifies signals while preserving or enhancing the structure in the data.
- Parameters:
adata (anndata.AnnData) – The annotated data matrix.
t (int) – Number of imputation iterations. Higher values increase imputation smoothing. (default: 5)
kappa (float) – Scaling factor for signal amplification while preserving maximum expression values. (default: 1.0)
features (list or None) – List of feature names (adata.var.index) to be imputed. If None, all features are imputed. (default: None)
eigvals (str) – Key in adata.uns storing eigenvalues. (default: ‘eigenvalues’)
eigvecs (str) – Key in adata.uns storing eigenvectors. (default: ‘eigenvectors’)
scale (float) – Scaling factor for signal amplification. Higher values increase imputed signal and maximum expression values. (default: 1.0)
copy (bool) – Whether to return a copy of adata. If False, updates are made in-place. (default: False)
- Returns:
If copy=False: Updates adata with the imputed count matrix in adata.X.
If copy=True: Returns a modified copy of adata with the imputed count matrix.
- Return type:
anndata.AnnData or None
- Example:
import ocelli as oci from anndata import AnnData import numpy as np # Example data adata = AnnData(X=np.random.rand(100, 50)) adata.var.index = [f"gene_{i}" for i in range(50)] # Add mock eigenvalues and eigenvectors adata.uns["eigenvalues"] = np.random.rand(10) adata.uns["eigenvectors"] = np.random.rand(100, 10) # Perform imputation oci.tl.imputation(adata, t=5, kappa=1.5, features=["gene_1", "gene_2"])