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

hashsolo requires dense array #80

Open
zktuong opened this issue Dec 15, 2023 · 0 comments
Open

hashsolo requires dense array #80

zktuong opened this issue Dec 15, 2023 · 0 comments

Comments

@zktuong
Copy link

zktuong commented Dec 15, 2023

Hi I'm trying to run the following:

import scanpy as sc
adata = sc.read_10x_h5("sample_filtered_feature_bc_matrix.h5", gex_only=False)
hdata = adata[:, adata.var.index.isin(["HTO_C0301", "HTO_C0302"])].copy()
from solo import hashsolo
hashsolo.hashsolo(hdata., number_of_noise_barcodes=1)

And it gives me this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/uqztuong/miniforge3/envs/dandelion/lib/python3.11/site-packages/solo/hashsolo.py", line 392, in hashsolo
    posterior_dict = _calculate_bayes_rule(data, priors, number_of_noise_barcodes)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/uqztuong/miniforge3/envs/dandelion/lib/python3.11/site-packages/solo/hashsolo.py", line 238, in _calculate_bayes_rule
    log_likelihoods_for_each_hypothesis, _, _ = _calculate_log_likelihoods(
                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/uqztuong/miniforge3/envs/dandelion/lib/python3.11/site-packages/solo/hashsolo.py", line 92, in _calculate_log_likelihoods
    data = np.log(data + 1)
                  ~~~~~^~~
  File "/home/uqztuong/miniforge3/envs/dandelion/lib/python3.11/site-packages/scipy/sparse/_base.py", line 462, in __add__
    raise NotImplementedError('adding a nonzero scalar to a '
NotImplementedError: adding a nonzero scalar to a sparse array is not supported

converting the .X to dense array manually worked. just want to flag this as others may encounter this issue.

versions:
scipy==1.11.3
solo-sc==1.3
scanpy==1.9.3 anndata==0.9.1 umap==0.5.4 numpy==1.24.4 scipy==1.11.3 pandas==2.1.0 scikit-learn==1.3.1 statsmodels==0.14.0 python-igraph==0.10.8 pynndescent==0.5.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant