devtools::load_all() library(stringr) library(ggplot2) suppressPackageStartupMessages(library(cowplot)) library(knitr) theme_set(theme_classic()) knitr::opts_chunk$set(collapse=TRUE, comment="#>", fig.show='hold', message=FALSE, warning=FALSE, cache=FALSE) set.seed(123)
PROJECT_DIR <- Sys.getenv('PROJECT_DIR') btlnck_fps <- list.files(file.path(PROJECT_DIR, 'data', 'dl', 'pretrained'),pattern = "Btlncks.csv", full.names = TRUE) %>% purrr::set_names(., stem(.)) btlnck_df <- map(btlnck_fps, readr::read_csv, n_max=1000) btlnck_df[[1]]["img_id"] btlnck_df[[2]]["X1"] #! TODO: fix ids
library(AnalysisToolkit) # # Cumulative variance explained # by_model_plotter %>% # unnest(cve) %>% # {ggplot(., aes(x=x, y=y, col=model))} + gg_cve_style # # Scatter # by_model_plotter %>% # unnest(scat) %>% # {ggplot(., aes(x=x, y=y)) + geom_point(alpha=0.2) + # facet_grid(.~model)} + gg_scat_style # by_model_plotter %>% # unnest(scat) %>% # mutate(dataset=revalue(ids, id2dat), # dataset=pretty_dataset(dataset)) %>% # {ggplot(., aes(x=x, y=y, col=dataset)) + geom_point(alpha=0.2) + # facet_grid(.~model)} + gg_scat_style + color_dataset data(scalars_df, package="ProjUtils") ###### # Independent Datasets by_dataset_model <- pilot_df %>% nest(-dataset, -model) # Compute plotting list-cols by_dataset_model_plotter <- by_dataset_model %>% mutate(pcs = map(data, compute_pcs), cve = map(pcs, gg_cve), scat = map(pcs, gg_scatter), model = pretty_model(model), dataset= pretty_dataset(dataset)) # Integrated by_model_plotter$dataset <- "Pooled" integrated_plotter <- by_dataset_model_plotter %>% bind_rows(by_model_plotter) %>% mutate(dataset = factor(dataset, levels=c("CXR", "Hips", "Pooled"))) # Cumulative variance explained gg1 <- integrated_plotter %>% unnest(cve) %>% { ggplot(., aes(x=x, y=y, col=model)) + facet_grid(dataset~.) + theme(panel.spacing = unit(1, "lines"), legend.position="right") + gg_cve_style } gg2 <- integrated_plotter %>% unnest(scat) %>% mutate(COLOR = revalue(ids, id2dat)) %>% { ggplot(., aes(x=x, y=y, col=COLOR)) + geom_point(alpha=kALPHA) + facet_grid(dataset~model) + theme(legend.position = "bottom") } + gg_scat_style + color_dataset grid.arrange(gg2, gg1, ncol=2) g <- arrangeGrob(gg2, gg1, ncol=2) ggsave(filename = kOUT_FIG_PTH, g, width = 9, height=4, dpi=300) beepr::beep(11)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.