theislab / zellkonverter

Conversion between scRNA-seq objects
https://theislab.github.io/zellkonverter/
Other
150 stars 28 forks source link

Error with datatype in X when reading in with readH5AD #120

Closed ecwheele closed 1 month ago

ecwheele commented 3 months ago

Can I get some help with an error I'm getting in R? I'm primarily a python user. I save H5AD files and reading them into R with zellkonverter::readH5AD . For most of my datasets it works just fine, but I'm getting this error on a few of them that I cannot seem to fix. Here is the output:

> rna = zellkonverter::readH5AD(data_file, verbose=TRUE)
ℹ Using the Python reader
ℹ Using anndata version 0.8.0
✔ Read /.../.../.../.../.../.../.../.../test_DS000017653-T_cell.h5ad [1.1s]
✔ uns$Celltype_Name_colors converted [78ms] 
✔ uns$author_cell_label_colors converted [80ms]
✔ uns$disease_colors converted [78ms]
✔ uns$inflammation_colors converted [79ms]
✔ uns$mayo_score_colors converted [71ms]
✔ uns$patientID_colors converted [69ms]
✔ uns$sampleID_colors converted [68ms]
✔ uns$tissue_colors converted [64ms]
✔ uns converted [1.6s]
✔ Converting uns to metadata ... done
✔ X matrix converted to assay [163ms]transposition and has been skipped
Error in validObject(.Object) : llExperiment
  invalid class "dgRMatrix" object: 'x' slot is not of type "double"
✖ Converting AnnData to SingleCellExperiment ... failed

I tried deleting the .X slot in python before saving the file and that didn't fix it. I also tried explicitly converting it to numpy64 data type with:

adata.X = adata.X.astype(np.float64)

and that also didn't fix the error.

lazappi commented 3 months ago

Hi @ecwheele

Thanks for giving {zellkonverter} a go. This kind of error can have various causes but it could be something to do with the format of your data. Could you please provide the output of sessionInfo() so I can see what package versions you are using? It would also be helpful to have a small test file that reproduces the error (a few cells/genes would be enough).

lazappi commented 1 month ago

@ecwheele I am closing issue. Please reopen if you would like to follow up.