GabrielHoffman / variancePartition

Quantify and interpret divers of variation in multilevel gene expression experiments
http://gabrielhoffman.github.io/variancePartition/
60 stars 14 forks source link

confint option for topTable function not working #58

Closed jcgrenier closed 2 years ago

jcgrenier commented 2 years ago

Hello,

I'm trying to use the option to get the confidence intervals after using the dream function. I'm not able to get them. Here's the error :

topTable(fit=fitmm_global,coef="contrast1",confint=TRUE) Error in qt(alpha, df = eb$df.total[top]) : Non-numeric argument to mathematical function

Thanks for your help! Jean-Christophe

GabrielHoffman commented 2 years ago

Can you show the result of sessionInfo()


From: Jean-Christophe Grenier @.> Sent: Tuesday, July 12, 2022 11:22:51 AM To: GabrielHoffman/variancePartition @.> Cc: Subscribed @.***> Subject: [GabrielHoffman/variancePartition] confint option for topTable function not working (Issue #58)

USE CAUTION: External Message.

Hello,

I'm trying to use the option to get the confidence intervals after using the dream function. I'm not able to get them. Here's the error :

topTable(fit=fitmm_global,coef="contrast1",confint=TRUE) Error in qt(alpha, df = eb$df.total[top]) : Non-numeric argument to mathematical function

Thanks for your help! Jean-Christophe

— Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_GabrielHoffman_variancePartition_issues_58&d=DwMCaQ&c=shNJtf5dKgNcPZ6Yh64b-A&r=KdYcmw5SdXylMrTGSuNVkNJulowod64k0PTDC5BHZkk&m=svaiCICkUrndE5FklFs_33oG2IhYjqgqbZ2gHiJyuYE&s=miwakTOH1P4vOMm0o7S0VzVWgt1zNihONtjNUNzzjkg&e=, or unsubscribehttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_ADFAXTOYNHBVB3W3LMMR3GDVTWEUXANCNFSM53LNTYAQ&d=DwMCaQ&c=shNJtf5dKgNcPZ6Yh64b-A&r=KdYcmw5SdXylMrTGSuNVkNJulowod64k0PTDC5BHZkk&m=svaiCICkUrndE5FklFs_33oG2IhYjqgqbZ2gHiJyuYE&s=eMKuNGF32b6pln3b10M93NDakpEp3DNj38uCVhjXc88&e=. You are receiving this because you are subscribed to this thread.Message ID: @.***>

jcgrenier commented 2 years ago

Sure :

R version 4.1.2 (2021-11-01)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib

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

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

other attached packages:
 [1] tidyr_1.1.4              variancePartition_1.24.0 Matrix_1.3-4             reshape2_1.4.4           dplyr_1.0.7              plyr_1.8.6               edgeR_3.36.0             limma_3.50.0             heplots_1.3-9            car_3.0-12               carData_3.0-4            flashClust_1.01-2        WGCNA_1.70-3             fastcluster_1.2.3        dynamicTreeCut_1.63-1    sva_3.42.0               BiocParallel_1.28.2      genefilter_1.76.0        mgcv_1.8-38              nlme_3.1-153             umap_0.2.7.0             ggfortify_0.4.14         ggrepel_0.9.1            ggplot2_3.3.5            dendsort_0.3.4           RColorBrewer_1.1-2       pheatmap_1.0.12          gplots_3.1.1             vegan_2.5-7              lattice_0.20-45          permute_0.9-5            ape_5.5

loaded via a namespace (and not attached):
  [1] snow_0.4-4             backports_1.4.0        Hmisc_4.6-0            splines_4.1.2          GenomeInfoDb_1.30.0    digest_0.6.29          foreach_1.5.1          htmltools_0.5.2        GO.db_3.14.0           lmerTest_3.1-3         fansi_0.5.0            magrittr_2.0.1         checkmate_2.0.0        memoise_2.0.1          cluster_2.1.2          doParallel_1.0.16      Biostrings_2.62.0      annotate_1.72.0        matrixStats_0.61.0     askpass_1.1            prettyunits_1.1.1      jpeg_0.1-9             colorspace_2.0-2       blob_1.2.2             xfun_0.28              tcltk_4.1.2            crayon_1.4.2           RCurl_1.98-1.5         jsonlite_1.7.2         lme4_1.1-27.1          impute_1.68.0          survival_3.2-13        iterators_1.0.13       glue_1.5.1             gtable_0.3.0           zlibbioc_1.40.0        XVector_0.34.0         BiocGenerics_0.40.0    abind_1.4-5            scales_1.1.1           DBI_1.1.1              Rcpp_1.0.7             xtable_1.8-4           progress_1.2.2         htmlTable_2.3.0        reticulate_1.24        foreign_0.8-81         bit_4.0.4              preprocessCore_1.56.0  Formula_1.2-4          stats4_4.1.2           htmlwidgets_1.5.4      httr_1.4.2             ellipsis_0.3.2         farver_2.1.0           pkgconfig_2.0.3        XML_3.99-0.8           nnet_7.3-16            locfit_1.5-9.4         utf8_1.2.2             tidyselect_1.1.1       labeling_0.4.2         rlang_0.4.12           AnnotationDbi_1.56.2   munsell_0.5.0          tools_4.1.2            cachem_1.0.6           generics_0.1.1         RSQLite_2.2.9          broom_0.7.10           stringr_1.4.0          fastmap_1.1.0          knitr_1.36             bit64_4.0.5            caTools_1.18.2         purrr_0.3.4            KEGGREST_1.34.0        compiler_4.1.2         pbkrtest_0.5.1         rstudioapi_0.13        png_0.1-7              tibble_3.1.6           stringi_1.7.6          RSpectra_0.16-0        nloptr_1.2.2.3         vctrs_0.3.8            pillar_1.6.4           lifecycle_1.0.1        data.table_1.14.2      bitops_1.0-7           R6_2.5.1               latticeExtra_0.6-29    KernSmooth_2.23-20     gridExtra_2.3          IRanges_2.28.0         codetools_0.2-18       boot_1.3-28            MASS_7.3-54            gtools_3.9.2           assertthat_0.2.1       openssl_1.4.5          withr_2.4.3            S4Vectors_0.32.3       GenomeInfoDbData_1.2.7 parallel_4.1.2         hms_1.1.1              grid_4.1.2             rpart_4.1-15           minqa_1.2.4            numDeriv_2016.8-1.1    Biobase_2.54.0         base64enc_0.1-3

Thanks a lot!

GabrielHoffman commented 2 years ago

Can you confirm that that issue only comes up when using contrasts? Does it work as expected when using a simple coef? I'm on vacation this week, so the earliest fix will be Monday

Gabriel

jcgrenier commented 2 years ago

Sorry, it's a coefficient in reality, bad terminology on my end. The term is in the table fitmm_global$coefficients. No worries, thanks for helping me out!

GabrielHoffman commented 2 years ago

Thanks for your bug report.

As of version 1.25.4, the empirical Bayes shrinkage works for linear mixed models too. I updated the code and documentation so users should run eBayes() following dream(). See https://gabrielhoffman.github.io/variancePartition/articles/dream.html#dream-analysis

Your code should work if you run the eBayes() step.

Here's a code example:


library(variancePartition)
library(BiocParallel)

data(varPartData)

form <- ~ 0 + Batch + (1|Individual) + (1|Tissue) 

# Define contrasts
L = makeContrastsDream( form, info, contrasts = c(Batch1_vs_2 = "Batch1 - Batch2", Batch3_vs_4 = "Batch3 - Batch4", Batch1_vs_34 = "Batch1 - (Batch3 + Batch4)/2"))

fit = dream( geneExpr[1:10,], form, info, L=L)
fit = eBayes(fit)

topTable(fit, coef="Batch1_vs_2", confint=TRUE)

Best, Gabriel

jcgrenier commented 2 years ago

I confirm that it's working! Thanks a lot for your help!! It's really appreciated! Have a good vacation!