diff rmarkdown_samtools_flagstat.Rmd @ 4:ec39bfeaf496 draft

update
author mingchen0919
date Wed, 27 Dec 2017 15:14:47 -0500
parents a0f0effea707
children 1c16536c70f5
line wrap: on
line diff
--- a/rmarkdown_samtools_flagstat.Rmd	Wed Dec 27 12:03:33 2017 -0500
+++ b/rmarkdown_samtools_flagstat.Rmd	Wed Dec 27 15:14:47 2017 -0500
@@ -1,5 +1,5 @@
 ---
-title: 'HTML report title'
+title: 'Reads alignment stats'
 output:
     html_document:
       number_sections: true
@@ -16,13 +16,17 @@
 ```
 
 
-# Code for computational analysis
+# Reads alignment stats
 
-```{r 'step 1'}
-command = paste0('samtools flagstat ', opt$input_bam, ' > report.csv')
+```{r 'flagstat'}
+command = paste0('samtools flagstat ', opt$input_bam, ' > ', paste0(opt$report_dir, '/report.txt'))
 system(command)
-read.csv('report.csv')
+df = readLines(paste0(opt$report_dir, '/report.txt')) %>%
+  str_replace('(\\d+\\s+\\+\\s+\\d+)\\s+', '\\1,') %>% 
+  str_split(',') %>% 
+  as.data.frame() %>% t()
+rownames(df) = NULL
+colnames(df) = c('PASS + FAIL', 'Description')
+knitr::kable(df)
 ```
 
-
-