Last updated: 2019-08-29
Checks: 6 0
Knit directory: FLASHvestigations/
This reproducible R Markdown analysis was created with workflowr (version 1.2.0). The Report tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20180714)
was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility. The version displayed above was the version of the Git repository at the time these results were generated.
Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish
or wflow_git_commit
). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:
Ignored files:
Ignored: .DS_Store
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: analysis/.DS_Store
Ignored: code/.DS_Store
Ignored: code/flashier_bench/.DS_Store
Ignored: data/flashier_bench/
Ignored: data/metabo3_gwas_mats.RDS
Ignored: output/jean/
Untracked files:
Untracked: code/extrapolate/extrapolate_gtex_ash30.R
Untracked: code/fasfunction.R
Untracked: code/nnmf.R
Untracked: output/extrapolate/trachea_gtex.rds
Unstaged changes:
Modified: code/extrapolate/extrapolate_util.R
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
These are the previous versions of the R Markdown and HTML files. If you’ve configured a remote Git repository (see ?wflow_git_remote
), click on the hyperlinks in the table below to view them.
File | Version | Author | Date | Message |
---|---|---|---|---|
Rmd | 00bcd24 | Jason Willwerscheid | 2019-08-29 | wflow_publish(“analysis/jean.Rmd”) |
I run flashier
on a GWAS dataset collated by Jean Morrison using eight different variance structures and three different initialization methods.
The most general EBMF model is: \[ Y = LF' + S + E \] where \(Y \in \mathbb{R}^{n \times p}\), \(S_{ij} \sim N(0, \sigma_{ij}^2)\) and \(E_{ij} \sim N(0, 1 / \tau_{ij})\), with the \(\sigma_{ij}^2\)s known and the \(\tau_{ij}\)s to be estimated (I ignore the priors on \(L\) and \(F\) here). One can either include \(S\) or not; and one can make different assumptions about how \(\tau\) is structured. I test eight variance structures:
softImpute
to initialize factors. This gives different results when there is missing data.softImpute
and then refines the fit via backfitting.The code used to produce the fits can be viewed here.
For each fit, I give the ELBO relative to the best overall ELBO attained and (in parentheses) the number of factors added.
res <- readRDS("./output/jean/flashier_res.rds")
calls <- lapply(res, `[[`, "call")
var.type <- sapply(calls, function(call) {
if (is.null(call$S)) {
return(switch(paste(as.character(call$var.type), collapse = " "),
"0" = "constant",
"1" = "by.row",
"2" = "by.col",
"1 2" = "kronecker"))
} else {
return(switch(paste(as.character(call$var.type), collapse = " "),
"0" = "noisy.const",
"1" = "noisy.byrow",
"2" = "noisy.bycol",
"1 2" = "noisy.kronecker",
"zero"))
}
})
init.type <- sapply(calls, function(call) {
if (!is.null(call$init.fn))
return("soft.impute")
else if (!is.null(call$EF.init))
return("init.from.data")
else
return("flashier")
})
best.elbo <- max(sapply(res, `[[`, "elbo"))
display.str <- sapply(res, function(fl) {
return(paste0(formatC(fl$elbo - best.elbo, format = "f", digits = 0), " (",
sum(fl$pve > 0), ")"))
})
df <- data.frame(var.type = factor(var.type,
levels = c("constant", "by.row", "by.col",
"kronecker", "zero", "noisy.const",
"noisy.byrow", "noisy.bycol")),
init.type = factor(init.type,
levels = c("flashier", "soft.impute",
"init.from.data")),
display.str = display.str)
knitr::kable(df %>% spread(init.type, display.str))
var.type | flashier | soft.impute | init.from.data |
---|---|---|---|
constant | -27051 (16) | -22920 (19) | -14414 (30) |
by.row | -22229 (10) | -22213 (10) | -9554 (30) |
by.col | -15193 (8) | -11005 (13) | -7850 (30) |
kronecker | -4552 (6) | -5571 (5) | 0 (21) |
zero | -18019 (10) | -11237 (14) | -9671 (25) |
noisy.const | -17235 (9) | -15081 (9) | -9313 (25) |
noisy.byrow | -15061 (6) | -14175 (6) | -7410 (20) |
noisy.bycol | -14734 (6) | -16280 (6) | -9664 (24) |
Some observations:
softImpute
typically does “better” (judging by the ELBO) than the default method.
sessionInfo()
#> R version 3.5.3 (2019-03-11)
#> Platform: x86_64-apple-darwin15.6.0 (64-bit)
#> Running under: macOS Mojave 10.14.6
#>
#> Matrix products: default
#> BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/3.5/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] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] mixsqp_0.1-119 ashr_2.2-38 ebnm_0.1-24 flashier_0.1.15
#> [5] tidyr_0.8.3
#>
#> loaded via a namespace (and not attached):
#> [1] Rcpp_1.0.1 highr_0.8 pillar_1.3.1
#> [4] compiler_3.5.3 git2r_0.25.2 workflowr_1.2.0
#> [7] iterators_1.0.10 tools_3.5.3 digest_0.6.18
#> [10] evaluate_0.13 tibble_2.1.1 lattice_0.20-38
#> [13] pkgconfig_2.0.2 rlang_0.3.1 Matrix_1.2-15
#> [16] foreach_1.4.4 yaml_2.2.0 parallel_3.5.3
#> [19] xfun_0.6 stringr_1.4.0 knitr_1.22
#> [22] fs_1.2.7 tidyselect_0.2.5 rprojroot_1.3-2
#> [25] grid_3.5.3 glue_1.3.1 rmarkdown_1.12
#> [28] purrr_0.3.2 magrittr_1.5 whisker_0.3-2
#> [31] backports_1.1.3 codetools_0.2-16 htmltools_0.3.6
#> [34] MASS_7.3-51.1 stringi_1.4.3 doParallel_1.0.14
#> [37] pscl_1.5.2 truncnorm_1.0-8 SQUAREM_2017.10-1
#> [40] crayon_1.3.4