ehrapy.preprocessing.nuclear_norm_minimization_impute

ehrapy.preprocessing.nuclear_norm_minimization_impute(adata, var_names=None, warning_threshold=70, require_symmetric_solution=False, min_value=None, max_value=None, error_tolerance=0.0001, max_iters=50000, verbose=False, copy=False)[source]

Impute data using the NuclearNormMinimization.

See https://github.com/iskandr/fancyimpute/blob/master/fancyimpute/nuclear_norm_minimization.py Simple implementation of “Exact Matrix Completion via Convex Optimization” by Emmanuel Candes and Benjamin Recht using cvxpy.

Parameters:
  • adata (AnnData) – The AnnData object to apply NuclearNormMinimization on.

  • var_names (Iterable[str] | None) – Var names indicating which columns to impute (if None -> all columns).

  • warning_threshold (int) – Threshold of percentage of missing values to display a warning for. Defaults to 70.

  • require_symmetric_solution (bool) – Whether to add a symmetry constraint to the convex problem. Defaults to False.

  • min_value (float | None) – Smallest possible imputed value. Defaults to None (no minimum value constraint).

  • max_value (float | None) – Largest possible imputed value. Defaults to None (no maximum value constraint).

  • error_tolerance (float) – Degree of error allowed on reconstructed values. Defaults to 0.0001.

  • max_iters (int) – Maximum number of iterations for the convex solver. Defaults to 50000.

  • verbose (bool) – Whether to print debug information. Defaults to False.

  • copy (bool) – Whether to return a copy of the AnnData object or act in place. Defaults to False (act in place).

Return type:

AnnData

Returns:

The imputed AnnData object.

Examples

>>> import ehrapy as ep
>>> adata = ep.dt.mimic_2(encoded=True)
>>> ep.ad.infer_feature_types(adata)
>>> ep.pp.nuclear_norm_minimization_impute(adata)