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

Update util.py #21

Closed
wants to merge 1 commit into from
Closed

Conversation

alexanderchang1
Copy link

csr_array will mess up downstream cause Anndata won't accept it and can't coerce it, switched to using csr_matrix instead. You also can't just lock it to 0.9.1 Anndata version since the new squidpy and scanpy functions will throw a fit for newer functions like reading in visium data.

csr_array will mess up downstream cause Anndata won't accept it and can't coerce it, switched to using csr_matrix instead. You also can't just lock it to 0.9.1 Anndata version since the new squidpy and scanpy functions will throw a fit for newer functions like reading in visium data.
@alexanderchang1 alexanderchang1 mentioned this pull request Sep 17, 2024
@alam-shahul
Copy link
Owner

Thanks for the pull request Alex! Can you elaborate?

In particular, I don't have the best test set up right now, but in what situations does csr_array not work? It seems to have worked in all of my Popari runs.

Furthermore, I believe that the AnnData version is not "locked" to 0.9.1; the pyproject.toml just specifies that it must be greater than or equal to that version. So if Scanpy/Squidpy require more up-to-date versions of AnnData, this dependency chain should resolve with installing the most up-to-date version. Or is that wrong?

@alexanderchang1
Copy link
Author

Scanpy and Squidpy added functions that directly read in visium data; if you want those functions to work, you have to install a later version of Anndata, which my conda solver put at version 0.10.9.

Your .toml allows greater than, it should be equal if the specific version of anndata is essential. But if you make it equal, it'll likely be unsolvable for more recent versions of Squidpy and Scanpy.

However, these later versions of anndata no longer permit csr_arrays to be assigned to .obsm, so every instance where you use csr_array has to be replaced with csr_matrix to avoid throwing an error. I've run the code and I believe it's a drop in replacement that works fine, however there other instances in your code base where it also needs to be fixed that I've recently discovered and haven't submitted a PR for yet.

@alam-shahul
Copy link
Owner

I see... that's really annoying, since the SciPy official documentation recommends switching to their new array interface: https://docs.scipy.org/doc/scipy/reference/sparse.html

I feel that Scanpy/Squidpy should enable sparse arrays to be saved in .obsm; I might open an issue for that in their repo.

But thanks for finding this; will try to work with the Scanpy developers to figure out a resolution.

@alam-shahul
Copy link
Owner

alam-shahul commented Sep 22, 2024

Good news: I think csr_arrays may be supported in the most recent release of AnnData: https://anndata.readthedocs.io/en/latest/release-notes/index.html#features

@alexanderchang1
Copy link
Author

I'll have to check for the exact line but I think the error isn't fixed by this, as it's a coerce array error that gets raised when it's a csr_array.

@alam-shahul
Copy link
Owner

I see, but I was digging deeper into the coerce_array function and I found that scipy.sparse.sparrays should be supported. Also I did a simple test and it seemed to work.

@alam-shahul
Copy link
Owner

Hey @alexanderchang1, I made many changes to Popari, including a hotfix for a Squidpy, which is not compatible with the most recent version of AnnData. I'm hosting the hotfix on my own GitHub, which means that unfortunately the most up-to-date version of Popari can't yet be uploaded to PyPI.

Instead, just git clone this repo, cd into it, and type pip install .. That should install the most recent version of Popari, which fixes the issues you were described here. Let me know if it works and I'll close this issue/pull request.

@alam-shahul
Copy link
Owner

Closing this as solved by more recent iterations of Popari. One thing to note, there is currently a pin for scanpy<=1.9.3 due to this issue: scverse/scanpy#3422

In any case, if you want to use Popari you should just create a new environment for it and install the pinned dependencies there (just run pip install popari).

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

Successfully merging this pull request may close these issues.

2 participants