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

Invalid expression matrix #11

Open
gototry2000 opened this issue Jul 22, 2024 · 4 comments
Open

Invalid expression matrix #11

gototry2000 opened this issue Jul 22, 2024 · 4 comments

Comments

@gototry2000
Copy link

The first and second step can be run,but when I run follow mode:

tnode = sct.train.Trainer(atest2)

such an error can occur:

ValueError Traceback (most recent call last)
Cell In[145], line 1
----> 1 tnode = sct.train.Trainer(atest2)

File ~/miniconda3/envs/scanpy/lib/python3.12/site-packages/sctour/train.py:168, in Trainer.init(self, adata, percent, n_latent, n_ode_hidden, n_vae_hidden, batch_norm, ode_method, step_size, alpha_recon_lec, alpha_recon_lode, alpha_kl, loss_mode, nepoch, batch_size, drop_last, lr, wt_decay, eps, random_state, val_frac, use_gpu)
166 X = self.adata.X.data if sparse.issparse(self.adata.X) else self.adata.X
167 if (X.min() < 0) or np.any(~np.equal(np.mod(X, 1), 0)):
--> 168 raise ValueError(
169 f"Invalid expression matrix in .X. {self.loss_mode} mode expects raw UMI counts in .X of the AnnData."
170 )
172 self.n_cells = adata.n_obs
173 self.batch_size = batch_size

ValueError: Invalid expression matrix in .X. nb mode expects raw UMI counts in .X of the AnnData.

Does It mean the data is not raw data? How do I fix it? THANKS!

@LiQian-XC
Copy link
Owner

Hi,
The error occurred because it detected that the values in .X were not integers. Can you check whether you provided raw UMI counts (instead of normalized values) in .X of your anndata object?

@gototry2000
Copy link
Author

Thanks for your reply!
yeah ,I checked my data. Because I used SeuratDisk R package to convert Seurat format data to data that Scanpy can recognize. Following the protocol of this R package, the .x were filled with data of seurat data, raw.X were filled with  counts of seurat data. Indeed the values were not integers, but there was no difference between the two data sets. Should I change the data format further? Thanks !

@LiQian-XC
Copy link
Owner

If neither .X nor .raw.X are integers, check your original Seurat object to see whether the raw UMI counts are missing or if they have been corrected for some factors, making them non-integers. If the latter is the case, you can probably convert them to integers using a function like round.

@wuxiangning
Copy link

hello i have the same issue,when run tnode = sct.train.Trainer(adata)tnode = sct.train.Trainer(adata)
its error like this "ValueError Traceback (most recent call last)
Cell In[22], line 1
----> 1 tnode = sct.train.Trainer(adata)

File ~\AppData\Roaming\Python\Python312\site-packages\sctour\train.py:168, in Trainer.init(self, adata, percent, n_latent, n_ode_hidden, n_vae_hidden, batch_norm, ode_method, step_size, alpha_recon_lec, alpha_recon_lode, alpha_kl, loss_mode, nepoch, batch_size, drop_last, lr, wt_decay, eps, random_state, val_frac, use_gpu)
166 X = self.adata.X.data if sparse.issparse(self.adata.X) else self.adata.X
167 if (X.min() < 0) or np.any(~np.equal(np.mod(X, 1), 0)):
--> 168 raise ValueError(
169 f"Invalid expression matrix in .X. {self.loss_mode} mode expects raw UMI counts in .X of the AnnData."
170 )
172 self.n_cells = adata.n_obs
173 self.batch_size = batch_size

ValueError: Invalid expression matrix in .X. nb mode expects raw UMI counts in .X of the AnnData."

but my .X and .raw.X all integers and my seurat counts are also integers,.help!thk!

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

3 participants