annotate rmarkdown_samtools_flagstat.Rmd @ 4:1723d63c7d95 draft

update
author mingchen0919
date Fri, 29 Dec 2017 21:22:21 -0500
parents 77e8e7bc5b44
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
mingchen0919
parents:
diff changeset
1 ---
mingchen0919
parents:
diff changeset
2 title: 'Reads alignment stats'
mingchen0919
parents:
diff changeset
3 output:
mingchen0919
parents:
diff changeset
4 html_document:
mingchen0919
parents:
diff changeset
5 number_sections: true
mingchen0919
parents:
diff changeset
6 toc: true
mingchen0919
parents:
diff changeset
7 theme: cosmo
mingchen0919
parents:
diff changeset
8 highlight: tango
mingchen0919
parents:
diff changeset
9 ---
mingchen0919
parents:
diff changeset
10
mingchen0919
parents:
diff changeset
11 ```{r setup, include=FALSE, warning=FALSE, message=FALSE}
mingchen0919
parents:
diff changeset
12 knitr::opts_chunk$set(
mingchen0919
parents:
diff changeset
13 echo = ECHO,
mingchen0919
parents:
diff changeset
14 error = TRUE
mingchen0919
parents:
diff changeset
15 )
mingchen0919
parents:
diff changeset
16 ```
mingchen0919
parents:
diff changeset
17
mingchen0919
parents:
diff changeset
18
mingchen0919
parents:
diff changeset
19 # Reads alignment stats on `r opt$input_bam_name`
mingchen0919
parents:
diff changeset
20
mingchen0919
parents:
diff changeset
21 ```{r 'flagstat'}
mingchen0919
parents:
diff changeset
22 command = paste0('samtools flagstat ', opt$input_bam, ' > ', paste0(opt$report_dir, '/report.txt'))
mingchen0919
parents:
diff changeset
23 system(command)
mingchen0919
parents:
diff changeset
24 df = readLines(paste0(opt$report_dir, '/report.txt')) %>%
mingchen0919
parents:
diff changeset
25 str_replace('(\\d+\\s+\\+\\s+\\d+)\\s+', '\\1,') %>%
mingchen0919
parents:
diff changeset
26 str_split(',') %>%
mingchen0919
parents:
diff changeset
27 as.data.frame() %>% t()
mingchen0919
parents:
diff changeset
28 rownames(df) = NULL
mingchen0919
parents:
diff changeset
29 colnames(df) = c('PASS + FAIL', 'Description')
mingchen0919
parents:
diff changeset
30 knitr::kable(df)
mingchen0919
parents:
diff changeset
31 ```
mingchen0919
parents:
diff changeset
32