Last updated: 2021-01-21

Checks: 7 0

Knit directory: invitroOA_pilot_repository/

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(20210119) 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 78cfbcd. 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:    code/single_cell_preprocessing/YG-AH-2S-ANT-1_S1_L008/
    Ignored:    data/.DS_Store
    Ignored:    data/external_scRNA/.DS_Store
    Ignored:    output/voom_results.rds

Untracked files:
    Untracked:  data/RUVsOut.rds
    Untracked:  data/filtered_counts.rds
    Untracked:  data/norm_filtered_counts.rds

Unstaged changes:
    Deleted:    analysis/figure/powerAnalysis.Rmd/curve-1.png
    Deleted:    analysis/figure/powerAnalysis.Rmd/hypoxia-1.png
    Deleted:    analysis/figure/powerAnalysis.Rmd/hypoxia-2.png
    Deleted:    analysis/figure/powerAnalysis.Rmd/hypoxia-3.png
    Deleted:    analysis/figure/powerAnalysis.Rmd/hypoxia-4.png
    Deleted:    analysis/figure/powerAnalysis.Rmd/hypoxia-5.png
    Deleted:    analysis/figure/powerAnalysis.Rmd/hypoxia-6.png
    Deleted:    analysis/figure/powerAnalysis.Rmd/hypoxia-7.png
    Deleted:    analysis/figure/powerAnalysis.Rmd/hypoxia-8.png

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/heterogeneity_bulkRNA.Rmd) and HTML (docs/heterogeneity_bulkRNA.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 e3fbd0f Anthony Hung 2021-01-21 add ward et al data files to data
html e3fbd0f Anthony Hung 2021-01-21 add ward et al data files to data

Introduction

Here, we plot the expression values of three genes for which we identified inter-individual hetereogeneity in the response to mechanical strain.

Load data and libraries

library(ggplot2)

#load in V2 results from voom in DE analysis
v2 <- readRDS("output/voom_results.rds")

Plot a dot plot for each of the three genes

# this function takes in the v2 object and the name of a gene (Ensmbl ID) and outputs a plot
plot_gene <- function(v, g) {
  # v - An EList object containing log2 counts per million
  # g - character vector of a single gene
  stopifnot(class(v) == "EList",
            is.character(g), length(g) == 1)
  library("tidyr")
  single_gene <- v$E[g, ]
  single_gene_long <- as.data.frame(single_gene)
  colnames(single_gene_long) <- "log2cpm"
  single_gene_long$sample <- rownames(single_gene_long)
  single_gene_long <- separate(single_gene_long, col = "sample", sep = "_",
                                into = c("Individual", "Replicate", "Treatment"))

  single_gene_long$Treatment <- gsub('S', 'Strain', single_gene_long$Treatment)
  single_gene_long$Treatment <- gsub('U', 'Control', single_gene_long$Treatment)
  single_gene_long$Treatment <- factor(single_gene_long$Treatment, levels(factor(single_gene_long$Treatment))[c(1,2)])
  
  return(ggplot(single_gene_long, aes(x = Individual, y = log2cpm, fill = Individual)) +
              labs(title = g, y = expression("Expression level (" * log[2] * " cpm)")) + 
              geom_dotplot(binaxis = "y", stackdir = "center", key_glyph = 'rect', dotsize = 0.75) + 
              facet_wrap(~Treatment, strip.position = 'bottom') + 
              stat_summary(fun.data = "mean_sdl", fun.args = list(mult=1)) +
              theme(axis.title.x=element_blank())
              )
}

Make plots

gene_list <- c("ENSG00000157227", "ENSG00000181789", "ENSG00000120699")

for (gene in gene_list) {
     print(plot_gene(v2, as.character(gene)))
}
Loading required package: limma
`stat_bindot()` using `bins = 30`. Pick better value with `binwidth`.

Version Author Date
e3fbd0f Anthony Hung 2021-01-21
`stat_bindot()` using `bins = 30`. Pick better value with `binwidth`.

Version Author Date
e3fbd0f Anthony Hung 2021-01-21
`stat_bindot()` using `bins = 30`. Pick better value with `binwidth`.

Version Author Date
e3fbd0f Anthony Hung 2021-01-21

sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15.7

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/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 utils     datasets  methods   base     

other attached packages:
[1] limma_3.40.6  tidyr_1.1.2   ggplot2_3.3.2

loaded via a namespace (and not attached):
 [1] tidyselect_1.1.0       xfun_0.16              purrr_0.3.4           
 [4] splines_3.6.3          lattice_0.20-41        colorspace_1.4-1      
 [7] vctrs_0.3.4            generics_0.0.2         htmltools_0.5.0       
[10] yaml_2.2.1             base64enc_0.1-3        survival_3.2-3        
[13] rlang_0.4.7            later_1.1.0.1          pillar_1.4.6          
[16] foreign_0.8-75         glue_1.4.2             withr_2.2.0           
[19] RColorBrewer_1.1-2     jpeg_0.1-8.1           lifecycle_0.2.0       
[22] stringr_1.4.0          munsell_0.5.0          gtable_0.3.0          
[25] workflowr_1.6.2        htmlwidgets_1.5.1      evaluate_0.14         
[28] labeling_0.3           latticeExtra_0.6-29    knitr_1.29            
[31] httpuv_1.5.4           htmlTable_2.0.1        Rcpp_1.0.5            
[34] checkmate_2.0.0        promises_1.1.1         scales_1.1.1          
[37] backports_1.1.9        Hmisc_4.4-1            farver_2.0.3          
[40] fs_1.5.0               gridExtra_2.3          png_0.1-7             
[43] digest_0.6.25          stringi_1.4.6          dplyr_1.0.2           
[46] grid_3.6.3             rprojroot_1.3-2        tools_3.6.3           
[49] magrittr_1.5           tibble_3.0.3           Formula_1.2-3         
[52] cluster_2.1.0          crayon_1.3.4           whisker_0.4           
[55] pkgconfig_2.0.3        ellipsis_0.3.1         Matrix_1.2-18         
[58] data.table_1.12.8      rmarkdown_2.3          rstudioapi_0.11.0-9000
[61] R6_2.4.1               rpart_4.1-15           nnet_7.3-14           
[64] git2r_0.27.1           compiler_3.6.3