Last updated: 2021-02-27
Checks: 7 0
Knit directory: liver-disease-atlas/
This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks 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(20201218)
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 job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version 40203d5. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
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/human-diehl-nafld_cache/
Ignored: analysis/human-hampe13-nash_cache/
Ignored: analysis/human-hampe14-misc_cache/
Ignored: analysis/human-hoang-nafld_cache/
Ignored: analysis/human-ramnath-fibrosis_cache/
Ignored: analysis/meta-chronic-vs-acute_cache/
Ignored: analysis/meta-mouse-vs-human_cache/
Ignored: analysis/mouse-acute-apap_cache/
Ignored: analysis/mouse-acute-bdl_cache/
Ignored: analysis/mouse-acute-ccl4_cache/
Ignored: analysis/mouse-acute-lps_cache/
Ignored: analysis/mouse-acute-ph_cache/
Ignored: analysis/mouse-acute-tunicamycin_cache/
Ignored: analysis/mouse-chronic-ccl4_cache/
Ignored: analysis/plot-acute-apap_cache/
Ignored: analysis/plot-acute-ccl4_cache/
Ignored: analysis/plot-acute-ph_cache/
Ignored: analysis/plot-chronic-ccl4_cache/
Ignored: analysis/plot-chronic-vs-acute_cache/
Ignored: analysis/plot-mouse-vs-human_cache/
Ignored: analysis/plot-precision-recall_cache/
Ignored: analysis/plot-study-overview_cache/
Ignored: analysis/plot-teufel-integration_cache/
Ignored: analysis/save-tables_cache/
Ignored: code/.DS_Store
Ignored: code/README.html
Ignored: code/meta-mouse-vs-human/.DS_Store
Ignored: data.zip
Ignored: data/.DS_Store
Ignored: data/annotation/
Ignored: data/human-diehl-nafld/
Ignored: data/human-hampe13-nash/
Ignored: data/human-hampe14-misc/
Ignored: data/human-hoang-nafld/
Ignored: data/human-ramnath-fibrosis/
Ignored: data/meta-chronic-vs-acute/
Ignored: data/meta-mouse-vs-human/
Ignored: data/mouse-acute-apap/
Ignored: data/mouse-acute-bdl/
Ignored: data/mouse-acute-ccl4/
Ignored: data/mouse-acute-lps/
Ignored: data/mouse-acute-ph/
Ignored: data/mouse-acute-tunicamycin/
Ignored: data/mouse-chronic-ccl4/
Ignored: external_software/.DS_Store
Ignored: external_software/README.html
Ignored: external_software/stem/.DS_Store
Ignored: figures/
Ignored: geo_submission/
Ignored: output/.DS_Store
Ignored: output/README.html
Ignored: output/human-diehl-nafld/
Ignored: output/human-hampe13-nash/
Ignored: output/human-hampe14-misc/
Ignored: output/human-hoang-nafld/
Ignored: output/human-ramnath-fibrosis/
Ignored: output/meta-chronic-vs-acute/
Ignored: output/meta-mouse-vs-human/
Ignored: output/mouse-acute-apap/
Ignored: output/mouse-acute-bdl/
Ignored: output/mouse-acute-ccl4/
Ignored: output/mouse-acute-lps/
Ignored: output/mouse-acute-ph/
Ignored: output/mouse-acute-tunicamycin/
Ignored: output/mouse-chronic-ccl4/
Ignored: renv/library/
Ignored: renv/staging/
Ignored: tables/
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 repository in which changes were made to the R Markdown (analysis/plot-acute-bdl.Rmd
) and HTML (docs/plot-acute-bdl.html
) files. If you’ve configured a remote Git repository (see ?wflow_git_remote
), click on the hyperlinks in the table below to view the files as they were in that past version.
File | Version | Author | Date | Message |
---|---|---|---|---|
html | 9c62197 | christianholland | 2021-01-07 | Build site. |
html | ff46d59 | christianholland | 2020-12-29 | Build site. |
Rmd | 0ccea65 | christianholland | 2020-12-29 | minor changes |
html | 067c933 | christianholland | 2020-12-23 | Build site. |
Rmd | d4f78fa | christianholland | 2020-12-23 | wflow_publish("analysis/*.Rmd", delete_cache = T) |
html | a008b54 | christianholland | 2020-12-23 | Build site. |
Rmd | c36ddd9 | christianholland | 2020-12-23 | minor changes |
html | 6b6c16a | christianholland | 2020-12-23 | Build site. |
Rmd | 9cdd995 | christianholland | 2020-12-22 | Added plotting scripts for mouse models |
Here we generate publication ready plots of the analysis of the acute BDL mouse model.
These libraries and sources are used for this analysis.
library(tidyverse)
library(tidylog)
library(here)
library(AachenColorPalette)
library(cowplot)
library(lemon)
library(ggpubr)
library(patchwork)
source(here("code/utils-plots.R"))
Definition of global variables that are used throughout this analysis.
# i/o
data_path <- "data/mouse-acute-bdl"
output_path <- "output/mouse-acute-bdl"
# graphical parameters
# fontsize
fz <- 7
# keys to annotate contrasts
key_mm <- readRDS(here("data/meta-chronic-vs-acute/contrast_annotation.rds"))
design <- ggdraw() +
draw_image(here(data_path, "exp-design.pdf"))
histology <- ggdraw() +
draw_image(here(data_path, "histology.png"))
df <- read_csv2(here(data_path, "liver_enzymes.csv")) %>%
mutate(time = fct_inorder(time)) %>%
pivot_longer(col = -c(time), names_to = "enzyme", values_to = "y") %>%
mutate(enzyme = factor(str_to_upper(enzyme), levels = c("ALT", "AST", "ALP")))
df_summary <- df %>%
group_by(time, enzyme) %>%
summarise(mean_se(y)) %>%
ungroup()
liver_enzymes <- df_summary %>%
ggplot(aes(x = time, y = y)) +
geom_errorbar(aes(ymin = ymin, ymax = ymax), width = 0.5) +
geom_col() +
facet_rep_wrap(~enzyme, scales = "free", ncol = 1) +
labs(x = NULL, y = "U/L") +
my_theme(grid = "y", fsize = fz) +
stat_compare_means(
data = df, label = "p.signif",
ref.group = "Control", hide.ns = T
) +
theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5))
liver_enzymes
Version | Author | Date |
---|---|---|
6b6c16a | christianholland | 2020-12-23 |
pca_result <- readRDS(here(output_path, "pca_result.rds"))
keys <- key_mm %>%
filter(treatment == "Bile Duct Ligation" & class == "Acute") %>%
distinct(time = value, label = time_label2) %>%
drop_na() %>%
mutate(time = ordered(time))
pca_plot <- pca_result$coords %>%
inner_join(keys, by = "time") %>%
mutate(treatment = case_when(
treatment == "bdl" ~ "BDL",
treatment == "sham" ~ "Sham Surgery"
)) %>%
ggplot(aes(x = PC1, y = PC2, color = label, shape = treatment, label = label)) +
geom_point() +
labs(
x = paste0("PC1", " (", pca_result$var[1], "%)"),
y = paste0("PC2", " (", pca_result$var[2], "%)"),
color = "Time", shape = "Group"
) +
my_theme(fsize = fz) +
theme(
legend.position = "top",
legend.box.margin = margin(10, 0, -20, 10)
) +
scale_color_manual(values = aachen_color(c(
"blue", "bordeaux", "orange",
"green"
))) +
scale_shape_manual(values = c(19, 15))
pca_plot
df <- readRDS(here(output_path, "limma_result.rds")) %>%
filter(contrast_reference == "bdl") %>%
inner_join(key_mm, by = "contrast") %>%
select(-contrast) %>%
rename(contrast = time_label2) %>%
mutate(contrast = fct_drop(contrast)) %>%
mutate(regulation = fct_recode(regulation,
Up = "up", Down = "down",
n.s. = "ns"
))
deg_count <- df %>%
add_count(contrast, regulation) %>%
filter(regulation != "n.s.") %>%
mutate(regulation = fct_drop(regulation)) %>%
mutate(
logFC = case_when(
regulation == "Up" ~ 0.75 * max(logFC),
regulation == "Down" ~ 0.75 * min(logFC)
),
pval = 0.4
) %>%
distinct(n, contrast, logFC, pval, regulation, value) %>%
complete(contrast, nesting(regulation, logFC, pval), fill = list(n = 0))
main_time <- c(1, 3, 7)
# for main panel
volcano_main <- df %>%
filter(value %in% main_time) %>%
plot_volcano(nrow = 1) +
geom_text(
data = filter(deg_count, value %in% main_time),
aes(y = pval, label = n), size = fz / (14 / 5),
hjust = "inward", vjust = "inward",
show.legend = F
) +
theme(
legend.position = "top",
legend.box.margin = margin(-10, 0, -10, 0)
) +
labs(color = "Regulation") +
my_theme(grid = "y", fsize = fz)
# for supp panel
volcano_supp <- df %>%
filter(!value %in% main_time) %>%
plot_volcano(ncol = 1) +
geom_text(
data = filter(deg_count, !value %in% main_time),
aes(y = pval, label = n), size = fz / (14 / 5),
show.legend = F
) +
theme(
legend.position = "top",
legend.box.margin = margin(-10, 0, -10, 0)
) +
labs(color = "Regulation") +
my_theme(grid = "y", fsize = fz)
volcano_main
Version | Author | Date |
---|---|---|
6b6c16a | christianholland | 2020-12-23 |
volcano_supp
Version | Author | Date |
---|---|---|
6b6c16a | christianholland | 2020-12-23 |
df <- readRDS(here(output_path, "limma_result.rds")) %>%
filter(contrast_reference == "bdl") %>%
inner_join(key_mm) %>%
select(-class) %>%
rename(class = time_label2)
top_genes_df <- df %>%
filter(regulation != "ns") %>%
group_by(class, sign(logFC)) %>%
slice_max(order_by = abs(logFC), n = 10, with_ties = F) %>%
ungroup() %>%
nest(data = -c(class, value))
plots <- top_genes_df %>%
mutate(p = pmap(., .f = plot_top_genes, fontsize = fz))
main_time <- c(1, 3, 7)
# for main panel
top_genes_main <- plots %>%
filter(value %in% main_time) %>%
pull(p) %>%
wrap_plots() +
plot_layout(nrow = 1)
# for supp panel
top_genes_supp <- plots %>%
filter(!value %in% main_time) %>%
pull(p) %>%
wrap_plots() +
plot_layout(ncol = 1)
top_genes_main
Version | Author | Date |
---|---|---|
6b6c16a | christianholland | 2020-12-23 |
top_genes_supp
Version | Author | Date |
---|---|---|
6b6c16a | christianholland | 2020-12-23 |
stem_res <- readRDS(here(output_path, "stem_result.rds")) %>%
filter(key == "bdl") %>%
filter(p <= 0.05) %>%
mutate(profile = fct_reorder(str_c(
"STEM ID: ",
as.character(profile)
), p))
# extract meta data of profiles
profile_anno <- stem_res %>%
group_by(key, profile, p) %>%
mutate(y = 1.2 * abs(max(value))) %>%
ungroup() %>%
mutate(max_time = max(time)) %>%
distinct(key, profile, p, size, y, max_time) %>%
mutate(label = str_c(size, " ", "genes"))
ts_cluster <- stem_res %>%
plot_stem_profiles(model_profile = F, nrow = 1) +
labs(x = "Time in Days") +
geom_text(
data = profile_anno, aes(x = 0, y = y, label = label),
inherit.aes = F, size = fz / (14 / 5), hjust = "inward"
) +
my_theme(grid = "no", fsize = fz) +
scale_x_continuous(
breaks = unique(stem_res$time),
guide = guide_axis(n.dodge = 1)
)
ts_cluster
sfig2_6 <- (design + histology) /
((liver_enzymes | pca_plot) + plot_layout(widths = c(1, 3))) /
((volcano_main / top_genes_main)) /
ts_cluster +
plot_layout(height = c(1.5, 2, 1.75, 0.75)) +
plot_annotation(tag_levels = list(c(
"A", "B", "C", "D", "E", "F", "", "", "",
"", "", "G"
))) &
theme(
plot.tag = element_text(size = fz + 3, face = "bold"),
legend.key.height = unit(11.5, "pt"),
legend.key.width = unit(12.5, "pt")
)
sfig2_6
ggsave(here("figures/Supplementary Figure 2.6.pdf"), sfig2_6,
width = 21, height = 29.7, units = c("cm")
)
ggsave(here("figures/Supplementary Figure 2.6.png"), sfig2_6,
width = 21, height = 29.7, units = c("cm")
)
sfig2_7 <- (volcano_supp | top_genes_supp) +
plot_annotation(tag_levels = list(c("A", "B"))) &
theme(
plot.tag = element_text(size = fz + 3, face = "bold"),
legend.key.height = unit(11.5, "pt"),
legend.key.width = unit(12.5, "pt")
)
sfig2_7
Version | Author | Date |
---|---|---|
6b6c16a | christianholland | 2020-12-23 |
ggsave(here("figures/Supplementary Figure 2.7.pdf"), sfig2_7,
width = 21, height = 10, units = c("cm")
)
ggsave(here("figures/Supplementary Figure 2.7.png"), sfig2_7,
width = 21, height = 10, units = c("cm")
)
Time spend to execute this analysis: 01:01 minutes.
sessionInfo()
#> R version 4.0.2 (2020-06-22)
#> Platform: x86_64-apple-darwin17.0 (64-bit)
#> Running under: macOS Mojave 10.14.5
#>
#> Matrix products: default
#> BLAS: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.0/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 datasets utils methods base
#>
#> other attached packages:
#> [1] patchwork_1.1.1 ggpubr_0.4.0 lemon_0.4.5
#> [4] cowplot_1.1.0 AachenColorPalette_1.1.2 here_1.0.1
#> [7] tidylog_1.0.2 forcats_0.5.0 stringr_1.4.0
#> [10] dplyr_1.0.2 purrr_0.3.4 readr_1.4.0
#> [13] tidyr_1.1.2 tibble_3.0.4 ggplot2_3.3.2
#> [16] tidyverse_1.3.0 workflowr_1.6.2
#>
#> loaded via a namespace (and not attached):
#> [1] fs_1.5.0 lubridate_1.7.9.2 httr_1.4.2 rprojroot_2.0.2
#> [5] tools_4.0.2 backports_1.2.1 R6_2.5.0 DBI_1.1.0
#> [9] colorspace_2.0-0 withr_2.3.0 tidyselect_1.1.0 gridExtra_2.3
#> [13] curl_4.3 compiler_4.0.2 git2r_0.27.1 cli_2.2.0
#> [17] rvest_0.3.6 xml2_1.3.2 labeling_0.4.2 scales_1.1.1
#> [21] digest_0.6.27 foreign_0.8-80 rmarkdown_2.6 rio_0.5.16
#> [25] pkgconfig_2.0.3 htmltools_0.5.0 dbplyr_2.0.0 rlang_0.4.9
#> [29] readxl_1.3.1 rstudioapi_0.13 generics_0.1.0 farver_2.0.3
#> [33] jsonlite_1.7.2 gtools_3.8.2 zip_2.1.1 car_3.0-10
#> [37] magrittr_2.0.1 Rcpp_1.0.5 munsell_0.5.0 fansi_0.4.1
#> [41] abind_1.4-5 lifecycle_0.2.0 stringi_1.5.3 whisker_0.4
#> [45] yaml_2.2.1 carData_3.0-4 plyr_1.8.6 grid_4.0.2
#> [49] promises_1.1.1 crayon_1.3.4 lattice_0.20-41 haven_2.3.1
#> [53] hms_0.5.3 magick_2.5.2 knitr_1.30 pillar_1.4.7
#> [57] ggsignif_0.6.0 codetools_0.2-16 clisymbols_1.2.0 reprex_0.3.0
#> [61] glue_1.4.2 evaluate_0.14 data.table_1.13.4 renv_0.12.3
#> [65] modelr_0.1.8 vctrs_0.3.6 httpuv_1.5.4 cellranger_1.1.0
#> [69] gtable_0.3.0 assertthat_0.2.1 xfun_0.19 openxlsx_4.2.3
#> [73] broom_0.7.3 rstatix_0.6.0 later_1.1.0.1 ellipsis_0.3.1