bnprks / BPCells

Scaling Single Cell Analysis to Millions of Cells
https://bnprks.github.io/BPCells
Other
166 stars 17 forks source link

Error coercing to `dgCMatrix` #79

Open mjz1 opened 8 months ago

mjz1 commented 8 months ago

I think the recent commits might have done something to break matrix coercion in certain cases. Apologies I don't have a reproducible example, but reverting back to commit 919983d solved the issue.

Running

counts <- as(srt[,run_metadata$cell_id][["RNA"]]$counts, "dgCMatrix")

> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'iterate_matrix': no slot of name "type" for this object of class "10xMatrixH5"

If it helps my object is as follows:

33538 x 34415 IterableMatrix object with class RenameDims

Row names: MIR1302-2HG, FAM138A ... FAM231C
Col names: sd_1640_bm_c_cd3minus_AAAGATGTCAGGCAAG-1, sd_1640_bm_c_cd3minus_AAAGCAACACTTAACG-1 ... sd_2391_hd62_113_myeloid_TTTGGTTTCAGGCAAG-1

Data type: uint32_t
Storage order: column major

Queued Operations:
1. Concatenate cols of 21 matrix objects with classes: RenameDims, RenameDims ... RenameDims (threads=0)
2. Reset dimnames
mjz1 commented 8 months ago

I've just noticed you mention this in the changelog:

I'll close the issue

bnprks commented 8 months ago

Hi @mjz1, sorry about the breakage. Is it clear to you how to update your RDS file to work with the new version? In short, I think it would be something like this:

mat <- readRDS("some_file.rds")
inputs <- all_matrix_inputs(mat)
for (i in seq_along(inputs)) {
  if (is(inputs[[i]], "10xMatrixH5")) {
    inputs[[i]] <- open_matrix_10x_hdf5(inputs[[i]]@path)
  }
}
all_matrix_inputs(mat) <- inputs

I apologize for the inconvenience of this breaking change -- I couldn't see a way to add the intended features without introducing some breakage, but I can look into improving the error message