Last updated: 2021-03-29

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 486340c. 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/01-mouse-chronic-ccl4_cache/
    Ignored:    analysis/02-mouse-acute-apap_cache/
    Ignored:    analysis/03-mouse-acute-ccl4_cache/
    Ignored:    analysis/04-mouse-acute-ph_cache/
    Ignored:    analysis/05-mouse-acute-bdl_cache/
    Ignored:    analysis/06-mouse-acute-lps_cache/
    Ignored:    analysis/07-mouse-acute-tunicamycin_cache/
    Ignored:    analysis/08-human-diehl-nafld_cache/
    Ignored:    analysis/09-human-hampe13-nash_cache/
    Ignored:    analysis/10-human-hampe14-misc_cache/
    Ignored:    analysis/11-human-hoang-nafld_cache/
    Ignored:    analysis/12-human-ramnath-fibrosis_cache/
    Ignored:    analysis/13-meta-chronic-vs-acute_cache/
    Ignored:    analysis/14-meta-mouse-vs-human_cache/
    Ignored:    analysis/15-plot-chronic-ccl4_cache/
    Ignored:    analysis/16-plot-acute-apap_cache/
    Ignored:    analysis/18-plot-acute-ph_cache/
    Ignored:    analysis/19-plot-acute-bdl_cache/
    Ignored:    analysis/20-plot-study-overview_cache/
    Ignored:    analysis/21-plot-chronic-vs-acute_cache/
    Ignored:    analysis/22-plot-mouse-vs-human_cache/
    Ignored:    analysis/23-plot-precision-recall_cache/
    Ignored:    analysis/24-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/Icon
    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/.DS_Store
    Ignored:    figures/Figure 1 (partial).pdf
    Ignored:    figures/Figure 1.pdf
    Ignored:    figures/Figure 1.png
    Ignored:    figures/Figure 2 (partial).pdf
    Ignored:    figures/Figure 2.pdf
    Ignored:    figures/Figure 2.png
    Ignored:    figures/Figure 3.pdf
    Ignored:    figures/Figure 3.png
    Ignored:    figures/Figure 4.pdf
    Ignored:    figures/Figure 4.png
    Ignored:    figures/Figure 5.pdf
    Ignored:    figures/Figure 6.png
    Ignored:    figures/Icon
    Ignored:    figures/Supplementary Figure 0.1.pdf
    Ignored:    figures/Supplementary Figure 0.1.png
    Ignored:    figures/Supplementary Figure 1.1.pdf
    Ignored:    figures/Supplementary Figure 1.1.png
    Ignored:    figures/Supplementary Figure 2.1.pdf
    Ignored:    figures/Supplementary Figure 2.1.png
    Ignored:    figures/Supplementary Figure 2.2.pdf
    Ignored:    figures/Supplementary Figure 2.2.png
    Ignored:    figures/Supplementary Figure 2.3.pdf
    Ignored:    figures/Supplementary Figure 2.3.png
    Ignored:    figures/Supplementary Figure 2.4.pdf
    Ignored:    figures/Supplementary Figure 2.4.png
    Ignored:    figures/Supplementary Figure 2.5.pdf
    Ignored:    figures/Supplementary Figure 2.5.png
    Ignored:    figures/Supplementary Figure 2.6.pdf
    Ignored:    figures/Supplementary Figure 2.6.png
    Ignored:    figures/Supplementary Figure 2.7.pdf
    Ignored:    figures/Supplementary Figure 2.7.png
    Ignored:    figures/Supplementary Figure 3.1.pdf
    Ignored:    figures/Supplementary Figure 3.1.png
    Ignored:    figures/Supplementary Figure 3.2.pdf
    Ignored:    figures/Supplementary Figure 3.2.png
    Ignored:    figures/Supplementary Figure 3.3.pdf
    Ignored:    figures/Supplementary Figure 3.3.png
    Ignored:    figures/Supplementary Figure 3.4.pdf
    Ignored:    figures/Supplementary Figure 3.4.png
    Ignored:    figures/Supplementary Figure 4.1.pdf
    Ignored:    figures/Supplementary Figure 4.1.png
    Ignored:    figures/Supplementary Figure 4.2.pdf
    Ignored:    figures/Supplementary Figure 4.2.png
    Ignored:    figures/Supplementary Figure 5.1.pdf
    Ignored:    figures/Supplementary Figure 5.1.png
    Ignored:    figures/figures.key
    Ignored:    figures/histologies.key
    Ignored:    figures/panels/
    Ignored:    figures/tmp/.DS_Store
    Ignored:    figures/tmp/Fig5A1.pdf
    Ignored:    figures/tmp/Fig5A2.pdf
    Ignored:    figures/tmp/Icon
    Ignored:    geo_submission/
    Ignored:    output/.DS_Store
    Ignored:    output/Icon
    Ignored:    output/README.html
    Ignored:    output/human-diehl-nafld/Icon
    Ignored:    output/human-diehl-nafld/limma_result.rds
    Ignored:    output/human-diehl-nafld/meta_data.rds
    Ignored:    output/human-diehl-nafld/normalized_expression.rds
    Ignored:    output/human-diehl-nafld/pca_result.rds
    Ignored:    output/human-diehl-nafld/z_scores.rds
    Ignored:    output/human-hampe13-nash/Icon
    Ignored:    output/human-hampe13-nash/limma_result.rds
    Ignored:    output/human-hampe13-nash/meta_data.rds
    Ignored:    output/human-hampe13-nash/normalized_expression.rds
    Ignored:    output/human-hampe13-nash/pca_result.rds
    Ignored:    output/human-hampe13-nash/z_scores.rds
    Ignored:    output/human-hampe14-misc/Icon
    Ignored:    output/human-hampe14-misc/limma_result.rds
    Ignored:    output/human-hampe14-misc/meta_data.rds
    Ignored:    output/human-hampe14-misc/normalized_expression.rds
    Ignored:    output/human-hampe14-misc/pca_result.rds
    Ignored:    output/human-hampe14-misc/z_scores.rds
    Ignored:    output/human-hoang-nafld/Icon
    Ignored:    output/human-hoang-nafld/limma_result.rds
    Ignored:    output/human-hoang-nafld/normalized_expression.rds
    Ignored:    output/human-hoang-nafld/pca_result.rds
    Ignored:    output/human-hoang-nafld/z_scores.rds
    Ignored:    output/human-ramnath-fibrosis/Icon
    Ignored:    output/human-ramnath-fibrosis/limma_result.rds
    Ignored:    output/human-ramnath-fibrosis/normalized_expression.rds
    Ignored:    output/human-ramnath-fibrosis/pca_result.rds
    Ignored:    output/human-ramnath-fibrosis/z_scores.rds
    Ignored:    output/meta-chronic-vs-acute/Icon
    Ignored:    output/meta-chronic-vs-acute/acute_gene_pool.rds
    Ignored:    output/meta-chronic-vs-acute/chronic_gene_pool.rds
    Ignored:    output/meta-chronic-vs-acute/exclusive_genes_characterization.rds
    Ignored:    output/meta-chronic-vs-acute/gene_membership.rds
    Ignored:    output/meta-chronic-vs-acute/gene_set_similarity.rds
    Ignored:    output/meta-chronic-vs-acute/go_cluster_ranking.rds
    Ignored:    output/meta-chronic-vs-acute/go_wordcounts.rds
    Ignored:    output/meta-chronic-vs-acute/interstudy_enrichment.rds
    Ignored:    output/meta-chronic-vs-acute/limma_result.rds
    Ignored:    output/meta-chronic-vs-acute/meta_data.rds
    Ignored:    output/meta-chronic-vs-acute/pca_dist.rds
    Ignored:    output/meta-chronic-vs-acute/ranked_common_genes.rds
    Ignored:    output/meta-chronic-vs-acute/ranked_exclusive_acute_genes.rds
    Ignored:    output/meta-chronic-vs-acute/ranked_exclusive_chronic_genes.rds
    Ignored:    output/meta-chronic-vs-acute/union_acute_geneset.rds
    Ignored:    output/meta-chronic-vs-acute/union_chronic_geneset.rds
    Ignored:    output/meta-chronic-vs-acute/z_score_pca.rds
    Ignored:    output/meta-mouse-vs-human/Icon
    Ignored:    output/meta-mouse-vs-human/chronic_mouse_deg_numbers.rds
    Ignored:    output/meta-mouse-vs-human/consistent_genes.rds
    Ignored:    output/meta-mouse-vs-human/cross_species_enrichment.rds
    Ignored:    output/meta-mouse-vs-human/cross_species_similarity.rds
    Ignored:    output/meta-mouse-vs-human/etiology_gene_sets.rds
    Ignored:    output/meta-mouse-vs-human/gene_set_similarity.rds
    Ignored:    output/meta-mouse-vs-human/go_cluster_ranking.rds
    Ignored:    output/meta-mouse-vs-human/go_wordcounts.rds
    Ignored:    output/meta-mouse-vs-human/gsea_res.rds
    Ignored:    output/meta-mouse-vs-human/individual_le.rds
    Ignored:    output/meta-mouse-vs-human/interstudy_enrichment.rds
    Ignored:    output/meta-mouse-vs-human/leading_edges.rds
    Ignored:    output/meta-mouse-vs-human/leading_edges_characterization.rds
    Ignored:    output/meta-mouse-vs-human/leading_edges_mgi.rds
    Ignored:    output/meta-mouse-vs-human/limma_result.rds
    Ignored:    output/meta-mouse-vs-human/meta_data.rds
    Ignored:    output/meta-mouse-vs-human/precision_recall.rds
    Ignored:    output/meta-mouse-vs-human/precision_recall_chronicity.rds
    Ignored:    output/meta-mouse-vs-human/teufel_genes.rds
    Ignored:    output/meta-mouse-vs-human/teufel_genes_hs.rds
    Ignored:    output/meta-mouse-vs-human/z_score_pca.rds
    Ignored:    output/mouse-acute-apap/.DS_Store
    Ignored:    output/mouse-acute-apap/Icon
    Ignored:    output/mouse-acute-apap/limma_result.rds
    Ignored:    output/mouse-acute-apap/meta_data.rds
    Ignored:    output/mouse-acute-apap/normalized_expression.rds
    Ignored:    output/mouse-acute-apap/pca_result.rds
    Ignored:    output/mouse-acute-apap/stem/.DS_Store
    Ignored:    output/mouse-acute-apap/stem/Icon
    Ignored:    output/mouse-acute-apap/stem/input/Icon
    Ignored:    output/mouse-acute-apap/stem/input/apap.txt
    Ignored:    output/mouse-acute-apap/stem_characterization.rds
    Ignored:    output/mouse-acute-apap/stem_result.rds
    Ignored:    output/mouse-acute-apap/z_scores.rds
    Ignored:    output/mouse-acute-bdl/.DS_Store
    Ignored:    output/mouse-acute-bdl/Icon
    Ignored:    output/mouse-acute-bdl/limma_result.rds
    Ignored:    output/mouse-acute-bdl/meta_data.rds
    Ignored:    output/mouse-acute-bdl/normalized_expression.rds
    Ignored:    output/mouse-acute-bdl/pca_result.rds
    Ignored:    output/mouse-acute-bdl/stem/.DS_Store
    Ignored:    output/mouse-acute-bdl/stem/Icon
    Ignored:    output/mouse-acute-bdl/stem/input/Icon
    Ignored:    output/mouse-acute-bdl/stem/input/bdl.txt
    Ignored:    output/mouse-acute-bdl/stem_characterization.rds
    Ignored:    output/mouse-acute-bdl/stem_result.rds
    Ignored:    output/mouse-acute-bdl/z_scores.rds
    Ignored:    output/mouse-acute-ccl4/.DS_Store
    Ignored:    output/mouse-acute-ccl4/Icon
    Ignored:    output/mouse-acute-ccl4/limma_result.rds
    Ignored:    output/mouse-acute-ccl4/meta_data.rds
    Ignored:    output/mouse-acute-ccl4/normalized_expression.rds
    Ignored:    output/mouse-acute-ccl4/pca_result.rds
    Ignored:    output/mouse-acute-ccl4/stem/.DS_Store
    Ignored:    output/mouse-acute-ccl4/stem/Icon
    Ignored:    output/mouse-acute-ccl4/stem/input/Icon
    Ignored:    output/mouse-acute-ccl4/stem/input/ccl4.txt
    Ignored:    output/mouse-acute-ccl4/stem_characterization.rds
    Ignored:    output/mouse-acute-ccl4/stem_result.rds
    Ignored:    output/mouse-acute-ccl4/z_scores.rds
    Ignored:    output/mouse-acute-lps/Icon
    Ignored:    output/mouse-acute-lps/limma_result.rds
    Ignored:    output/mouse-acute-lps/meta_data.rds
    Ignored:    output/mouse-acute-lps/normalized_expression.rds
    Ignored:    output/mouse-acute-lps/pca_result.rds
    Ignored:    output/mouse-acute-lps/z_scores.rds
    Ignored:    output/mouse-acute-ph/.DS_Store
    Ignored:    output/mouse-acute-ph/Icon
    Ignored:    output/mouse-acute-ph/limma_result.rds
    Ignored:    output/mouse-acute-ph/meta_data.rds
    Ignored:    output/mouse-acute-ph/normalized_expression.rds
    Ignored:    output/mouse-acute-ph/pca_result.rds
    Ignored:    output/mouse-acute-ph/stem/.DS_Store
    Ignored:    output/mouse-acute-ph/stem/Icon
    Ignored:    output/mouse-acute-ph/stem/input/Icon
    Ignored:    output/mouse-acute-ph/stem/input/hepatec.txt
    Ignored:    output/mouse-acute-ph/stem_characterization.rds
    Ignored:    output/mouse-acute-ph/stem_result.rds
    Ignored:    output/mouse-acute-ph/z_scores.rds
    Ignored:    output/mouse-acute-tunicamycin/Icon
    Ignored:    output/mouse-acute-tunicamycin/limma_result.rds
    Ignored:    output/mouse-acute-tunicamycin/meta_data.rds
    Ignored:    output/mouse-acute-tunicamycin/normalized_expression.rds
    Ignored:    output/mouse-acute-tunicamycin/pca_result.rds
    Ignored:    output/mouse-acute-tunicamycin/z_scores.rds
    Ignored:    output/mouse-chronic-ccl4/.DS_Store
    Ignored:    output/mouse-chronic-ccl4/Icon
    Ignored:    output/mouse-chronic-ccl4/limma_result.rds
    Ignored:    output/mouse-chronic-ccl4/limma_result_hs.rds
    Ignored:    output/mouse-chronic-ccl4/normalized_expression.rds
    Ignored:    output/mouse-chronic-ccl4/pca_result.rds
    Ignored:    output/mouse-chronic-ccl4/stem/.DS_Store
    Ignored:    output/mouse-chronic-ccl4/stem/Icon
    Ignored:    output/mouse-chronic-ccl4/stem/input/Icon
    Ignored:    output/mouse-chronic-ccl4/stem/input/pure_ccl4.txt
    Ignored:    output/mouse-chronic-ccl4/stem_characterization.rds
    Ignored:    output/mouse-chronic-ccl4/stem_result.rds
    Ignored:    output/mouse-chronic-ccl4/z_scores.rds
    Ignored:    renv/library/
    Ignored:    renv/staging/
    Ignored:    tables/Supplementary Table 1.xlsx
    Ignored:    tables/Supplementary Table xy consistent_genes.xlsx
    Ignored:    tables/Supplementary Table xy exclusive_common_genes.xlsx
    Ignored:    tables/Supplementary Table xy human_degs.xlsx
    Ignored:    tables/Supplementary Table xy stem_results.xlsx

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/17-plot-acute-ccl4.Rmd) and HTML (docs/17-plot-acute-ccl4.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 24c0c74 christianholland 2021-02-28 Build site.
html 5e36b25 christianholland 2021-02-28 Build site.
Rmd 7f331d0 christianholland 2021-02-28 wflow_publish("analysis/*", delete_cache = TRUE, republish = TRUE)

Introduction

Here we generate publication ready plots of the analysis of the acute CCl4 mouse model.

Libraries and sources

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-ccl4"
output_path <- "output/mouse-acute-ccl4"

# graphical parameters
# fontsize
fz <- 7

# keys to annotate contrasts
key_mm <- readRDS(here("data/meta-chronic-vs-acute/contrast_annotation.rds"))

Design

design <- ggdraw() +
  draw_image(here(data_path, "exp-design.pdf"))

Histology

histology <- ggdraw() +
  draw_image(here(data_path, "histology.png"))

Liver enyzmes

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(enzyme, levels = c("ALT", "AST")))

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
3340593 christianholland 2021-02-28

PCA

pca_result <- readRDS(here(output_path, "pca_result.rds"))

keys <- key_mm %>%
  filter(treatment == "CCl4" & class == "Acute") %>%
  distinct(time = value, label = time_label2) %>%
  drop_na() %>%
  add_row(time = 0, label = "Control") %>%
  mutate(time = ordered(time))

pca_plot <- pca_result$coords %>%
  arrange(time) %>%
  inner_join(keys, by = "time") %>%
  mutate(label = fct_inorder(label)) %>%
  ggplot(aes(x = PC1, y = PC2, color = label, label = label)) +
  geom_point() +
  labs(
    x = paste0("PC1", " (", pca_result$var[1], "%)"),
    y = paste0("PC2", " (", pca_result$var[2], "%)"),
    color = "Time"
  ) +
  my_theme(fsize = fz) +
  theme(legend.position = "top",
        legend.box.margin = margin(10, 0, -20, 0)) +
  scale_color_manual(values = aachen_color(c(
    "blue", "purple", "violet",
    "bordeaux", "red", "orange",
    "maygreen", "green", "turquoise",
    "petrol"
  )))

pca_plot

Version Author Date
3340593 christianholland 2021-02-28

Volcano plot

df <- readRDS(here(output_path, "limma_result.rds")) %>%
  filter(contrast_reference == "ccl4") %>%
  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(8,24,48)
# 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
3340593 christianholland 2021-02-28
volcano_supp

Version Author Date
3340593 christianholland 2021-02-28

Top DEGs

df <- readRDS(here(output_path, "limma_result.rds")) %>%
  filter(contrast_reference == "ccl4") %>%
  inner_join(key_mm) %>%
  select(-class) %>%
  rename(class = time_label2)

top_genes_df <- df %>% 
  group_by(class, sign(logFC)) %>%
  slice_max(order_by = abs(statistic), 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(8,24,48)

# 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
3340593 christianholland 2021-02-28
top_genes_supp

Version Author Date
3340593 christianholland 2021-02-28

Time series cluster

stem_res <- readRDS(here(output_path, "stem_result.rds")) %>%
  filter(key == "ccl4") %>%
  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 Hours") +
  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 = 3)
  )

ts_cluster

Version Author Date
3340593 christianholland 2021-02-28

Collage

Supplementary Figure 2.2

sfig2_2 <- (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_2

Version Author Date
3340593 christianholland 2021-02-28

ggsave(here("figures/Supplementary Figure 2.2.pdf"), sfig2_2,
  width = 21, height = 29.7, units = c("cm")
)
ggsave(here("figures/Supplementary Figure 2.2.png"), sfig2_2,
  width = 21, height = 29.7, units = c("cm")
)

Supplementary Figure 2.3

sfig2_3 <- (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_3

Version Author Date
3340593 christianholland 2021-02-28

ggsave(here("figures/Supplementary Figure 2.3.pdf"), sfig2_3,
  width = 21, height = 29.7, units = c("cm")
)
ggsave(here("figures/Supplementary Figure 2.3.png"), sfig2_3,
  width = 21, height = 29.7, units = c("cm")
)

Time spend to execute this analysis: 01:16 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-81    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-18  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