HelenaLC / muscat

Multi-sample multi-group scRNA-seq analysis tools
160 stars 32 forks source link

Error in .check_args_pbHeatmap #105

Closed lindsaynhayes closed 2 years ago

lindsaynhayes commented 2 years ago

When I try to generate a heat map with pbHeatmap it gives an error about the sort_by function. I tried the heatmap with several different configurations for example: pbHeatmap(sce, res, k = "Myeloid") or pbHeatmap(sce, res, g = "CSF1R"), even if I specify the sort_by= I still get the error. pbHeatmap(sce, res, sort_by="p_adj.loc")

Here is the error:

Error in .check_args_pbHeatmap(as.list(environment())) : 
  u$sort_by == "none" | u$sort_by %in% names(u$y$table[[1]][[1]]) &  .... is not TRUE
HelenaLC commented 2 years ago

I can't reproduce this from the information provided. The function's example works fine for me:

data(example_sce)
pb <- aggregateData(example_sce)
res <- pbDS(pb)
# all of these run without issues
pbHeatmap(example_sce, res)
pbHeatmap(example_sce, res, sort_by = "none")
pbHeatmap(example_sce, res, sort_by = "logFC")

Could you please provide (with any issue!) the output of your sessionInfo() as well as any relevant outputs (e.g., names(res$table), names(res$table[[1]]) and names(res$table[[1]][[1]])) that might aid in figuring out the issue.

lindsaynhayes commented 2 years ago

I apologize for not providing enough information. My results were produced using mmDS. Does it have to be the pseudobulk version? In the ?pbHeatmap it states that y can be from pbDS or mmDS. The str of my res and the res <- pbDS(pb) is very different. This is probably the problem.

res <- mmDS(sce, coef = "group_idVS-HIV", method = "dream2", n_cells = 10, n_samples = 2, min_cells = 20, verbose = TRUE)
class(res)
[1] "list"
> sessionInfo()
R version 4.2.0 (2022-04-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.3.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
 [1] edgeR_3.38.1                limma_3.52.1                purrr_0.3.4                
 [4] UpSetR_1.4.0                bluster_1.6.0               scran_1.24.0               
 [7] scater_1.24.0               scuttle_1.6.0               SingleCellExperiment_1.18.0
[10] SummarizedExperiment_1.26.1 Biobase_2.56.0              GenomicRanges_1.48.0       
[13] GenomeInfoDb_1.32.2         IRanges_2.30.0              S4Vectors_0.34.0           
[16] BiocGenerics_0.42.0         MatrixGenerics_1.8.0        matrixStats_0.62.0         
[19] muscat_1.11.0               cowplot_1.1.1               ggplot2_3.3.6              
[22] dplyr_1.0.9                 glmGamPoi_1.8.0             scDblFinder_1.10.0         
[25] sp_1.4-7                    SeuratObject_4.1.0          Seurat_4.1.1               

loaded via a namespace (and not attached):
  [1] rtracklayer_1.56.0        scattermore_0.8           tidyr_1.2.0              
  [4] bit64_4.0.5               knitr_1.39                irlba_2.3.5              
  [7] DelayedArray_0.22.0       data.table_1.14.2         rpart_4.1.16             
 [10] KEGGREST_1.36.0           RCurl_1.98-1.6            doParallel_1.0.17        
 [13] generics_0.1.2            ScaledMatrix_1.4.0        RhpcBLASctl_0.21-247.1   
 [16] RSQLite_2.2.14            RANN_2.6.1                future_1.25.0            
 [19] bit_4.0.4                 spatstat.data_2.2-0       httpuv_1.6.5             
 [22] assertthat_0.2.1          viridis_0.6.2             xfun_0.31                
 [25] hms_1.1.1                 evaluate_0.15             promises_1.2.0.1         
 [28] progress_1.2.2            fansi_1.0.3               restfulr_0.0.13          
 [31] caTools_1.18.2            igraph_1.3.1              DBI_1.1.2                
 [34] geneplotter_1.74.0        htmlwidgets_1.5.4         spatstat.geom_2.4-0      
 [37] ellipsis_0.3.2            RSpectra_0.16-1           backports_1.4.1          
 [40] annotate_1.74.0           aod_1.3.2                 deldir_1.0-6             
 [43] sparseMatrixStats_1.8.0   vctrs_0.4.1               ROCR_1.0-11              
 [46] abind_1.4-5               cachem_1.0.6              withr_2.5.0              
 [49] progressr_0.10.0          sctransform_0.3.3         GenomicAlignments_1.32.0 
 [52] prettyunits_1.1.1         goftest_1.2-3             cluster_2.1.3            
 [55] lazyeval_0.2.2            crayon_1.5.1              genefilter_1.78.0        
 [58] pkgconfig_2.0.3           labeling_0.4.2            nlme_3.1-157             
 [61] vipor_0.4.5               blme_1.0-5                rlang_1.0.2              
 [64] globals_0.15.0            lifecycle_1.0.1           miniUI_0.1.1.1           
 [67] rsvd_1.0.5                polyclip_1.10-0           lmtest_0.9-40            
 [70] Matrix_1.4-1              boot_1.3-28               zoo_1.8-10               
 [73] beeswarm_0.4.0            ggridges_0.5.3            GlobalOptions_0.1.2      
 [76] png_0.1-7                 viridisLite_0.4.0         rjson_0.2.21             
 [79] bitops_1.0-7              KernSmooth_2.23-20        Biostrings_2.64.0        
 [82] blob_1.2.3                DelayedMatrixStats_1.18.0 shape_1.4.6              
 [85] stringr_1.4.0             parallelly_1.31.1         spatstat.random_2.2-0    
 [88] beachmat_2.12.0           scales_1.2.0              memoise_2.0.1            
 [91] magrittr_2.0.3            plyr_1.8.7                ica_1.0-2                
 [94] gplots_3.1.3              zlibbioc_1.42.0           compiler_4.2.0           
 [97] dqrng_0.3.0               BiocIO_1.6.0              RColorBrewer_1.1-3       
[100] clue_0.3-60               lme4_1.1-29               DESeq2_1.36.0            
[103] fitdistrplus_1.1-8        Rsamtools_2.12.0          cli_3.3.0                
[106] XVector_0.36.0            lmerTest_3.1-3            listenv_0.8.0            
[109] patchwork_1.1.1           pbapply_1.5-0             TMB_1.8.1                
[112] MASS_7.3-57               mgcv_1.8-40               tidyselect_1.1.2         
[115] stringi_1.7.6             yaml_2.3.5                BiocSingular_1.12.0      
[118] locfit_1.5-9.5            ggrepel_0.9.1             grid_4.2.0               
[121] tools_4.2.0               future.apply_1.9.0        parallel_4.2.0           
[124] circlize_0.4.15           rstudioapi_0.13           foreach_1.5.2            
[127] metapod_1.4.0             gridExtra_2.3             farver_2.1.0             
[130] Rtsne_0.16                digest_0.6.29             rgeos_0.5-9              
[133] shiny_1.7.1               Rcpp_1.0.8.3              broom_0.8.0              
[136] later_1.3.0               RcppAnnoy_0.0.19          httr_1.4.3               
[139] AnnotationDbi_1.58.0      ComplexHeatmap_2.12.0     Rdpack_2.3               
[142] colorspace_2.0-3          XML_3.99-0.9              tensor_1.5               
[145] reticulate_1.25           splines_4.2.0             uwot_0.1.11              
[148] statmod_1.4.36            spatstat.utils_2.3-1      xgboost_1.6.0.1          
[151] plotly_4.10.0             xtable_1.8-4              jsonlite_1.8.0           
[154] nloptr_2.0.0              R6_2.5.1                  pillar_1.7.0             
[157] htmltools_0.5.2           mime_0.12                 glue_1.6.2               
[160] fastmap_1.1.0             minqa_1.2.4               BiocParallel_1.30.2      
[163] BiocNeighbors_1.14.0      codetools_0.2-18          utf8_1.2.2               
[166] lattice_0.20-45           spatstat.sparse_2.1-1     tibble_3.1.7             
[169] pbkrtest_0.5.1            numDeriv_2016.8-1.1       ggbeeswarm_0.6.0         
[172] leiden_0.4.2              gtools_3.9.2              survival_3.3-1           
[175] glmmTMB_1.1.3             rmarkdown_2.14            munsell_0.5.0            
[178] GetoptLong_1.0.5          GenomeInfoDbData_1.2.8    iterators_1.0.14         
[181] variancePartition_1.26.0  reshape2_1.4.4            gtable_0.3.0             
[184] rbibutils_2.2.8           spatstat.core_2.4-2    
> names(res$table)
NULL
> str(res)
List of 4
 $ Myeloid  :'data.frame':  10833 obs. of  8 variables:
  ..$ gene      : chr [1:10833] "LINC01409" "LINC01128" "NOC2L" "ISG15" ...
  ..$ cluster_id: chr [1:10833] "Myeloid" "Myeloid" "Myeloid" "Myeloid" ...
  ..$ logFC     : num [1:10833] -0.02635 -0.1117 -0.00401 -0.2978 -0.09281 ...
  ..$ AveExpr   : num [1:10833] 18.2 18.2 18.4 19.2 18.1 ...
  ..$ t         : num [1:10833] -0.1834 -0.8567 -0.0497 -2.3466 -0.6733 ...
  ..$ p_val     : num [1:10833] 0.872 0.487 0.966 0.145 0.573 ...
  ..$ p_adj.loc : num [1:10833] 1 1 1 1 1 ...
  ..$ p_adj.glb : num [1:10833] 0.948 0.715 0.986 0.326 0.786 ...
 $ NK       :'data.frame':  6427 obs. of  8 variables:
  ..$ gene      : chr [1:6427] "LINC01409" "NOC2L" "ISG15" "TNFRSF18" ...
  ..$ cluster_id: chr [1:6427] "NK" "NK" "NK" "NK" ...
  ..$ logFC     : num [1:6427] -0.0799 -0.1268 -0.0459 -0.4177 -0.1927 ...
  ..$ AveExpr   : num [1:6427] 18.1 18.3 18.7 18.4 18.2 ...
  ..$ t         : num [1:6427] -1.205 -1.484 -0.325 -4.407 -2.241 ...
  ..$ p_val     : num [1:6427] 2.29e-01 1.39e-01 7.45e-01 1.58e-05 2.27e-01 ...
  ..$ p_adj.loc : num [1:6427] 0.93262 0.83371 0.95128 0.00282 0.93262 ...
  ..$ p_adj.glb : num [1:6427] 0.439585 0.318184 0.88791 0.000143 0.43712 ...
 $ Tcell_CD4:'data.frame':  10868 obs. of  8 variables:
  ..$ gene      : chr [1:10868] "LINC01409" "LINC01128" "NOC2L" "PLEKHN1" ...
  ..$ cluster_id: chr [1:10868] "Tcell_CD4" "Tcell_CD4" "Tcell_CD4" "Tcell_CD4" ...
  ..$ logFC     : num [1:10868] -0.19876 -0.19238 -0.13867 -0.21292 0.00549 ...
  ..$ AveExpr   : num [1:10868] 18 18.1 18.2 18 18.6 ...
  ..$ t         : num [1:10868] -21.6032 -15.008 -7.8902 -26.4889 0.0317 ...
  ..$ p_val     : num [1:10868] 1.91e-99 6.16e-50 3.61e-15 1.09e-145 9.78e-01 ...
  ..$ p_adj.loc : num [1:10868] 7.04e-98 7.93e-49 2.15e-14 1.29e-143 9.81e-01 ...
  ..$ p_adj.glb : num [1:10868] 2.13e-97 1.96e-48 4.46e-14 4.24e-143 9.91e-01 ...
 $ Tcell_CD8:'data.frame':  10752 obs. of  8 variables:
  ..$ gene      : chr [1:10752] "LINC01409" "LINC01128" "NOC2L" "PLEKHN1" ...
  ..$ cluster_id: chr [1:10752] "Tcell_CD8" "Tcell_CD8" "Tcell_CD8" "Tcell_CD8" ...
  ..$ logFC     : num [1:10752] -0.1374 -0.2101 -0.1889 -0.1739 -0.0833 ...
  ..$ AveExpr   : num [1:10752] 18 18 18.2 18 18.5 ...
  ..$ t         : num [1:10752] -14.62 -4.42 -3.92 -10.76 -0.58 ...
  ..$ p_val     : num [1:10752] 3.01e-47 4.91e-02 8.80e-02 2.39e-02 6.23e-01 ...
  ..$ p_adj.loc : num [1:10752] 7.79e-46 1.17e-01 1.53e-01 9.76e-02 6.57e-01 ...
  ..$ p_adj.glb : num [1:10752] 8.94e-46 1.80e-01 2.43e-01 1.35e-01 8.20e-01 ...
HelenaLC commented 2 years ago

Aha, yes, indeed, that would have been good to know. I could reproduce this with results from mmDS(). I have pushed a fixed to Bioc devel just now (might take 24-48h to go through). Once this builds cleanly, I will also push the fix to release. Leaving this open for now until you can confirm it's working! Thanks for catching this.

lindsaynhayes commented 2 years ago

I have been away at conferences and was unable to test this until now. I installed the dev version and tried again, but I am still getting the same error message. devtools::install_github("HelenaLC/muscat", ref = "devel") the sessionInfo() has me now running muscat_1.5.2. Is the correct version for the devel?

lindsaynhayes commented 2 years ago

Ok it worked! I had to re-reun the mmDS instead of loading the previously run one. And I see you pushed it to master. Thanks!