Last updated: 2020-12-19
Checks: 7 0
Knit directory: meta-liver/
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 891a004. 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/mouse-acute-apap_cache/
Ignored: analysis/mouse-acute-bdl_cache/
Ignored: analysis/mouse-acute-ccl4_cache/
Ignored: analysis/mouse-chronic-ccl4_cache/
Ignored: code/.DS_Store
Ignored: data/.DS_Store
Ignored: data/annotation/
Ignored: data/mouse-acute-apap/
Ignored: data/mouse-acute-bdl/
Ignored: data/mouse-acute-ccl4/
Ignored: data/mouse-acute-ph/
Ignored: data/mouse-chronic-ccl4/
Ignored: external_software/.DS_Store
Ignored: external_software/README.html
Ignored: external_software/stem/.DS_Store
Ignored: output/.DS_Store
Ignored: output/mouse-acute-apap/
Ignored: output/mouse-acute-bdl/
Ignored: output/mouse-acute-ccl4/
Ignored: output/mouse-acute-ph/
Ignored: output/mouse-chronic-ccl4/
Ignored: renv/library/
Ignored: renv/staging/
Unstaged changes:
Modified: .gitignore
Modified: analysis/mouse-acute-apap.Rmd
Modified: analysis/mouse-acute-bdl.Rmd
Modified: analysis/mouse-acute-ccl4.Rmd
Modified: analysis/mouse-chronic-ccl4.Rmd
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/mouse-acute-ph.Rmd
) and HTML (docs/mouse-acute-ph.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 |
---|---|---|---|---|
Rmd | 891a004 | christianholland | 2020-12-19 | added ph study |
Here we analysis a mouse model of PH (partial hepatectomy) induced acute liver damage. The transcriptomic profiles were measured at 12 different time points ranging from 1 hour to 3 months.
These libraries and sources are used for this analysis.
library(mouse4302.db)
library(tidyverse)
library(tidylog)
library(here)
library(oligo)
library(annotate)
library(limma)
library(biobroom)
library(janitor)
library(AachenColorPalette)
library(cowplot)
library(lemon)
library(patchwork)
options("tidylog.display" = list(print))
source(here("code/utils-microarray.R"))
source(here("code/utils-utils.R"))
source(here("code/utils-plots.R"))
Definition of global variables that are used throughout this analysis.
# i/o
data_path <- "data/mouse-acute-ph"
output_path <- "output/mouse-acute-ph"
# graphical parameters
# fontsize
fz <- 9
The array quality is controlled based on the relative log expression values (RLE) and the normalized unscaled standard errors (NUSE).
# load cel files and check quality
platforms <- readRDS(here("data/annotation/platforms.rds"))
raw_eset <- list.celfiles(here(data_path), listGzipped = T, full.names = T) %>%
read.celfiles() %>%
ma_qc() # discard Jena_DPH_69_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_03_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_04_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_16_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_21_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_22_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_23_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_24_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_25_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_27_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_28_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_29_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_34_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_35_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_36_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_37_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_39_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_40_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_41_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_44_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_47_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_48_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_49_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_50_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_51_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_52_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_54_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_58_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_59_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_60_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_61_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_62_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_66_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_67_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_69_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_70_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_71_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_74_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_75_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_DPH_76_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_WMH_17_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Jena_WMT_16_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Patricio_DPH022_1_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Patricio_DPH023_2_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Patricio_NOR_014_8_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Patricio_NOR_015_9_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Patricio_NOR_016_10_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Patricio_NOR_017_11_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Patricio_NOR_018_12_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Patricio_WMH_004_3_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Patricio_WMH_005_4_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Patricio_WMH_006_5_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Patricio_WMH_007_6_(Mouse430_2).CEL
#> Reading in : /Users/cholland/Projects/meta-liver/data/mouse-acute-ph/Patricio_WMH_008_7_(Mouse430_2).CEL
Probe intensities are normalized with the rma()
function. Probes are annotated with MGI symbols.
eset <- rma(raw_eset)
#> Background correcting
#> Normalizing
#> Calculating Expression
# annotate microarray probes with mgi symbols
expr <- ma_annotate(eset, platforms)
# save normalized expression
saveRDS(expr, here(output_path, "normalized_expression.rds"))
Meta information are loaded from a manual constructed .csv file
meta_raw = read_csv(here(data_path, "DPH_WMH_Samples_clean.csv"))
meta = meta_raw %>%
filter(sample %in% colnames(expr)) %>%
mutate(time = ordered(time),
gender = as_factor(gender),
treatment = as_factor(treatment),
year = ordered(year),
mouse = fct_inorder(mouse),
surgeon = factor(surgeon),
group = as_factor(group)) %>%
select(-gender)
#> filter: removed one row (2%), 52 rows remaining
#> mutate: converted 'mouse' from character to factor (0 new NA)
#> converted 'surgeon' from character to factor (0 new NA)
#> converted 'gender' from character to factor (0 new NA)
#> converted 'treatment' from character to factor (0 new NA)
#> converted 'group' from character to factor (0 new NA)
#> converted 'year' from double to ordered factor (0 new NA)
#> converted 'time' from double to ordered factor (0 new NA)
#> select: dropped one variable (gender)
# save meta data
saveRDS(meta, here(output_path, "meta_data.rds"))
PCA plot of normalized expression data contextualized based on the time point. Only the top 1000 most variable genes are used as features.
expr <- readRDS(here(output_path, "normalized_expression.rds"))
meta <- readRDS(here(output_path, "meta_data.rds"))
pca_result <- do_pca(expr, meta, top_n_var_genes = 1000)
#> left_join: added 6 columns (mouse, surgeon, treatment, group, year, …)
#> > rows only in x 0
#> > rows only in y ( 0)
#> > matched rows 52
#> > ====
#> > rows total 52
saveRDS(pca_result, here(output_path, "pca_result.rds"))
plot_pca(pca_result, feature = "time") +
my_theme()
Differential gene expression analysis via limma with the aim to identify the effect of PH for the different time points.
# load expression and meta data
expr <- readRDS(here(output_path, "normalized_expression.rds"))
meta <- readRDS(here(output_path, "meta_data.rds"))
stopifnot(colnames(expr) == meta$sample)
# build design matrix
design = model.matrix(~0+group, data=meta)
rownames(design) = meta$sample
# define contrasts
contrasts = makeContrasts(
# comparison vs time point 0
ph_0.043d = group1h - group0h,
ph_0.25d = group6h - group0h,
ph_0.5d = group12h - group0h,
ph_1d = group24h - group0h,
ph_2d = group48h - group0h,
ph_3d = group3d - group0h,
ph_4d = group4d - group0h,
ph_7d = group1w - group0h,
ph_14d = group2w - group0h,
ph_28d = group4w - group0h,
ph_84d = group3m - group0h,
# consecutive timepoint comparison
consec_1h_vs_0h = group1h - group0h,
consec_6h_vs_1h = group6h - group1h,
consec_12h_vs_6h = group12h - group6h,
consec_1d_vs_12h = group24h - group12h,
consec_2d_vs_1d = group48h - group24h,
consec_3d_vs_2d = group3d - group48h,
consec_4d_vs_3d = group4d - group3d,
consec_1w_vs_4d = group1w - group4d,
consec_2w_vs_1w = group2w - group1w,
consec_1m_vs_2w = group4w - group2w,
consec_3m_vs_1m = group3m - group4w,
levels = design
)
limma_result = run_limma(expr, design, contrasts) %>%
assign_deg()
#> select: renamed 3 variables (contrast, logFC, pval) and dropped one variable
#> group_by: one grouping variable (contrast)
#> mutate (grouped): new variable 'fdr' (double) with 205,639 unique values and 0% NA
#> ungroup: no grouping variables
#> mutate: new variable 'regulation' (character) with 3 unique values and 0% NA
#> mutate: converted 'regulation' from character to factor (0 new NA)
deg_df = limma_result %>%
mutate(contrast = fct_inorder(contrast)) %>%
mutate(contrast_reference = case_when(
str_detect(contrast, "ph") ~ "hepatec",
str_detect(contrast, "consec") ~ "consec"))
#> mutate: changed 0 values (0%) of 'contrast' (0 new NA)
#> mutate: new variable 'contrast_reference' (character) with 2 unique values and 0% NA
saveRDS(deg_df, here(output_path, "limma_result.rds"))
Volcano plots visualizing the effect of APAP on gene expression.
df <- readRDS(here(output_path, "limma_result.rds"))
df %>%
filter(contrast_reference == "hepatec") %>%
plot_volcano() +
my_theme(grid = "y", fsize = fz)
#> filter: removed 225,214 rows (50%), 225,214 rows remaining
#> rename: renamed one variable (p)
Gene expression trajectories are clustered using the STEM software. The cluster algorithm is described here.
# prepare input for stem analysis
df = readRDS(here(output_path, "limma_result.rds"))
stem_inputs = df %>%
filter(contrast_reference == "hepatec") %>%
mutate(class = str_c("Hour ",
as.integer(parse_number(as.character(contrast))*24))) %>%
arrange(contrast) %>%
mutate(class = fct_inorder(class)) %>%
select(gene, class, logFC, contrast_reference)
#> filter: removed 225,214 rows (50%), 225,214 rows remaining
#> mutate: new variable 'class' (character) with 11 unique values and 0% NA
#> mutate: converted 'class' from character to factor (0 new NA)
#> select: dropped 5 variables (contrast, statistic, pval, fdr, regulation)
stem_inputs %>%
select(-contrast_reference) %>%
pivot_wider(names_from = class, values_from = logFC) %>%
write_delim(here(output_path, "stem/input/hepatec.txt"), delim = "\t")
#> select: dropped one variable (contrast_reference)
#> pivot_wider: reorganized (class, logFC) into (Hour 1, Hour 6, Hour 12, Hour 24, Hour 48, …) [was 225214x3, now 20474x12]
STEM is implemented in Java. The .jar file is called from R. Only significant time series clusters are visualized.
# execute stem
stem_res <- run_stem(here(output_path, "stem"), clear_output = T)
#> distinct: no rows removed
#> mutate: new variable 'gene' (character) with 20,474 unique values and 0% NA
#> distinct: no rows removed
#> mutate: new variable 'key' (character) with one unique value and 0% NA
#> select: dropped one variable (spot)
#> gather: reorganized (x0, hour_1, hour_6, hour_12, hour_24, …) into (time, value) [was 3878x15, now 46536x5]
#> mutate: converted 'time' from character to double (0 new NA)
#> mutate: new variable 'key' (character) with one unique value and 0% NA
#> select: renamed 4 variables (profile, y_coords, size, p) and dropped 2 variables
#> inner_join: added 3 columns (y_coords, size, p)
#> > rows only in x ( 0)
#> > rows only in y ( 0)
#> > matched rows 46,536
#> > ========
#> > rows total 46,536
#> inner_join: added one column (symbol)
#> > rows only in x ( 0)
#> > rows only in y (16,596)
#> > matched rows 46,536
#> > ========
#> > rows total 46,536
#> transmute: dropped one variable (symbol)
#> changed 45,924 values (99%) of 'gene' (0 new NA)
saveRDS(stem_res, here(output_path, "stem_result.rds"))
stem_res %>%
filter(p <= 0.05) %>%
filter(key == "hepatec") %>%
distinct() %>%
plot_stem_profiles(model_profile = F, ncol = 2) +
labs(x = "Time in Days", y = "logFC") +
my_theme(grid = "y", fsize = fz)
#> filter: removed 16,056 rows (35%), 30,480 rows remaining
#> filter: no rows removed
#> distinct: no rows removed
#> group_by: 4 grouping variables (key, profile, p, time)
#> ungroup: no grouping variables
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] parallel stats4 stats graphics grDevices datasets utils
#> [8] methods base
#>
#> other attached packages:
#> [1] pd.mouse430.2_3.12.0 DBI_1.1.0 RSQLite_2.2.1
#> [4] patchwork_1.1.1 lemon_0.4.5 cowplot_1.1.0
#> [7] AachenColorPalette_1.1.2 janitor_2.0.1 biobroom_1.22.0
#> [10] broom_0.7.3 limma_3.46.0 annotate_1.68.0
#> [13] XML_3.99-0.5 oligo_1.54.1 Biostrings_2.58.0
#> [16] XVector_0.30.0 oligoClasses_1.52.0 here_1.0.1
#> [19] tidylog_1.0.2 forcats_0.5.0 stringr_1.4.0
#> [22] dplyr_1.0.2 purrr_0.3.4 readr_1.4.0
#> [25] tidyr_1.1.2 tibble_3.0.4 ggplot2_3.3.2
#> [28] tidyverse_1.3.0 mouse4302.db_3.2.3 org.Mm.eg.db_3.12.0
#> [31] AnnotationDbi_1.52.0 IRanges_2.24.1 S4Vectors_0.28.1
#> [34] Biobase_2.50.0 BiocGenerics_0.36.0 workflowr_1.6.2
#>
#> loaded via a namespace (and not attached):
#> [1] colorspace_2.0-0 ellipsis_0.3.1
#> [3] rprojroot_2.0.2 snakecase_0.11.0
#> [5] GenomicRanges_1.42.0 fs_1.5.0
#> [7] rstudioapi_0.13 farver_2.0.3
#> [9] affyio_1.60.0 bit64_4.0.5
#> [11] fansi_0.4.1 lubridate_1.7.9.2
#> [13] xml2_1.3.2 codetools_0.2-16
#> [15] splines_4.0.2 knitr_1.30
#> [17] jsonlite_1.7.2 dbplyr_2.0.0
#> [19] BiocManager_1.30.10 compiler_4.0.2
#> [21] httr_1.4.2 backports_1.2.1
#> [23] assertthat_0.2.1 Matrix_1.2-18
#> [25] cli_2.2.0 later_1.1.0.1
#> [27] htmltools_0.5.0 tools_4.0.2
#> [29] gtable_0.3.0 glue_1.4.2
#> [31] GenomeInfoDbData_1.2.4 affxparser_1.62.0
#> [33] Rcpp_1.0.5 cellranger_1.1.0
#> [35] vctrs_0.3.6 preprocessCore_1.52.0
#> [37] iterators_1.0.13 xfun_0.19
#> [39] rvest_0.3.6 lifecycle_0.2.0
#> [41] renv_0.12.3 zlibbioc_1.36.0
#> [43] scales_1.1.1 clisymbols_1.2.0
#> [45] hms_0.5.3 promises_1.1.1
#> [47] MatrixGenerics_1.2.0 SummarizedExperiment_1.20.0
#> [49] yaml_2.2.1 gridExtra_2.3
#> [51] memoise_1.1.0 stringi_1.5.3
#> [53] foreach_1.5.1 GenomeInfoDb_1.26.2
#> [55] rlang_0.4.9 pkgconfig_2.0.3
#> [57] bitops_1.0-6 matrixStats_0.57.0
#> [59] evaluate_0.14 lattice_0.20-41
#> [61] labeling_0.4.2 bit_4.0.4
#> [63] tidyselect_1.1.0 plyr_1.8.6
#> [65] magrittr_2.0.1 R6_2.5.0
#> [67] generics_0.1.0 DelayedArray_0.16.0
#> [69] pillar_1.4.7 haven_2.3.1
#> [71] whisker_0.4 withr_2.3.0
#> [73] RCurl_1.98-1.2 modelr_0.1.8
#> [75] crayon_1.3.4 rmarkdown_2.6
#> [77] grid_4.0.2 readxl_1.3.1
#> [79] blob_1.2.1 git2r_0.27.1
#> [81] reprex_0.3.0 digest_0.6.27
#> [83] xtable_1.8-4 ff_4.0.4
#> [85] httpuv_1.5.4 munsell_0.5.0
#> [87] viridisLite_0.3.0