library(tidyverse)
## ── Attaching packages ────────────────────────────────────────────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 3.1.0 ✔ purrr 0.3.2
## ✔ tibble 2.1.1 ✔ dplyr 0.8.0.1
## ✔ tidyr 0.8.3 ✔ stringr 1.4.0
## ✔ readr 1.3.1 ✔ forcats 0.3.0
## ── Conflicts ───────────────────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(magrittr)
##
## Attaching package: 'magrittr'
## The following object is masked from 'package:purrr':
##
## set_names
## The following object is masked from 'package:tidyr':
##
## extract
library(wesanderson)
source("../util_defs.R")
Set input/output paths.
datadir <- "data"
outdir <- "2018-10-22"
knitr::opts_chunk$set(fig.path = "figs/", dev = c('png',"pdf"))
Load grid parameters
load(file.path(datadir, "grid.RData"))
# number of settings
nrow(grid)
## [1] 40
head(grid)
## n p g pi_low rho tau
## 1 100 300 6 0.2 0 1
## 2 300 300 6 0.2 0 1
## 3 500 300 6 0.2 0 1
## 4 700 300 6 0.2 0 1
## 5 900 300 6 0.2 0 1
## 6 1100 300 6 0.2 0 1
files <- list.files(outdir)
files <- files[grepl(".RData", files)]
res_all <- lapply(files, function(fnm){
# load fits
load(file.path(outdir,fnm))
# add parameter info
params <- strsplit(fnm,"_")[[1]]
res$n <- as.numeric(sub("n","",params[1]))
res$p <- as.numeric(sub("p","",params[2]))
res$g <- as.numeric(sub(".RData","",(sub("g","",params[3]))))
res
}) %>% bind_rows()
# base parameters
getBaseParam <- function(param){
as.numeric(names(table(grid[[param]]))[which.max(table(grid[[param]]))])
}
n_base <- getBaseParam("n")
p_base <- getBaseParam("p")
g_base <- getBaseParam("g")
methods_time <- c("graper_SS", "Lasso", "IPFLasso", "SparseGroupLasso",
"varbvs", "graper_FF", "graper", "GRridge")
df_time <- res_all %>%
mutate(method = sub("grpRR", "graper", method)) %>% # replace old name
filter(method %in% methods_time) %>%
mutate(method = make_nicenames(method))
df_time %<>% mutate(vary_param = ifelse(n==n_base, ifelse(p == p_base, "G","p"), "n"))
df_time %<>% mutate(value = ifelse(vary_param == "n", n, ifelse(vary_param=="p", p, g)))
df_time %<>% mutate(vary_param = factor(vary_param, levels = c("p", "n", "G")))
df_time %>%
ggplot(aes(x=value, y=runtime/60, col=method)) +
stat_summary(fun.data = mean_se, geom="errorbar", width=0) +
# geom_smooth(method="loess",method.args = list(degree=0, span=10), se=FALSE) +
stat_summary(fun.y = mean, geom = "line") +
facet_wrap(~vary_param, scales = "free_x",strip.position = "bottom") +
ylab("time [min]")+ scale_y_log10()+
theme_bw(base_size = 15) + scale_color_manual(values = cols4methods) +
xlab("") +
theme(strip.background = element_blank(), strip.placement = "outside") +
scale_x_continuous(breaks=scales::pretty_breaks(3))
sessionInfo()
## R version 3.5.3 (2019-03-11)
## Platform: x86_64-apple-darwin15.6.0 (64-bit)
## Running under: macOS Mojave 10.14.4
##
## 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_IE.UTF-8/en_IE.UTF-8/en_IE.UTF-8/C/en_IE.UTF-8/en_IE.UTF-8
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] RColorBrewer_1.1-2 wesanderson_0.3.6 magrittr_1.5
## [4] forcats_0.3.0 stringr_1.4.0 dplyr_0.8.0.1
## [7] purrr_0.3.2 readr_1.3.1 tidyr_0.8.3
## [10] tibble_2.1.1 ggplot2_3.1.0 tidyverse_1.2.1
## [13] BiocStyle_2.10.0
##
## loaded via a namespace (and not attached):
## [1] tidyselect_0.2.5 xfun_0.4 haven_2.0.0
## [4] lattice_0.20-38 colorspace_1.4-1 generics_0.0.2
## [7] htmltools_0.3.6 yaml_2.2.0 rlang_0.3.2
## [10] pillar_1.3.1 glue_1.3.1 withr_2.1.2
## [13] modelr_0.1.2 readxl_1.2.0 plyr_1.8.4
## [16] munsell_0.5.0 gtable_0.2.0 cellranger_1.1.0
## [19] rvest_0.3.2 evaluate_0.12 knitr_1.21
## [22] broom_0.5.1 Rcpp_1.0.1 scales_1.0.0
## [25] backports_1.1.3 BiocManager_1.30.4 jsonlite_1.6
## [28] hms_0.4.2 digest_0.6.18 stringi_1.4.3
## [31] bookdown_0.9 grid_3.5.3 cli_1.1.0
## [34] tools_3.5.3 lazyeval_0.2.2 crayon_1.3.4
## [37] pkgconfig_2.0.2 xml2_1.2.0 lubridate_1.7.4
## [40] assertthat_0.2.1 rmarkdown_1.11 httr_1.4.0
## [43] rstudioapi_0.9.0 R6_2.4.0 nlme_3.1-137
## [46] compiler_3.5.3