theislab / zellkonverter

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

problem with the Delayed Array matrix #111

Open Marwansha opened 5 months ago

Marwansha commented 5 months ago

hey, i generated a sce object using readH5AD with big object and i am failing to convert it the delayed matrix to dgCMatrix or CsparseMatrix and i wanted to ask if this is related to how readH5AD works and if you have any advice on how to convert the matrix would apperciate it. thanks

 > sce
class: SingleCellExperiment 
dim: 36623 697321 
metadata(11): _scvi_manager_uuid _scvi_uuid ... umap x_condition
assays(1): counts
rownames: NULL
rowData names(8): FDR bio ... tech total
colnames(697321): TTCAATCTCGAACCTA CGTAAGTTCACTCCGT ... GCTGGGTGTGTTCCAA AGTGATCAGCAATTAG-1
colData names(56): sample_id condition ... age_group age_sex
reducedDimNames(0):
mainExpName: NULL
altExpNames(0):

 > sce@assays@data@listData$counts%>%str()
**Formal class 'DelayedMatrix' [package "DelayedArray"] with 1 slot**
  ..@ seed:Formal class 'DelayedSetDimnames' [package "DelayedArray"] with 2 slots
  .. .. ..@ dimnames:List of 2
  .. .. .. ..$ **: int -1**
  .. .. .. ..$ : chr [1:697321] "TTCAATCTCGAACCTA" "CGTAAGTTCACTCCGT" "GAGAGGTCACCCTATC" "GTGCACGAGTCGAAGC" ...
  .. .. ..@ seed    :Formal class 'DelayedSubset' [package "DelayedArray"] with 2 slots
  .. .. .. .. ..@ index:List of 2
  .. .. .. .. .. ..$ : NULL
  .. .. .. .. .. ..$ : int [1:697321] 1 2 3 4 5 6 7 8 9 10 ...
  .. .. .. .. ..@ seed :Formal class 'CSC_H5SparseMatrixSeed' [package "HDF5Array"] with 6 slots
  .. .. .. .. .. .. ..@ filepath     : chr **"/pasteur/zeus/projets/p02/LabExMI/singleCell/V3/scRNA_NS_IAV_COV/results/merged_object/raw_v4.h5ad"**
  .. .. .. .. .. .. ..@ group        : chr "/X"
  .. .. .. .. .. .. ..@ subdata      : NULL
  .. .. .. .. .. .. ..@ dim          : int [1:2] 36623 714138
  .. .. .. .. .. .. ..@ indptr_ranges:'data.frame': 714138 obs. of  2 variables:
  .. .. .. .. .. .. .. ..$ start: num [1:714138] 1 8370 16015 24161 30876 ...
  .. .. .. .. .. .. .. ..$ width: int [1:714138] 8369 7645 8146 6715 7141 7118 7349 7288 7221 6599 ...
  .. .. .. .. .. .. ..@ dimnames     :List of 2
  .. .. .. .. .. .. .. ..$ : NULL
  .. .. .. .. .. .. .. ..$ : NULL

>assays(sce)$counts
36623 x 697321> sparse matrix of class DelayedMatrix and type "double":

 > assays(sce)$counts_dgC <- as(assays(sce)$counts, "dgCMatrix")
Error in rbind(...) : negative extents to matrix
lazappi commented 5 months ago

If you have managed to get a SingleCellExperiment object then {zellkonverter} is no longer involved so this might be a better question for the {DelayedArray} maintainers. Do you see the same problem if you try it on a subset of the matrix?

Was the H5AD file created with zellkonverter::writeH5AD() and/or do you have any issues reading it in Python? If that is the case it might be something that needs to be addressed here.