adata = data.copy() if copy else data
from .. import settings as sett // why is this necessary?
if ("X_pca" in adata.smp
and adata.smp["X_pca"].shape[1] >= n_comps
and not recompute
and (sett.recompute == "none" or sett.recompute == "pp")):
logg.m(" not recomputing PCA, using "X_pca" contained "
"in `adata.smp` (set `recompute=True` to avoid this)", v=4)
return adata
else:
logg.m("compute PCA with n_comps =", n_comps, r=True, v=4)
result = pca(adata.X, n_comps=n_comps, zero_center=zero_center,
svd_solver=svd_solver, random_state=random_state,
recompute=recompute, mute=mute, return_info=True)
X_pca, components, pca_variance_ratio = result
adata.smp["X_pca"] = X_pca // this is multicolumn-sample annotation
for icomp, comp in enumerate(components):
adata.var["PC" + str(icomp+1)] = comp
adata.add["pca_variance_ratio"] = pca_variance_ratio
After Change
adata = data.copy() if copy else data
from .. import settings as sett // why is this necessary?
if ("X_pca" in adata.smp
and adata.get_multicol_field_smp("X_pca").shape[1] >= n_comps
and not recompute
and (sett.recompute == "none" or sett.recompute == "pp")):
logg.m(" not recomputing PCA, using "X_pca" contained "