glmGamPoi icon indicating copy to clipboard operation
glmGamPoi copied to clipboard

Error in pseudobulk step

Open darcymi opened this issue 1 year ago • 1 comments

Hi,

I was having issues with my own dataset, so tried running the one given in the vignette and ran into the same problem.

In the vignette, starting in section 3.2 I ran the code from sce <- muscData::Kang18_8vs8() to de_res <- test_de(fit, contrast = stimstim+cellCD4 T cells:stimstim, pseudobulk_by = paste0(stim, "-", ind))

This last command resulted in the following error: Error in value[3L] : Object 'stim' not found. Allowed variables are:

There are no allowed variables listed after the colon. Is there a way to get it to recognize the colData columns? I am running glmGamPoi version 1.8.0.

Thanks for your help!

darcymi avatar Nov 04 '22 17:11 darcymi

Hi darcymi,

sorry for the delayed response. I was traveling last week and didn't check my emails.


First of all, thank you for opening the issue; it's always important to hear when things don't work. I tried to run the example that you were referencing, but I cannot reproduce the error:

library(glmGamPoi)
sce <- muscData::Kang18_8vs8()
#> snapshotDate(): 2021-05-18
#> see ?muscData and browseVignettes('muscData') for documentation
#> loading from cache
set.seed(1)
# Take highly expressed genes and proper cells:
sce_subset <- sce[rowSums(counts(sce)) > 100, 
                  sample(which(sce$multiplets == "singlet" & 
                                 ! is.na(sce$cell) &
                                 sce$cell %in% c("CD4 T cells", "B cells", "NK cells")), 
                         1000)]
# Convert counts to dense matrix
counts(sce_subset) <- as.matrix(counts(sce_subset))
# Remove empty levels because glm_gp() will complain otherwise
sce_subset$cell <- droplevels(sce_subset$cell)

fit <- glm_gp(sce_subset, design = ~ cell + stim +  stim:cell - 1,
              reference_level = "NK cells")
de_res <- test_de(fit, contrast = `stimstim` + `cellCD4 T cells:stimstim`, 
                  pseudobulk_by = paste0(stim, "-", ind)) 
head(de_res)
#>        name         pval   adj_pval  f_statistic df1      df2        lfc
#> 1 LINC00115 9.488240e-01 1.00000000 4.158485e-03   1 53.36198 -0.5418114
#> 2     NOC2L 5.827811e-01 1.00000000 3.054703e-01   1 53.36198 -0.7664476
#> 3   PLEKHN1 9.999228e-01 1.00000000 9.461520e-09   1 53.36198 31.3439440
#> 4      HES4 1.333351e-01 0.93055719 2.323538e+00   1 53.36198 -3.8056793
#> 5     ISG15 6.650242e-05 0.04620493 1.873020e+01   1 53.36198  3.3361152
#> 6  TNFRSF18 5.992403e-01 1.00000000 2.794707e-01   1 53.36198 -0.7194761

Created on 2022-11-14 by the reprex package (v2.0.1)

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 4.1.1 (2021-08-10)
#>  os       macOS Big Sur 10.16         
#>  system   x86_64, darwin17.0          
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       Europe/Berlin               
#>  date     2022-11-14                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package                * version  date       lib
#>  AnnotationDbi            1.54.1   2021-06-08 [1]
#>  AnnotationHub          * 3.0.1    2021-06-20 [1]
#>  assertthat               0.2.1    2019-03-21 [1]
#>  backports                1.2.1    2020-12-09 [1]
#>  Biobase                * 2.52.0   2021-05-19 [1]
#>  BiocFileCache          * 2.0.0    2021-05-19 [1]
#>  BiocGenerics           * 0.38.0   2021-05-19 [1]
#>  BiocManager              1.30.16  2021-06-15 [1]
#>  BiocVersion              3.13.1   2021-03-09 [1]
#>  Biostrings               2.60.2   2021-08-05 [1]
#>  bit                      4.0.4    2020-08-04 [1]
#>  bit64                    4.0.5    2020-08-30 [1]
#>  bitops                   1.0-7    2021-04-24 [1]
#>  blob                     1.2.2    2021-07-23 [1]
#>  cachem                   1.0.6    2021-08-19 [1]
#>  cli                      3.3.0    2022-04-25 [1]
#>  crayon                   1.4.1    2021-02-08 [1]
#>  curl                     4.3.2    2021-06-23 [1]
#>  DBI                      1.1.1    2021-01-15 [1]
#>  dbplyr                 * 2.1.1    2021-04-06 [1]
#>  DelayedArray             0.18.0   2021-05-19 [1]
#>  DelayedMatrixStats       1.14.3   2021-08-26 [1]
#>  digest                   0.6.27   2020-10-24 [1]
#>  dplyr                    1.0.7    2021-06-18 [1]
#>  ellipsis                 0.3.2    2021-04-29 [1]
#>  evaluate                 0.14     2019-05-28 [1]
#>  ExperimentHub          * 2.0.0    2021-05-19 [1]
#>  fansi                    0.5.0    2021-05-25 [1]
#>  fastmap                  1.1.0    2021-01-25 [1]
#>  filelock                 1.0.2    2018-10-05 [1]
#>  fs                       1.5.0    2020-07-31 [1]
#>  generics                 0.1.2    2022-01-31 [1]
#>  GenomeInfoDb           * 1.28.4   2021-09-05 [1]
#>  GenomeInfoDbData         1.2.6    2021-09-09 [1]
#>  GenomicRanges          * 1.44.0   2021-05-19 [1]
#>  glmGamPoi              * 1.8.0    2022-11-14 [1]
#>  glue                     1.6.2    2022-02-24 [1]
#>  highr                    0.9      2021-04-16 [1]
#>  htmltools                0.5.2    2021-08-25 [1]
#>  httpuv                   1.6.3    2021-09-09 [1]
#>  httr                     1.4.2    2020-07-20 [1]
#>  interactiveDisplayBase   1.30.0   2021-05-19 [1]
#>  IRanges                * 2.26.0   2021-05-19 [1]
#>  KEGGREST                 1.32.0   2021-05-19 [1]
#>  knitr                    1.34     2021-09-09 [1]
#>  later                    1.3.0    2021-08-18 [1]
#>  lattice                  0.20-44  2021-05-02 [1]
#>  lifecycle                1.0.0    2021-02-15 [1]
#>  magrittr                 2.0.1    2020-11-17 [1]
#>  Matrix                   1.3-4    2021-06-01 [1]
#>  MatrixGenerics         * 1.9.0    2022-06-08 [1]
#>  matrixStats            * 0.60.1   2021-08-23 [1]
#>  memoise                  2.0.0    2021-01-26 [1]
#>  mime                     0.11     2021-06-23 [1]
#>  muscData               * 1.6.0    2021-05-20 [1]
#>  pillar                   1.6.2    2021-07-29 [1]
#>  pkgconfig                2.0.3    2019-09-22 [1]
#>  png                      0.1-7    2013-12-03 [1]
#>  promises                 1.2.0.1  2021-02-11 [1]
#>  purrr                    0.3.4    2020-04-17 [1]
#>  R6                       2.5.1    2021-08-19 [1]
#>  rappdirs                 0.3.3    2021-01-31 [1]
#>  Rcpp                     1.0.7    2021-07-07 [1]
#>  RCurl                    1.98-1.4 2021-08-17 [1]
#>  reprex                   2.0.1    2021-08-05 [1]
#>  rlang                    1.0.3    2022-06-27 [1]
#>  rmarkdown                2.11     2021-09-14 [1]
#>  RSQLite                  2.2.8    2021-08-21 [1]
#>  rstudioapi               0.13     2020-11-12 [1]
#>  S4Vectors              * 0.30.0   2021-05-19 [1]
#>  sessioninfo              1.1.1    2018-11-05 [1]
#>  shiny                    1.7.2    2022-07-19 [1]
#>  SingleCellExperiment   * 1.14.1   2021-05-21 [1]
#>  sparseMatrixStats        1.4.2    2021-08-08 [1]
#>  stringi                  1.7.4    2021-08-25 [1]
#>  stringr                  1.4.0    2019-02-10 [1]
#>  styler                   1.5.1    2021-07-13 [1]
#>  SummarizedExperiment   * 1.22.0   2021-05-19 [1]
#>  tibble                   3.1.4    2021-08-25 [1]
#>  tidyselect               1.1.1    2021-04-30 [1]
#>  utf8                     1.2.2    2021-07-24 [1]
#>  vctrs                    0.3.8    2021-04-29 [1]
#>  withr                    2.4.2    2021-04-18 [1]
#>  xfun                     0.26     2021-09-14 [1]
#>  xtable                   1.8-4    2019-04-21 [1]
#>  XVector                  0.32.0   2021-05-19 [1]
#>  yaml                     2.2.1    2020-02-01 [1]
#>  zlibbioc                 1.38.0   2021-05-19 [1]
#>  source                                  
#>  Bioconductor                            
#>  Bioconductor                            
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  Bioconductor                            
#>  Bioconductor                            
#>  Bioconductor                            
#>  CRAN (R 4.1.0)                          
#>  Bioconductor                            
#>  Bioconductor                            
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.2)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  Bioconductor                            
#>  Bioconductor                            
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  Bioconductor                            
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.2)                          
#>  Bioconductor                            
#>  Bioconductor                            
#>  Bioconductor                            
#>  Bioconductor                            
#>  CRAN (R 4.1.2)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  Bioconductor                            
#>  Bioconductor                            
#>  Bioconductor                            
#>  CRAN (R 4.1.1)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.1)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.1)                          
#>  Github (const-ae/MatrixGenerics@263ddc7)
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  Bioconductor                            
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.2)                          
#>  CRAN (R 4.1.1)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  Bioconductor                            
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.2)                          
#>  Bioconductor                            
#>  Bioconductor                            
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  Bioconductor                            
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.0)                          
#>  CRAN (R 4.1.1)                          
#>  CRAN (R 4.1.0)                          
#>  Bioconductor                            
#>  CRAN (R 4.1.0)                          
#>  Bioconductor                            
#> 
#> [1] /Library/Frameworks/R.framework/Versions/4.1/Resources/library

Could you run the same code (preferably through reprex) and post the output so that we can figure out why the error occurs for you?

Best, Constantin

const-ae avatar Nov 14 '22 09:11 const-ae