Last updated: 2020-12-18

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 261f1a4. 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:    .Rproj.user/
    Ignored:    code/.DS_Store
    Ignored:    data/.DS_Store
    Ignored:    renv/library/
    Ignored:    renv/staging/

Untracked files:
    Untracked:  code/mouse-chronic-ccl4/
    Untracked:  code/utils-plots.R
    Untracked:  code/utils-rnaseq.R
    Untracked:  code/utils-wrapper.R
    Untracked:  data/mouse-chronic-ccl4/
    Untracked:  output/mouse-chronic-ccl4/

Unstaged changes:
    Modified:   renv.lock

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-chronic-ccl4.Rmd) and HTML (docs/mouse-chronic-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
Rmd 261f1a4 christianholland 2020-12-18 Start my new project

Introduction

TODO

Libraries and sources

These libraries and sources are used in this analysis

library(tidyverse)
library(tidylog)
library(here)

library(edgeR)
#> Warning: package 'edgeR' was built under R version 4.0.3
#> Warning: package 'limma' was built under R version 4.0.3

options("tidylog.display" = list(print))
source(here("code/utils-rnaseq.R"))
source(here("code/utils-wrapper.R"))
source(here("code/utils-plots.R"))

Analysis specific options

# i/o
data_path = "data/mouse-chronic-ccl4"
output_path = "output/mouse-chronic-ccl4"
figure_path = "output/mouse-chronic-ccl4/figures"

# graphical parameters
# fontsize
fz = 9

Preliminary exploratory analysis

PCA of raw data

count_matrix = readRDS(here(data_path, "count_matrix.rds"))
meta = readRDS(here(data_path, "meta_data.rds"))

stopifnot(colnames(count_matrix) ==  meta$sample)

# remove constant expressed genes and transform to log2 scale
preprocessed_count_matrix = preprocess_count_matrix(count_matrix)
#> Discarding 7711 genes 
#> Keeping 24833 genes


pca_result = do_pca(preprocessed_count_matrix, meta, top_n_var_genes = 2000)
#> left_join: added 3 columns (time, treatment, group)
#>            > rows only in x    0
#>            > rows only in y  ( 0)
#>            > matched rows     36
#>            >                 ====
#>            > rows total       36

plot_pca(pca_result, feature = "time") +
  my_theme()

plot_pca(pca_result, feature = "treatment") +
  my_theme()

Data processing

Normalization

count_matrix = readRDS(here(data_path, "count_matrix.rds"))
meta = readRDS(here(data_path, "meta_data.rds"))

stopifnot(meta$sample == colnames(count_matrix))

dge_obj = DGEList(count_matrix, group = meta$group)

# filter low read counts, TMM normalization and logCPM transformation
norm = voom_normalization(dge_obj)
#> Discarding 17206 genes 
#> Keeping 15338 genes

saveRDS(norm, here(output_path, "normalized_expression.rds"))

PCA of normalized data

expr = readRDS(here(output_path, "normalized_expression.rds"))
meta = readRDS(here(data_path, "meta_data.rds"))

pca_result = do_pca(expr, meta, top_n_var_genes = 1000)
#> left_join: added 3 columns (time, treatment, group)
#>            > rows only in x    0
#>            > rows only in y  ( 0)
#>            > matched rows     36
#>            >                 ====
#>            > rows total       36

saveRDS(pca_result, here(output_path, "pca_result.rds"))

### PC1 vs PC2
plot_pca(pca_result, feature = "time") +
  my_theme()


plot_pca(pca_result, feature = "treatment") +
  my_theme()


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] edgeR_3.32.0    limma_3.46.0    here_1.0.1      tidylog_1.0.2  
#>  [5] forcats_0.5.0   stringr_1.4.0   dplyr_1.0.2     purrr_0.3.4    
#>  [9] readr_1.4.0     tidyr_1.1.2     tibble_3.0.4    ggplot2_3.3.2  
#> [13] tidyverse_1.3.0 workflowr_1.6.2
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.5        locfit_1.5-9.4    lubridate_1.7.9.2 lattice_0.20-41  
#>  [5] clisymbols_1.2.0  assertthat_0.2.1  rprojroot_2.0.2   digest_0.6.27    
#>  [9] R6_2.5.0          cellranger_1.1.0  backports_1.2.1   reprex_0.3.0     
#> [13] evaluate_0.14     httr_1.4.2        pillar_1.4.7      rlang_0.4.9      
#> [17] readxl_1.3.1      rstudioapi_0.13   whisker_0.4       rmarkdown_2.6    
#> [21] labeling_0.4.2    munsell_0.5.0     broom_0.7.3       compiler_4.0.2   
#> [25] httpuv_1.5.4      modelr_0.1.8      xfun_0.19         pkgconfig_2.0.3  
#> [29] htmltools_0.5.0   tidyselect_1.1.0  viridisLite_0.3.0 fansi_0.4.1      
#> [33] crayon_1.3.4      dbplyr_2.0.0      withr_2.3.0       later_1.1.0.1    
#> [37] grid_4.0.2        jsonlite_1.7.2    gtable_0.3.0      lifecycle_0.2.0  
#> [41] DBI_1.1.0         git2r_0.27.1      magrittr_2.0.1    scales_1.1.1     
#> [45] cli_2.2.0         stringi_1.5.3     farver_2.0.3      renv_0.12.3      
#> [49] fs_1.5.0          promises_1.1.1    xml2_1.3.2        ellipsis_0.3.1   
#> [53] generics_0.1.0    vctrs_0.3.6       cowplot_1.1.0     tools_4.0.2      
#> [57] glue_1.4.2        hms_0.5.3         yaml_2.2.1        colorspace_2.0-0 
#> [61] rvest_0.3.6       knitr_1.30        haven_2.3.1