Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

csr_vcorrcoef calculates wrong correlation #678

Closed
WeilerP opened this issue Sep 1, 2021 · 1 comment · Fixed by #679
Closed

csr_vcorrcoef calculates wrong correlation #678

WeilerP opened this issue Sep 1, 2021 · 1 comment · Fixed by #679
Assignees
Labels
bug Something isn't working

Comments

@WeilerP
Copy link
Member

WeilerP commented Sep 1, 2021

Description

In csr_vcorrcoef, the radicals in the denominator of the Pearson's correlation are calculated incorrectly. For 1d arrays X, the radical should be

np.sum((X - X.mean()) ** 2)

or equivalently

np.sum(X ** 2) - 2 * np.sum(X) * X.mean() + len(X) * X.mean() ** 2

The actual implementation is missing the factor 2 as well as len(X).

Versions
scvelo==0.2.4.dev48+gba75c4a.d20210719  scanpy==1.7.2  anndata==0.7.6  loompy==3.0.6  numpy==1.20.3  scipy==1.6.3  matplotlib==3.4.2  sklearn==0.24.2  pandas==1.2.4
@WeilerP WeilerP added the bug Something isn't working label Sep 1, 2021
@WeilerP WeilerP self-assigned this Sep 1, 2021
@WeilerP
Copy link
Member Author

WeilerP commented Sep 1, 2021

Closed via #679.

@WeilerP WeilerP closed this as completed Sep 1, 2021
@WeilerP WeilerP linked a pull request Sep 1, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant