neurorestore / Libra

MIT License
153 stars 25 forks source link

limma not working correctly #17

Open chengmingbo opened 2 years ago

chengmingbo commented 2 years ago

Hi, limma looks still not working. Here I used ifnb data to create fake replicates. EdgeR works fine, but limma not.

The R code

library(SeuratData)
library(Seurat)
library(Libra)

InstallData("ifnb")
LoadData("ifnb")

ifnb <- UpdateSeuratObject(ifnb)

ifnb$celltype <- as.character(ifnb$seurat_annotations)
ifnb$rep <- ifnb$orig.ident
lenctrl = length(which(ifnb$rep=="IMMUNE_CTRL"))
lenstim = length(which(ifnb$rep=="IMMUNE_STIM"))

ifnb$rep[ifnb$rep=="IMMUNE_CTRL"] <-paste0("ctrl_", c(rep(1, as.integer(lenctrl/2)),rep(2, lenctrl-as.integer(lenctrl/2))))
ifnb$rep[ifnb$rep=="IMMUNE_STIM"] <-paste0("stim_", c(rep(1, as.integer(lenstim/2)),rep(2, lenstim-as.integer(lenstim/2))))

DE = run_de(ifnb, cell_type_col = "celltype", label_col = "stim", replicate_col="rep", de_method="limma")

Error message:

[1] "B"
[1] "B Activated"
[1] "CD14 Mono"
[1] "CD16 Mono"
[1] "CD4 Memory T"
[1] "CD4 Naive T"
[1] "CD8 T"
[1] "DC"
[1] "Eryth"
[1] "Mk"
[1] "NK"
[1] "pDC"
[1] "T activated"
object 'trend_bool' not foundobject 'trend_bool' not foundobject 'trend_bool' not foundobject 'trend_bool' not foundobject 'trend_bool' not foundobject 'trend_bool' not foundobject 'trend_bool' not foundobject 'trend_bool' not foundobject 'trend_bool' not foundobject 'trend_bool' not foundobject 'trend_bool' not foundobject 'trend_bool' not foundobject 'trend_bool' not foundError: Problem with `mutate()` column `p_val_adj`.
ℹ `p_val_adj = p.adjust(p_val, method = "BH")`.
✖ object 'p_val' not found
Run `rlang::last_error()` to see where the error occurred.

Session info

r$> sessionInfo()                                                                                                                                             
R version 4.1.0 (2021-05-18)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: Rocky Linux 8.5 (Green Obsidian)

Matrix products: default
BLAS/LAPACK: /data/sz753404/miniconda3/envs/schema/lib/libopenblasp-r0.3.17.so

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

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

other attached packages:
[1] ifnb.SeuratData_3.1.0   bmcite.SeuratData_0.3.0 SeuratData_0.2.1        Libra_1.0.0             SeuratObject_4.0.4      Seurat_4.0.6           

loaded via a namespace (and not attached):
  [1] blme_1.0-5                  plyr_1.8.6                  igraph_1.3.0                lazyeval_0.2.2              TMB_1.8.1                  
  [6] splines_4.1.0               BiocParallel_1.26.2         listenv_0.8.0               scattermore_0.7             TH.data_1.1-0              
 [11] GenomeInfoDb_1.28.4         ggplot2_3.3.5               digest_0.6.29               htmltools_0.5.2             lmerTest_3.1-3             
 [16] fansi_0.5.0                 magrittr_2.0.1              memoise_2.0.1               tensor_1.5                  cluster_2.1.2              
 [21] ROCR_1.0-11                 limma_3.48.3                globals_0.14.0              Biostrings_2.60.2           annotate_1.70.0            
 [26] tester_0.1.7                matrixStats_0.61.0          sandwich_3.0-1              spatstat.sparse_2.1-0       colorspace_2.0-2           
 [31] rappdirs_0.3.3              blob_1.2.2                  ggrepel_0.9.1               dplyr_1.0.7                 crayon_1.4.2               
 [36] RCurl_1.98-1.5              jsonlite_1.7.2              genefilter_1.74.1           lme4_1.1-27.1               spatstat.data_2.1-2        
 [41] survival_3.2-13             zoo_1.8-9                   glue_1.6.0                  polyclip_1.10-0             gtable_0.3.0               
 [46] emmeans_1.7.0               zlibbioc_1.38.0             XVector_0.32.0              leiden_0.3.9                DelayedArray_0.18.0        
 [51] future.apply_1.8.1          BiocGenerics_0.38.0         abind_1.4-5                 scales_1.1.1                mvtnorm_1.1-3              
 [56] DBI_1.1.2                   edgeR_3.34.1                miniUI_0.1.1.1              Rcpp_1.0.7                  viridisLite_0.4.0          
 [61] xtable_1.8-4                reticulate_1.22             spatstat.core_2.3-2         bit_4.0.4                   stats4_4.1.0               
 [66] htmlwidgets_1.5.4           httr_1.4.2                  RColorBrewer_1.1-2          ellipsis_0.3.2              ica_1.0-2                  
 [71] pkgconfig_2.0.3             XML_3.99-0.8                uwot_0.1.11                 deldir_1.0-6                locfit_1.5-9.4             
 [76] utf8_1.2.2                  tidyselect_1.1.1            rlang_0.4.12                reshape2_1.4.4              later_1.3.0                
 [81] AnnotationDbi_1.54.1        pbmcapply_1.5.1             munsell_0.5.0               tools_4.1.0                 cachem_1.0.6               
 [86] cli_3.1.0                   generics_0.1.1              RSQLite_2.2.8               ggridges_0.5.3              stringr_1.4.0              
 [91] fastmap_1.1.0               goftest_1.2-3               bit64_4.0.5                 fitdistrplus_1.1-6          purrr_0.3.4                
 [96] RANN_2.6.1                  KEGGREST_1.32.0             pbapply_1.5-0               future_1.23.0               nlme_3.1-153               
[101] mime_0.12                   compiler_4.1.0              plotly_4.10.0               png_0.1-7                   spatstat.utils_2.3-0       
[106] tibble_3.1.6                geneplotter_1.70.0          stringi_1.7.5               forcats_0.5.1               lattice_0.20-45            
[111] Matrix_1.3-4                nloptr_1.2.2.3              vctrs_0.3.8                 pillar_1.6.4                lifecycle_1.0.1            
[116] spatstat.geom_2.4-0         lmtest_0.9-39               estimability_1.3            RcppAnnoy_0.0.19            data.table_1.14.2          
[121] cowplot_1.1.1               bitops_1.0-7                irlba_2.3.5                 httpuv_1.6.4                patchwork_1.1.1            
[126] GenomicRanges_1.44.0        R6_2.5.1                    promises_1.2.0.1            KernSmooth_2.23-20          gridExtra_2.3              
[131] IRanges_2.26.0              parallelly_1.30.0           codetools_0.2-18            boot_1.3-28                 MASS_7.3-54                
[136] assertthat_0.2.1            SummarizedExperiment_1.22.0 DESeq2_1.32.0               sctransform_0.3.2           multcomp_1.4-17            
[141] S4Vectors_0.30.2            GenomeInfoDbData_1.2.6      mgcv_1.8-38                 parallel_4.1.0              grid_4.1.0                 
[146] rpart_4.1-15                coda_0.19-4                 glmmTMB_1.1.3               tidyr_1.1.4                 minqa_1.2.4                
[151] MatrixGenerics_1.4.3        Rtsne_0.15                  numDeriv_2016.8-1.1         Biobase_2.52.0              shiny_1.7.1                
chengmingbo commented 2 years ago

toy data failed too.

DE = run_de(hagai_toy,  cell_type_col = "cell_type", label_col = "label", replicate_col="replicate", de_method="limma")
[1] "bone marrow derived mononuclear phagocytes"
object 'trend_bool' not foundError: Problem with `mutate()` column `p_val_adj`.
ℹ `p_val_adj = p.adjust(p_val, method = "BH")`.
✖ object 'p_val' not found
Run `rlang::last_error()` to see where the error occurred.
jordansquair commented 2 years ago

pushed a fix.