zktuong / ktplots

Some tools for plotting single-cell data
https://zktuong.github.io/ktplots/
MIT License
157 stars 30 forks source link

counts <- Matrix::t(adata$X) error #67

Closed chrsyl closed 1 year ago

chrsyl commented 1 year ago

Using your transfer code from python to R for the cellphonedb example file: normalised_log_counts.h5ad, I get following error: counts <- Matrix::t(adata$X) Error in h(simpleError(msg, call)) : error in evaluating the argument 'x' in selecting a method for function 't': invalid class “dgCMatrix” object: 'i' slot is not increasing within columns

How to correct?

zktuong commented 1 year ago

Hi, if you are using anndata/python, maybe you can use ktplotspy.

Otherwise, in your normalised_log_counts.h5ad, is the the .X a scipy.sparse.csr_matrix class/object or is just a numpy.ndarray ? if it is the second one, save your .h5ad again after converting the format:

from scipy.sparse import csr_matrix
adata.X = csr_matrix(adata.X)
adata.write_h5ad('new_norm.h5ad')
chrsyl commented 1 year ago

Helo, Thanks for answer. I tried your advice on the cellphonedb sample file. But still no X appeared. However, when I use library(zellkonverter) with readH5AD(), X appears and I can proceed. Your library is excellent. Still I want to be able to do modifications :). Best

28 mars 2023 kl. 00:13 skrev Zewen Kelvin Tuong @.***>:

Hi, if you are using anndata/python, maybe you can use ktplotspy https://www.github.com/zktuong/ktplotspy.

Otherwise, in your normalised_log_counts.h5ad, is the the .X a scipy.sparse.csr_matrix class/object or is just a numpy.ndarray ? if it is the second one, save your .h5ad again after converting the format:

from scipy.sparse import csr_matrix adata.X = csr_matrix(adata.X) adata.write_h5ad('new_norm.h5ad') — Reply to this email directly, view it on GitHub https://github.com/zktuong/ktplots/issues/67#issuecomment-1485929133, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXFFRE7LRN7UJE3D4ZKO5DW6IGKPANCNFSM6AAAAAAWHHGEMY. You are receiving this because you authored the thread.

zktuong commented 1 year ago

Oh ok great! I’ll look into updating the readme at some point.