MarioniLab / miloR

R package implementation of Milo for testing for differential abundance in KNN graphs
https://bioconductor.org/packages/release/bioc/html/miloR.html
GNU General Public License v3.0
339 stars 22 forks source link

Function Not Found Error #328

Closed DarioS closed 4 months ago

DarioS commented 4 months ago

I am exploring the mixed model functionality. It seems as though there might be a missing function import from BiocParallel.

> class(MILOdata)
  "Milo"
> head(design) # P: primary, M: metastasis.
           SampleID Smoker
HN118_P     HN118_P     No
OSCC_12-P OSCC_12-P     No
OSCC_16-P OSCC_16-P    Yes
OSCC_16-M OSCC_16-M    Yes
OSCC_20-P OSCC_20-P     No
OSCC_22-P OSCC_22-P    Yes
> testNhoods(MILOdata, design = ~ Smoker + (1|SampleID), design.df = design, fdr.weighting = "graph-overlap")
  Random effects found
  Using TMM normalisation
  Running GLMM model - this may take a few minutes
  Error in bpstopOnError(new("SerialParam", .xData = <environment>)) : 
    could not find function "bpstopOnError"

I am hoping to avoid spurious neighbourhoods with cells originating from only one sample, e.g. John Marioni et al. 2024

image

MikeDMorgan commented 4 months ago

Hi @DarioS - thanks for flagging - for now you can add library(BiocParallel) to your code to resolve this issue.

MikeDMorgan commented 4 months ago

Hi @DarioS - could you check if the latest master-branch version fixes your issue?

DarioS commented 4 months ago

I used devtools' install_github which succeeded. But, reloading the package didn't solve it. So, I loaded BiocParallel.

library(BiocParallel)
Running GLMM model - this may take a few minutes
Error in testNhoods(MILOdata, design = ~Smoker + (1 | Sample), design.df = design[!is.na(design$Smoker),  : 
  Lowest traceback returned: 5: handle_error(e)
4: h(simpleError(msg, call))
3: .handleSimpleError(function (e) 
   {
       annotated_condition <- handle_error(e)
       stop(annotated_condition)
   }, "argument is of length zero", base::quote(if (!glmm.control$solver %in% 
       c("HE", "Fisher", "HE-NNLS")) {
       stop(glmm.control$solver, " not recognised - must be HE, HE-NNLS or Fisher")
   }))
2: fitGLMM(X = Xmodel, Z = Zmodel, y = Y[i, ], offsets = off.sets, 
       random.levels = randlevels, REML = reml, dispersion = disper[i], 
       geno.only = genonly, Kin = kinship, glmm.control = glmm.contr)
1: FUN(...)

It is hard for users to read but I realised that glmm.solver is mandatory if a formula contains |. Perhaps an is.null check?