Open gototry2000 opened 4 months ago
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?
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 !
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
.
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!
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_sizeValueError: 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!