GabrielHoffman / variancePartition

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

Can't run with any random effects specified #102

Closed bk1n closed 1 month ago

bk1n commented 1 month ago

Running fixed effects with fitExtractVarPartModel() e.g. ~ c1 + c2 works fine but running ~ c1 + (1|c2) with categorical variables as random effects gives error:

Error in if (inherits(possibleError, "error") && grep("the fixed-effects model matrix is column rank deficient",  : 
  missing value where TRUE/FALSE needed

Traceback:

3: .fitExtractVarPartModel(exprObj, formula, data, REML = REML,
       useWeights = useWeights, weightsMatrix = weightsMatrix, showWarnings = showWarnings,
       control = control, quiet = quiet, BPPARAM = BPPARAM, ...)
2: fitExtractVarPartModel(t(rna), form, viab)
1: fitExtractVarPartModel(t(rna), form, viab)

Minimum reproducible example:

library(variancePartition)

expr <- replicate(50, sample(1:5, 50, replace = T))
info <- data.frame(tissue = sample(c("lung", "bone", "testicle"), 50, replace = T))

vp <- fitExtractVarPartModel(expr, ~ (1 | tissue), info)

sessionInfo: R version 4.2.3 (2023-03-15 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 22631)

Matrix products: default

locale: [1] LC_COLLATE=English_United Kingdom.utf8 [2] LC_CTYPE=English_United Kingdom.utf8 [3] LC_MONETARY=English_United Kingdom.utf8 [4] LC_NUMERIC=C [5] LC_TIME=English_United Kingdom.utf8

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

other attached packages: [1] rafalib_1.0.0 variancePartition_1.28.9 BiocParallel_1.32.6 [4] limma_3.54.2 openssl_2.1.2 digest_0.6.35 [7] lubridate_1.9.3 forcats_1.0.0 stringr_1.5.1 [10] dplyr_1.1.4 purrr_1.0.2 readr_2.1.5 [13] tidyr_1.3.1 tibble_3.2.1 ggplot2_3.5.1 [16] tidyverse_2.0.0

loaded via a namespace (and not attached): [1] Rcpp_1.0.12 mvtnorm_1.2-4 lattice_0.21-8 [4] prettyunits_1.2.0 gtools_3.9.5 RhpcBLASctl_0.23-42 [7] foreach_1.5.2 utf8_1.2.4 plyr_1.8.9 [10] R6_2.5.1 backports_1.4.1 pillar_1.9.0 [13] Rdpack_2.6.1 gplots_3.1.3.1 rlang_1.1.3 [16] progress_1.2.3 data.table_1.15.4 minqa_1.2.6 [19] nloptr_2.0.3 Matrix_1.6-1 EnvStats_2.8.1 [22] splines_4.2.3 lme4_1.1-35.3 remaCor_0.0.18 [25] munsell_0.5.1 broom_1.0.6 compiler_4.2.3 [28] pkgconfig_2.0.3 askpass_1.2.0 BiocGenerics_0.44.0 [31] tidyselect_1.2.1 codetools_0.2-19 fansi_1.0.6 [34] crayon_1.5.3 tzdb_0.4.0 withr_3.0.1 [37] MASS_7.3-60 bitops_1.0-7 rbibutils_2.2.16 [40] grid_4.2.3 nlme_3.1-163 jsonlite_1.8.8 [43] gtable_0.3.5 lifecycle_1.0.4 magrittr_2.0.3 [46] scales_1.3.0 KernSmooth_2.23-22 cli_3.6.2 [49] stringi_1.8.3 reshape2_1.4.4 doParallel_1.0.17 [52] generics_0.1.3 vctrs_0.6.5 boot_1.3-28.1 [55] aod_1.3.3 RColorBrewer_1.1-3 iterators_1.0.14 [58] tools_4.2.3 Biobase_2.58.0 glue_1.7.0 [61] hms_1.1.3 pbkrtest_0.5.3 parallel_4.2.3 [64] timechange_0.3.0 colorspace_2.1-0 BiocManager_1.30.24 [67] caTools_1.18.2

GabrielHoffman commented 1 month ago

variancePartition 1.28.9 is from March 14, 2023. Can you try a more recent version? I works for me with `v1.35.5.

bk1n commented 1 month ago

Yes sorry should have read other issues! #96