carmonalab / UCell

Gene set scoring for single-cell data
GNU General Public License v3.0
137 stars 16 forks source link

Error in d$value$value : $ operator is invalid for atomic vectors #22

Closed massonix closed 1 year ago

massonix commented 2 years ago

Hi UCell team,

Thanks for developing this wonderful tool! I'm running the following code for scGate:

models <- list(
  myeloblast = gating_model(name = "myeloblast", signature = c("ELANE+", "MPO+", "NAMPT-")),
  azurophilic = gating_model(name = "azurophilic", signature = c("DEFA3+", "NAMPT-")),
  specific = gating_model(name = "specific", signature = c("LTF+", "LCN2+", "CAMP+", "NAMPT-")),
  gelatinase = gating_model(name = "gelatinase", signature = c("MMP9+"))
)
seurat <- scGate(
  data = seurat,
  model = models,
  save.levels = TRUE,
  reduction = "pca",
  ncores = 4,
  verbose = TRUE
)

But I get the following error:

Computing UCell scores for all signatures using RNA assay...

Error in d$value$value : $ operator is invalid for atomic vectors

Which seems to come from the UCell side. Any idea what could be going wrong? I have executed this code with other Seurat objects and it has worked great.

Thanks in advanced for your help!

Ramon

mass-a commented 2 years ago

Hello Ramon,

have you tried running directly UCell on these signatures? e.g.

sigs <- list("myeloblast"=c("ELANE+", "MPO+", "NAMPT-"),
            "azurophilic"=c("DEFA3+", "NAMPT-"),
            "specific"=c("LTF+", "LCN2+", "CAMP+", "NAMPT-"),
            "gelatinase"=c("MMP9+"))

obj <- AddModuleScore_UCell(obj, features = sigs)

Does it throw the same error?

Best -m

massonix commented 2 years ago

Hello!

If I comment out the "ncores" parameter it runs well; so the problem might be related with that.

Thanks

Ramon

mass-a commented 2 years ago

So, to understand - you see this error when setting ncores>1, but only on certain input objects?

Can you post an example with an input object that reproduces the behavior, and your sessionInfo() ?

gdagstn commented 1 year ago

Hi,

since it happened to me as well in many instances I thought I'd pitch in.

This is more of a BiocParallel-related error, and in my experience it happens when you abort a previous parallel run or it encounters some errors (but not always).

Not sure whether this is the right line that causes it, but for a small example, consider running this line and killing it (Ctrl + C) as soon as it starts:

a = BiocParallel::bplapply(seq_len(100), function(x) rnorm(x * 10^6, 0, 1), BPPARAM = MulticoreParam(workers = 2, progressbar = TRUE))
|===============================================                                                                      |  40%

[Ctrl + C]

Then running it again will return the same error for me:

a = BiocParallel::bplapply(seq_len(100), function(x) rnorm(x * 10^6, 0, 1), BPPARAM = MulticoreParam(workers = 2, progressbar = TRUE))
  |                                                                                                                     |   0%
Error in d$value$value : $ operator is invalid for atomic vectors

Sometimes if I force bpstop() it allows me to go on, sometimes it doesn't, and then I need to restart the R session.

HTH

mass-a commented 1 year ago

Hi Giuseppe,

thanks for the reproducible example! I had seen this error sporadically with different packages, but was never able to pinpoint the source. Perhaps it's worth reporting this to the BiocParallel developers?

-m

gdagstn commented 1 year ago

Hi @mass-a, They should have fixed this bug now, you can check the issue for the developer's comments.