Skip to content

Commit

Permalink
_pca_fallback removal
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushalprasadhial authored Feb 14, 2025
1 parent 5678a7c commit da71424
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions src/scanpy/preprocessing/_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -1231,29 +1231,4 @@ def _downsample_array(
while count >= cumcounts[geneptr]:
geneptr += 1
col[geneptr] += 1
return col


# --------------------------------------------------------------------------------
# Helper Functions
# --------------------------------------------------------------------------------


def _pca_fallback(data, n_comps=2):
# mean center the data
data -= data.mean(axis=0)
# calculate the covariance matrix
C = np.cov(data, rowvar=False)
# calculate eigenvectors & eigenvalues of the covariance matrix
# use 'eigh' rather than 'eig' since C is symmetric,
# the performance gain is substantial
evals, evecs = sp.sparse.linalg.eigsh(C, k=n_comps)
# sort eigenvalues in decreasing order
idcs = np.argsort(evals)[::-1]
evecs = evecs[:, idcs]
evals = evals[idcs]
# select the first n eigenvectors (n is desired dimension
# of rescaled data array, or n_comps)
evecs = evecs[:, :n_comps]
# project data points on eigenvectors
return np.dot(evecs.T, data.T).T
return col

0 comments on commit da71424

Please sign in to comment.