Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/release-notes/3296.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add explicit support to {func}`scanpy.pp.pca` for `svd_solver='covariance_eigh'` {smaller}`P Angerer`
8 changes: 4 additions & 4 deletions src/scanpy/preprocessing/_pca/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
SvdSolvTruncatedSVDDaskML = Literal["tsqr", "randomized"]
SvdSolvDaskML = SvdSolvPCADaskML | SvdSolvTruncatedSVDDaskML

SvdSolvPCASklearn = Literal["auto", "full", "arpack", "randomized"]
SvdSolvPCASklearn = Literal["auto", "full", "arpack", "covariance_eigh", "randomized"]
SvdSolvTruncatedSVDSklearn = Literal["arpack", "randomized"]
SvdSolvPCASparseSklearn = Literal["arpack"]
SvdSolvSkearn = SvdSolvPCASklearn | SvdSolvTruncatedSVDSklearn | SvdSolvPCASparseSklearn
Expand Down Expand Up @@ -116,13 +116,13 @@ def pca(
`'arpack'`
for the ARPACK wrapper in SciPy (:func:`~scipy.sparse.linalg.svds`)
Not available with *dask* arrays.
`'covariance_eigh'`
Classic eigendecomposition of the covariance matrix, suited for tall-and-skinny matrices.
`'randomized'`
for the randomized algorithm due to Halko (2009). For *dask* arrays,
this will use :func:`~dask.array.linalg.svd_compressed`.
`'auto'`
chooses automatically depending on the size of the problem.
`'lobpcg'`
An alternative SciPy solver. Not available with dask arrays.
`'tsqr'`
Only available with *dask* arrays. "tsqr"
algorithm from Benson et. al. (2013).
Expand All @@ -133,7 +133,7 @@ def pca(
Default value changed from `'auto'` to `'arpack'`.

Efficient computation of the principal components of a sparse matrix
currently only works with the `'arpack`' or `'lobpcg'` solvers.
currently only works with the `'arpack`' or `'covariance_eigh`' solver.

If X is a *dask* array, *dask-ml* classes :class:`~dask_ml.decomposition.PCA`,
:class:`~dask_ml.decomposition.IncrementalPCA`, or
Expand Down
4 changes: 3 additions & 1 deletion tests/test_pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from scipy.sparse import issparse

import scanpy as sc
from scanpy.preprocessing._pca import SvdSolver as SvdSolverSupported
from testing.scanpy import _helpers
from testing.scanpy._helpers.data import pbmc3k_normalized
from testing.scanpy._pytest.marks import needs
Expand Down Expand Up @@ -110,7 +111,8 @@ def array_type(request: pytest.FixtureRequest) -> ArrayType:
return request.param


SVDSolver = Literal["auto", "full", "arpack", "randomized", "tsqr", "lobpcg"]
SVDSolverDeprecated = Literal["lobpcg"]
SVDSolver = SvdSolverSupported | SVDSolverDeprecated


def gen_pca_params(
Expand Down