diff 01_evaluation_overview.Rmd @ 2:c64267b9f754 draft default tip

planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
author mingchen0919
date Sun, 30 Dec 2018 12:48:14 -0500
parents b7c115edd970
children
line wrap: on
line diff
--- a/01_evaluation_overview.Rmd	Tue Feb 27 10:40:20 2018 -0500
+++ b/01_evaluation_overview.Rmd	Sun Dec 30 12:48:14 2018 -0500
@@ -9,87 +9,49 @@
 ---
 
 ```{r setup, include=FALSE, warning=FALSE, message=FALSE}
-knitr::opts_chunk$set(
-  echo = as.logical(opt$X_e),
-  error = TRUE,
-  eval = TRUE
-)
+knitr::opts_knit$set(progress = FALSE)
+knitr::opts_chunk$set(error = TRUE, echo = FALSE)
 ```
 
 # Run FastQC
 
-```{bash eval=TRUE,echo=FALSE}
-cd ${X_d}
-cp ${X_r} ${X_d}/read_1.fq
-cp ${X_R} ${X_d}/read_2.fq
-
-cat >temp.sh <<EOL
-fastqc \\
-  -q \\
-  -c ${X_c} \\
-  -l ${X_l} \\
-  ${X_d}/read_1.fq > /dev/null 2>&1
-  
-fastqc \\
-  -q \\
-  -c ${X_c} \\
-  -l ${X_l} \\
-  ${X_d}/read_2.fq > /dev/null 2>&1
-EOL
-
-grep -v None temp.sh > fastqc.sh
-
-# run fastqc
-sh fastqc.sh
-
-# unzip outputs
-unzip -q read_1_fastqc.zip
-unzip -q read_2_fastqc.zip
+```{bash}
+sh ${TOOL_INSTALL_DIR}/build-and-run-job-scripts.sh
 ```
 
-```{r}
+```{r echo=FALSE,results='asis'}
 # display fastqc job script
-fastqc_sh = paste0(opt$X_d, '/fastqc.sh')
-tags$code(tags$pre(readChar(fastqc_sh, file.info(fastqc_sh)$size )))
+cat('```bash\n')
+cat(readLines(paste0(Sys.getenv('REPORT_FILES_PATH'), '/job-1-script.sh')), sep = '\n')
+cat('\n```')
 ```
 
-# Raw FastQC reports
-
-## Before trimming
-```{r eval=TRUE}
-ori_html = tags$a(href = 'read_1_fastqc/fastqc_report.html', opt$X_n)
-ori_fastqc_data = tags$a(href = 'read_1_fastqc/fastqc_data.txt', 'fastqc_data.txt')
-ori_summary = tags$a(href = 'read_1_fastqc/summary.txt', 'summary.txt')
-tags$ul(
-    tags$li(ori_html),
-    tags$li(ori_fastqc_data),
-    tags$li(ori_summary)
-  )
-```
-
-## After trimming
-```{r eval=TRUE}
-ori_html = tags$a(href = 'read_2_fastqc/fastqc_report.html', opt$X_n)
-ori_fastqc_data = tags$a(href = 'read_2_fastqc/fastqc_data.txt', 'fastqc_data.txt')
-ori_summary = tags$a(href = 'read_2_fastqc/summary.txt', 'summary.txt')
-tags$ul(
-    tags$li(ori_html),
-    tags$li(ori_fastqc_data),
-    tags$li(ori_summary)
-  )
-```
-
-
 # Fastqc Output Visualization
 
 ## Overview
 
 ```{r eval=TRUE}
-read_1_summary = read.csv(paste0(opt$X_d, '/read_1_fastqc/summary.txt'), header = FALSE, sep = '\t')[, 2:1]
-read_2_summary = read.csv(paste0(opt$X_d, '/read_2_fastqc/summary.txt'), header = FALSE, sep = '\t')[, 1]
-combined_summary = cbind(read_1_summary, read_2_summary)
-names(combined_summary) = c('MODULE', paste0(opt$X_n, '(before)'), paste0(opt$X_N, '(after)'))
+read_1_summary = read.csv(paste0(opt$X_d, '/read_1_fastqc/summary.txt'),
+                          stringsAsFactors = FALSE,
+                          header = FALSE, sep = '\t')[, 2:1]
+read_2_summary = read.csv(paste0(opt$X_d, '/read_2_fastqc/summary.txt'),
+                          stringsAsFactors = FALSE,
+                          header = FALSE, sep = '\t')[, 1]
+combined_summary = data.frame(read_1_summary, read_2_summary, stringsAsFactors = FALSE)
+names(combined_summary) = c('MODULE', 'Pre-trimming', 'Post-trimming')
 combined_summary[combined_summary == 'FAIL'] = 'FAIL (X)'
 combined_summary[combined_summary == 'WARN'] = 'WARN (!)'
 knitr::kable(combined_summary)
 ```
+
+```{r 'function definition', echo=FALSE}
+extract_data_module = function(fastqc_data, module_name, header = TRUE, comment.char = "") {
+  f = readLines(fastqc_data)
+  start_line = grep(module_name, f)
+  end_module_lines = grep('END_MODULE', f)
+  end_line = end_module_lines[which(end_module_lines > start_line)[1]]
+  module_data = f[(start_line+1):(end_line-1)]
+  writeLines(module_data, '/tmp/temp.txt')
+  read.csv('/tmp/temp.txt', sep = '\t', header = header, comment.char = comment.char)
+}
+```