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

Errors in generating cell embeddings #21

Open
HelloWorldLTY opened this issue Dec 1, 2024 · 1 comment
Open

Errors in generating cell embeddings #21

HelloWorldLTY opened this issue Dec 1, 2024 · 1 comment

Comments

@HelloWorldLTY
Copy link

Hi, thanks for your great work. I tested the cell embeddings generation function in a new dataset, and found an error:

File /gpfs/gibbs/pi/zhao/tl688/CellPLM/tutorials/CellPLM/utils/data.py:19, in sparse_scipy_to_tensor(x)
     18 def sparse_scipy_to_tensor(x: scipy.sparse.csr_matrix):
---> 19     return torch.sparse_csr_tensor(x.indptr, x.indices, x.data, (x.shape[0], x.shape[1])).to_sparse().float().coalesce()

RuntimeError: crow_indices.shape[-1] must be equal to the number of rows + 1 (=47682), but got 17142

My dataset has 47681 cells and 17142 genes, and it seems that CellPLM identify my genes as cells. Is it possible to address it? Thanks.

I have checked that this dataset contains non zero gene expression.
image

@wehos
Copy link
Contributor

wehos commented Jan 23, 2025

Hello, did you convert your dataset from a dense matrix to a csr sparse matrix? For example, adata.X = scipy.sparse.csr_matrix(adata.X). This should be crucial to the model.

I suppose there is an issue with the data format, but I'm surprised that the format checking codes didn't throw an exception.

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

2 participants