Open wuxiangning opened 1 week ago
Can you run the following code on your .X
? If it returns True, it then means that not all of the values in .X
are integers and you need to check what causes some non-integer values in your .X
.
np.any(~np.equal(np.mod(X, 1), 0))
I run it np.any(~np.equal(np.mod(adata.x, 1), 0)) this code seems to check if adata.x is an integer It return error like this: TypeError: unsupported operand type(s) for %: 'csr_matrix' and 'int' this error seems my adata.X type isnt right,why? This adata is convert from seurate by using MuDataSeurat::WriteH5AD(seurate, "F:/数据分析/R.h5ad", assay="RNA"). Is there a problem with this conversion function?but this adata can use Scanpy as normal! Thanks!
Can you try this np.any(~np.equal(np.mod(adata.X.data, 1), 0))
?
Sure 。It seems something is wrong in my anadata.because when i use the standard data . It return false ![Uploading {B59D15FB-21CF-4593-B47A-F47AD2052E7C}.png…]()
I dont know why my adata has this wrong,because it seems every object is right and ture
I think you can first check which values in your .X
are non-integers. Then you can go back to your original Seurat object to see where the issue occurred.
I don't quite know how to determine which value makes my .X are non-integers. Can you help me!help!!!
One quick, though possibly inefficient, way is:
np.where(~np.equal(np.mod(adata.X.toarray(), 1), 0))
The first array returned is the row index and the second one is column index for non-integer values in .X
It looks like there are a lot of non-integers, how do I go and change these in Seurate
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!