view 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 source

---
title: 'Short reads evaluation with [FastQC](https://www.bioinformatics.babraham.ac.uk/projects/fastqc/)'
output:
    html_document:
      number_sections: true
      toc: true
      theme: cosmo
      highlight: tango
---

```{r setup, include=FALSE, warning=FALSE, message=FALSE}
knitr::opts_knit$set(progress = FALSE)
knitr::opts_chunk$set(error = TRUE, echo = FALSE)
```

# Run FastQC

```{bash}
sh ${TOOL_INSTALL_DIR}/build-and-run-job-scripts.sh
```

```{r echo=FALSE,results='asis'}
# display fastqc job script
cat('```bash\n')
cat(readLines(paste0(Sys.getenv('REPORT_FILES_PATH'), '/job-1-script.sh')), sep = '\n')
cat('\n```')
```

# Fastqc Output Visualization

## Overview

```{r eval=TRUE}
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)
}
```