comparison rmarkdown_samtools_flagstat.Rmd @ 4:ec39bfeaf496 draft

update
author mingchen0919
date Wed, 27 Dec 2017 15:14:47 -0500
parents a0f0effea707
children 1c16536c70f5
comparison
equal deleted inserted replaced
3:106ab5f33970 4:ec39bfeaf496
1 --- 1 ---
2 title: 'HTML report title' 2 title: 'Reads alignment stats'
3 output: 3 output:
4 html_document: 4 html_document:
5 number_sections: true 5 number_sections: true
6 toc: true 6 toc: true
7 theme: cosmo 7 theme: cosmo
14 error = TRUE 14 error = TRUE
15 ) 15 )
16 ``` 16 ```
17 17
18 18
19 # Code for computational analysis 19 # Reads alignment stats
20 20
21 ```{r 'step 1'} 21 ```{r 'flagstat'}
22 command = paste0('samtools flagstat ', opt$input_bam, ' > report.csv') 22 command = paste0('samtools flagstat ', opt$input_bam, ' > ', paste0(opt$report_dir, '/report.txt'))
23 system(command) 23 system(command)
24 read.csv('report.csv') 24 df = readLines(paste0(opt$report_dir, '/report.txt')) %>%
25 str_replace('(\\d+\\s+\\+\\s+\\d+)\\s+', '\\1,') %>%
26 str_split(',') %>%
27 as.data.frame() %>% t()
28 rownames(df) = NULL
29 colnames(df) = c('PASS + FAIL', 'Description')
30 knitr::kable(df)
25 ``` 31 ```
26 32
27
28