Last updated: 2021-02-19

Checks: 6 1

Knit directory: 2021_UoM_Yap_shRNA_nuclei_RNAseq_ATACseq/

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(20210219) 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.

Using absolute paths to the files within your workflowr project makes it difficult for you and others to run your code on a different machine. Change the absolute path(s) below to the suggested relative path(s) to make your code more reproducible.

absolute relative
/group/card2/Evangelyn_Sim/Collaboration_Kev_UoM/Sequencing_ATAC_RNA/Github/2021_UoM_Yap_shRNA_nuclei_RNAseq_ATACseq/output/mouseATAC_peaks_cov2.bed.saf.pe.mx.fix_filt output/mouseATAC_peaks_cov2.bed.saf.pe.mx.fix_filt
/group/card2/Evangelyn_Sim/Collaboration_Kev_UoM/Sequencing_ATAC_RNA/Github/2021_UoM_Yap_shRNA_nuclei_RNAseq_ATACseq/output/pheno.matrix_cov2.txt output/pheno.matrix_cov2.txt
/group/card2/Evangelyn_Sim/Collaboration_Kev_UoM/Sequencing_ATAC_RNA/Github/2021_UoM_Yap_shRNA_nuclei_RNAseq_ATACseq/output/edgeR_ output/edgeR_

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 704a4cf. 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/

Untracked files:
    Untracked:  Mus_musculus.GRCm38.96.fulllength.saf
    Untracked:  header.txt
    Untracked:  mouseATAC*bed.saf
    Untracked:  mouseATAC*bed.saf.pe.mx
    Untracked:  mouseATAC*bed.saf.pe.mx.chr
    Untracked:  mouseATAC*bed.saf.pe.mx.fix
    Untracked:  output/YAP_shRNA_D28_Proteomics_results.xls
    Untracked:  output/edgeR_atac_cov2_LacZvsYap.xls
    Untracked:  output/edgeR_rna_LacZvsYap.xls
    Untracked:  output/logCPM_mrna_fulllen_pe_strrev.mx.fix_filt.csv
    Untracked:  output/mouse2human.txt.sort
    Untracked:  output/mouseATAC_peaks_cov2.bed.saf.pe.mx.fix_filt
    Untracked:  output/mrna_fulllen_pe_strrev.mx.fix_filt
    Untracked:  output/pheno.matrix.txt
    Untracked:  output/pheno.matrix_cov2.txt
    Untracked:  output/sampleinfo.txt

Unstaged changes:
    Modified:   README.md

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/05.ATACseq_EdgeR_and_ScatterPlot.Rmd) and HTML (docs/05.ATACseq_EdgeR_and_ScatterPlot.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 704a4cf evangelynsim 2021-02-19 wflow_publish(c(“analysis/01.RNAseq_primary_analysis.Rmd”, “analysis/02.RNAseq_QC_and_CPM.Rmd”,

Introduction

In the GEO submission 1 processed files were uploaded.

  1. mouseATAC_peaks_cov2.bed.saf.pe.mx.fix_filt

They have been uploaded in the /output folder and will be used below to generate different figures.

Used libraries and functions

library(edgeR)
Loading required package: limma
library(limma)
library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
library(ggplot2)
library(moonBook)
library(webr)
library(waffle)
library(extrafont)
Registering fonts with R
library(grid)
library(gridExtra)

Attaching package: 'gridExtra'
The following object is masked from 'package:dplyr':

    combine
library(cowplot)

********************************************************
Note: As of version 1.0.0, cowplot does not change the
  default ggplot2 theme anymore. To recover the previous
  behavior, execute:
  theme_set(theme_cowplot())
********************************************************
library(ggpubr)

Attaching package: 'ggpubr'
The following object is masked from 'package:cowplot':

    get_legend

1. EdgeR

Read files

PRIOR = 20
FDR = 0.01

rm1 <- read.delim("/group/card2/Evangelyn_Sim/Collaboration_Kev_UoM/Sequencing_ATAC_RNA/Github/2021_UoM_Yap_shRNA_nuclei_RNAseq_ATACseq/output/mouseATAC_peaks_cov2.bed.saf.pe.mx.fix_filt", header = TRUE, row.names = 1)
matrix = rm1[,c(1:6)]

phenoN = data.frame(colnames(matrix))
colnames(phenoN) = "sampleN"

phenoN$sample = gsub(".[0-9]", "", phenoN$sampleN)

pheno = data.frame(phenoN[,c(2)])
colnames(pheno) =  "sample"


write.table(pheno, file="/group/card2/Evangelyn_Sim/Collaboration_Kev_UoM/Sequencing_ATAC_RNA/Github/2021_UoM_Yap_shRNA_nuclei_RNAseq_ATACseq/output/pheno.matrix_cov2.txt", sep="\t", quote = F, row.names = F)
pheno = read.delim(file="/group/card2/Evangelyn_Sim/Collaboration_Kev_UoM/Sequencing_ATAC_RNA/Github/2021_UoM_Yap_shRNA_nuclei_RNAseq_ATACseq/output/pheno.matrix_cov2.txt")

########################################################################################################

attach(pheno)
design = model.matrix(as.formula("~ 0  + sample"))
detach(pheno)
design
  sampleLacz sampleYap
1          1         0
2          1         0
3          1         0
4          0         1
5          0         1
6          0         1
attr(,"assign")
[1] 1 1
attr(,"contrasts")
attr(,"contrasts")$sample
[1] "contr.treatment"
D = DGEList(counts=matrix)
D = calcNormFactors(D)
D = estimateGLMCommonDisp(D, design)
D = estimateGLMTagwiseDisp(D, design, prior.df = PRIOR)
fit = glmFit(D, design, prior.count = PRIOR)

Contrast = makeContrasts(atac_cov2_LacZvsYap = sampleYap - sampleLacz,
                         levels=design)

res = list()
contrast.name = colnames(Contrast)

for(i in 1:length(contrast.name)){
  lrt = glmLRT(fit, contrast = Contrast[,i])   
  
  results = lrt$table
  disp = lrt$dispersion
  fitted.vals = lrt$fitted.values
  coefficients = lrt$coefficients
  
  results$adj.p.value = p.adjust(p = results$PValue, method = "fdr" )
  table(row.names(results) == row.names(fitted.vals))
  
  Name = row.names(results)
  res0 = cbind(Name, results, disp, fitted.vals, coefficients)
  res[[i]] = res0[order(res0$adj.p.value),]
  write.table(res[[i]], file= paste0("/group/card2/Evangelyn_Sim/Collaboration_Kev_UoM/Sequencing_ATAC_RNA/Github/2021_UoM_Yap_shRNA_nuclei_RNAseq_ATACseq/output/edgeR_", contrast.name[i] ,".xls"), quote=F, sep="\t", col.names = T, row.names = F)
  
  
  res[[i]]= mutate(res[[i]], cs= ifelse(res[[i]]$PValue <= 0.01 , "red", "black"))
  
  mxFDR = res[[i]][res[[i]]$PValue <= FDR,]
  mxFDR_Up = mxFDR[mxFDR$logFC>0,]
  mxFDR_Dn = mxFDR[mxFDR$logFC<0,]
  
  res[[i]]= mutate(res[[i]], FDR= nrow(mxFDR))
  res[[i]]= mutate(res[[i]], FDRup= nrow(mxFDR_Up))
  res[[i]]= mutate(res[[i]], FDRdn= nrow(mxFDR_Dn))

}

2. MA plot of EdgeR result

par(mfrow=c(1,1))

for(i in 1:length(contrast.name)){

  plot(res[[i]]$logFC, -log10(res[[i]]$PValue), pch=20, cex=0.8, col=res[[i]]$cs, 
       xlab = "LogFC", ylab = "-log10(PValue)",
       main = paste0(contrast.name[i], 
                      "\np<=0.01, N=", res[[i]][1,ncol(res[[i]])-2], 
                      "\nUp=",res[[i]][1,ncol(res[[i]])-1],", Dn=",res[[i]][1,ncol(res[[i]])]))
  grid(nx = NULL, ny = NULL, col = "blue", lty = "dotted")
  
  
}

3. Genome Feature of Peaks Enriched in AAV6:lacZ-shRNA or AAV6:Yap-shRNA

Select peaks with p<=0.01

#!/bin/bash

set -x


#Create sets of foreground regions in bed format
for XLS in *xls ; do

  UP=$XLS.up.bed
  DN=$XLS.dn.bed

 awk ' $5<0.01 && $2>0 {print $1"\t"$1}' $XLS \
  | cut -d '_' -f2- | sed 's/:/\t/' | sed 's/-/\t/' \
  | bedtools sort > $UP

  awk ' $5<0.01 && $2<0 {print $1"\t"$1}' $XLS \
  | cut -d '_' -f2- | sed 's/:/\t/' | sed 's/-/\t/' \
  | bedtools sort > $DN
done

#Create a set of background regions from those not changing in any comparison
BG=$XLS.bg.bed
tail -qn +2 *xls \
| awk '$5>0.1 {print $1}' \
| sort | uniq -c \
| cut -d '_' -f2- | tr ':-' '\t' \
| bedtools sort > $BG

Homer annotate peaks

#!/bin/bash

set -x

REF=/group/card2/Evangelyn_Sim/Collaboration_Kev_UoM/Sequencing_ATAC_RNA/refgenome/Mus_musculus.GRCm38.96.gtf

#PATH=$PATH:/group/card2/Evangelyn_Sim/NGS/app/homer/.//bin/

for BED in *.up.bed *.dn.bed ; do

 OUT=$BED.homeranno.txt
 annotatePeaks.pl $BED mm10 -gtf $REF -go go -annStats $BED.stats.txt > $OUT

done

Plot Homer peak annotation results

files = list.files(path = "/group/card2/Evangelyn_Sim/Collaboration_Kev_UoM/Sequencing_ATAC_RNA/20190530_ATAC_run1/R/2.pks/4.pkstats/", pattern = ".stats.txt", full.names = T)

mx = lapply(files, read.delim, header=T)

files
[1] "/group/card2/Evangelyn_Sim/Collaboration_Kev_UoM/Sequencing_ATAC_RNA/20190530_ATAC_run1/R/2.pks/4.pkstats//edgeR_atac_cov2_LacZvsYap.xls.dn.bed.stats.txt"
[2] "/group/card2/Evangelyn_Sim/Collaboration_Kev_UoM/Sequencing_ATAC_RNA/20190530_ATAC_run1/R/2.pks/4.pkstats//edgeR_atac_cov2_LacZvsYap.xls.up.bed.stats.txt"
for(i in 1:length(mx)){
  
  mxFDR = mx[[i]][c(1:5),]
  #write.table(mxFDR,
  #            file = paste0(gsub("./|.txt","",files[[i]]),".tidy.txt"),
  #            col.names = T, row.names = F, sep = "\t")
  
}



files1 = list.files(path = "/group/card2/Evangelyn_Sim/Collaboration_Kev_UoM/Sequencing_ATAC_RNA/20190530_ATAC_run1/R/2.pks/4.pkstats/", pattern = ".stats.tidy.txt", full.names = T)

mx1 = lapply(files1, read.delim, header=T)

for(j in 1:length(mx1)){
  
  mx[[j]]=PieDonut(mx1[[j]],aes(Annotation,count=Number.of.peaks),r0=0.5,start=3*pi/2,labelpositionThreshold=0.1)
  
}
multi = arrangeGrob(mx[[1]],mx[[2]],
                    ncol = 2, nrow = 1)
plot = as_ggplot(multi)

plot


sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS:   /hpc/software/installed/R/3.6.1/lib64/R/lib/libRblas.so
LAPACK: /hpc/software/installed/R/3.6.1/lib64/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods  
[8] base     

other attached packages:
 [1] ggpubr_0.4.0    cowplot_1.0.0   gridExtra_2.3   extrafont_0.17 
 [5] waffle_0.7.0    webr_0.1.5      moonBook_0.2.3  ggplot2_3.3.2  
 [9] dplyr_1.0.2     edgeR_3.26.8    limma_3.40.6    workflowr_1.6.2

loaded via a namespace (and not attached):
  [1] nlme_3.1-150       fs_1.5.0           RColorBrewer_1.1-2
  [4] insight_0.9.0      rprojroot_1.3-2    tools_3.6.1       
  [7] backports_1.1.10   R6_2.5.0           DT_0.14           
 [10] sjlabelled_1.1.6   colorspace_1.4-1   withr_2.3.0       
 [13] tidyselect_1.1.0   mnormt_1.5-6       extrafontdb_1.0   
 [16] curl_4.3           compiler_3.6.1     git2r_0.27.1      
 [19] flextable_0.5.10   xml2_1.3.2         officer_0.3.12    
 [22] labeling_0.4.2     scales_1.1.1       lmtest_0.9-38     
 [25] psych_1.9.12.31    readr_1.4.0        systemfonts_0.2.3 
 [28] stringr_1.4.0      digest_0.6.27      foreign_0.8-71    
 [31] editData_0.1.2     rmarkdown_2.5      rio_0.5.16        
 [34] base64enc_0.1-3    pkgconfig_2.0.3    htmltools_0.5.0   
 [37] fastmap_1.0.1      highr_0.8          rvg_0.2.5         
 [40] htmlwidgets_1.5.2  rlang_0.4.7        readxl_1.3.1      
 [43] rstudioapi_0.11    shiny_1.5.0        farver_2.0.3      
 [46] generics_0.1.0     zoo_1.8-8          jsonlite_1.7.0    
 [49] zip_2.1.1          car_3.0-10         magrittr_1.5      
 [52] Rcpp_1.0.5         munsell_0.5.0      abind_1.4-5       
 [55] gdtools_0.2.2      lifecycle_0.2.0    stringi_1.5.3     
 [58] whisker_0.4        yaml_2.2.1         carData_3.0-4     
 [61] MASS_7.3-51.6      parallel_3.6.1     promises_1.1.1    
 [64] sjmisc_2.8.5       forcats_0.5.0      crayon_1.3.4      
 [67] miniUI_0.1.1.1     lattice_0.20-41    haven_2.3.1       
 [70] hms_0.5.3          locfit_1.5-9.4     knitr_1.30        
 [73] pillar_1.4.6       uuid_0.1-4         ggsignif_0.6.0    
 [76] glue_1.4.2         evaluate_0.14      data.table_1.13.2 
 [79] vcd_1.4-8          vctrs_0.3.2        tweenr_1.0.1      
 [82] httpuv_1.5.4       Rttf2pt1_1.3.8     cellranger_1.1.0  
 [85] gtable_0.3.0       purrr_0.3.4        polyclip_1.10-0   
 [88] tidyr_1.1.2        xfun_0.18          ggforce_0.3.2     
 [91] openxlsx_4.2.3     mime_0.9           xtable_1.8-4      
 [94] broom_0.7.0        rstatix_0.6.0      later_1.1.0.1     
 [97] tibble_3.0.3       shinyWidgets_0.5.4 rrtable_0.2.1     
[100] ellipsis_0.3.1     ztable_0.2.0       devEMF_3.8