Nanostring-Biostats / GeomxTools

Tools for NanoString GeoMx Digital Spatial Profiler data for reading DCC and PKC files to NanoStringGeomxSet class, Normalization and QC.
MIT License
34 stars 16 forks source link

Error when running mixedModelDE #174

Closed Flope closed 2 years ago

Flope commented 2 years ago

Hi, Not sure if this is the proper channel to communicate issues. I have been following the vignette from bioconductor. I encountered a couple of hiccups that I was able to solve but I can't figure out why I am getting the following error with mixedModelDE (problem with env??) . I tried different ways to indicate the formula and using different factors but I get the same error. Bellow, I have the session info.

Any suggestions on how to solve it.

BTW, the link to the demo data in that pdf doesn't seem to work and the one that I found on your website doesn't have the same data structures to follow the vignette.

Thanks.

pData(target_Data)$testTEMP <- factor(pData(protocolData(target_Data))$CD8TEMP, c("HOT", "COLD"))
results <- c()
for(segment in c("pos","neg")) {
    ind <- pData(protocolData(target_Data))$segment == segment
    mixedOutmc <-
        mixedModelDE(target_Data[, ind],
                     elt = "log_q",
                     modelFormula = ~ testTEMP + 1,
                     groupVar = "testTEMP",
                     #nCores = parallel::detectCores(),
                     #multiCore = FALSE
                     )

    # format results as data.frame
    r_test <- do.call(rbind, mixedOutmc["lsmeans", ])
    tests <- rownames(r_test)
    r_test <- as.data.frame(r_test)
    r_test$Contrast <- tests

    # use lapply in case you have multiple levels of your test factor to
    # correctly associate gene name with it's row in the results table
    r_test$Gene <- 
        unlist(lapply(colnames(mixedOutmc),
                      rep, nrow(mixedOutmc["lsmeans", ][[1]])))
    r_test$Subset <- region
    r_test$FDR <- p.adjust(r_test$`Pr(>|t|)`, method = "fdr")
    r_test <- r_test[, c("Gene", "Subset", "Contrast", "Estimate", 
                         "Pr(>|t|)", "FDR")]
    results <- rbind(results, r_test)
}
Error in eval(predvars, data, env): object 'testTEMP' not found
Traceback:

1. mixedModelDE(target_Data[, ind], elt = "log_q", modelFormula = ~testTEMP + 
 .     1, groupVar = "testTEMP", )
2. assayDataApply(object, 1, deFunc, groupVar, pDat, formula(paste("expr", 
 .     as.character(modelFormula)[2], sep = " ~ ")), pairwise, elt = elt)
3. assayDataApply(object, 1, deFunc, groupVar, pDat, formula(paste("expr", 
 .     as.character(modelFormula)[2], sep = " ~ ")), pairwise, elt = elt)
4. .local(X, MARGIN, FUN, ...)
5. .apply(X = mat, MARGIN = MARGIN, FUN = FUN, ..., .df = df, .kvs = kvs)
6. FUN(X[i, ], ...)
7. suppressMessages(lmerTest::lmer(modelFormula, dat))
8. withCallingHandlers(expr, message = function(c) if (inherits(c, 
 .     classes)) tryInvokeRestart("muffleMessage"))
9. lmerTest::lmer(modelFormula, dat)
10. eval.parent(mc)
11. eval(expr, p)
12. eval(expr, p)
13. lme4::lmer(formula = modelFormula, data = dat)
14. eval(mc, parent.frame(1L))
15. eval(mc, parent.frame(1L))
16. lme4::lFormula(formula = modelFormula, data = dat, control = structure(list(
  .     optimizer = "nloptwrap", restart_edge = TRUE, boundary.tol = 1e-05, 
  .     calc.derivs = TRUE, use.last.params = FALSE, checkControl = list(
  .         check.nobs.vs.rankZ = "ignore", check.nobs.vs.nlev = "stop", 
  .         check.nlev.gtreq.5 = "ignore", check.nlev.gtr.1 = "stop", 
  .         check.nobs.vs.nRE = "stop", check.rankX = "message+drop.cols", 
  .         check.scaleX = "warning", check.formula.LHS = "stop"), 
  .     checkConv = list(check.conv.grad = list(action = "warning", 
  .         tol = 0.002, relTol = NULL), check.conv.singular = list(
  .         action = "message", tol = 1e-04), check.conv.hess = list(
  .         action = "warning", tol = 1e-06)), optCtrl = list()), class = c("lmerControl", 
  . "merControl")))
17. eval(mf, parent.frame())
18. eval(mf, parent.frame())
19. stats::model.frame(data = dat, drop.unused.levels = TRUE, formula = expr ~ 
  .     testTEMP + 1)
20. model.frame.default(data = dat, drop.unused.levels = TRUE, formula = expr ~ 
  .     testTEMP + 1)
21. eval(predvars, data, env)
22. eval(predvars, data, env)

Session info

R version 4.2.0 (2022-04-22)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server 7.9 (Maipo)

Matrix products: default
BLAS/LAPACK:/conda_envs/nanostring/lib/libopenblasp-r0.3.20.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats4    stats     graphics  grDevices utils     datasets  methods  
[8] base     

other attached packages:
 [1] ggrepel_0.9.1           pheatmap_1.0.12         Rtsne_0.16             
 [4] umap_0.2.8.0            cowplot_1.1.1           reshape2_1.4.4         
 [7] scales_1.2.0            ggforce_0.3.3           dplyr_1.0.9            
[10] knitr_1.39              GeoMxWorkflows_1.2.0    GeomxTools_3.0.1       
[13] NanoStringNCTools_1.4.0 ggplot2_3.3.6           S4Vectors_0.34.0       
[16] Biobase_2.56.0          BiocGenerics_0.42.0    

loaded via a namespace (and not attached):
 [1] nlme_3.1-158           bitops_1.0-7           EnvStats_2.7.0        
 [4] RColorBrewer_1.1-3     GenomeInfoDb_1.32.2    repr_1.1.4            
 [7] numDeriv_2016.8-1.1    tools_4.2.0            utf8_1.2.2            
[10] R6_2.5.1               vipor_0.4.5            rgeos_0.5-9           
[13] colorspace_2.0-3       withr_2.5.0            sp_1.5-0              
[16] tidyselect_1.1.2       GGally_2.1.2           compiler_4.2.0        
[19] progressr_0.10.1       cli_3.3.0              askpass_1.1           å
[22] pbdZMQ_0.3-7           systemfonts_1.0.4      stringr_1.4.0         
[25] digest_0.6.29          minqa_1.2.4            rmarkdown_2.14        
[28] XVector_0.36.0         base64enc_0.1-3        pkgconfig_2.0.3       
[31] htmltools_0.5.2        parallelly_1.32.0      lme4_1.1-29           
[34] fastmap_1.1.0          htmlwidgets_1.5.4      rlang_1.0.3           
[37] ggthemes_4.2.4         readxl_1.4.0           farver_2.1.0          
[40] generics_0.1.2         jsonlite_1.8.0         RCurl_1.98-1.7        
[43] magrittr_2.0.3         GenomeInfoDbData_1.2.8 Matrix_1.4-1          
[46] Rcpp_1.0.8.3           ggbeeswarm_0.6.0       IRkernel_1.3          
[49] munsell_0.5.0          fansi_1.0.3            reticulate_1.25       
[52] lifecycle_1.0.1        yaml_2.3.5             stringi_1.7.6         
[55] MASS_7.3-57            zlibbioc_1.42.0        plyr_1.8.7            
[58] grid_4.2.0             parallel_4.2.0         listenv_0.8.0         
[61] crayon_1.5.1           lattice_0.20-45        IRdisplay_1.1         
[64] Biostrings_2.64.0      splines_4.2.0          pillar_1.7.0          
[67] uuid_1.1-0             boot_1.3-28            rjson_0.2.21          
[70] future.apply_1.9.0     codetools_0.2-18       glue_1.6.2            
[73] ggiraph_0.8.2          evaluate_0.15          outliers_0.15         
[76] SeuratObject_4.1.0     BiocManager_1.30.18    data.table_1.14.2     
[79] png_0.1-7              tweenr_1.0.2           vctrs_0.4.1           
[82] nloptr_2.0.3           cellranger_1.1.0       openssl_2.0.2         
[85] polyclip_1.10-0        gtable_0.3.0           purrr_0.3.4           
[88] reshape_0.8.9          future_1.26.1          xfun_0.31             
[91] RSpectra_0.16-1        tibble_3.1.7           lmerTest_3.1-3        
[94] beeswarm_0.4.0         IRanges_2.30.0         globals_0.15.1        
[97] ellipsis_0.3.2         BiocStyle_2.24.0  
~~~
NicoleEO commented 2 years ago

Hi @Flope,

Thank you for reaching out. Our customer support team will be able to help you with this. Please email geomxsupport@nanostring.com with your issue.

Thanks, Nicole

Flope commented 2 years ago

thanks