comparison 2_per_base_N_content.Rmd @ 0:d732d4526c6d draft

planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_fastqc_site commit ddb1f6aca7619aea2e660b1729367841b56ba4c9-dirty
author mingchen0919
date Tue, 08 Aug 2017 10:14:46 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:d732d4526c6d
1 ---
2 title: "Per Base N Content"
3 output: html_document
4 ---
5
6 ```{r setup, include=FALSE, warning=FALSE, message=FALSE}
7 knitr::opts_chunk$set(echo = ECHO)
8 ```
9
10 ## Per Base N Content
11
12 ```{r}
13 PBNC_df = data.frame()
14 PBNC_file_paths = read.csv('PBNC_file_paths.txt',
15 header = TRUE, stringsAsFactors = FALSE)
16 for(i in 1:nrow(PBNC_file_paths)) {
17 # file_path = paste0('REPORT_OUTPUT_DIR/', PBNC_file_paths[i,2])
18 file_path = PBNC_file_paths[i,2]
19 pbnc_df = read.csv(file_path,
20 sep='\t', header=TRUE, stringsAsFactors = FALSE) %>%
21 mutate(Base1=as.numeric(str_split_fixed(X.Base, '-', 2)[,1]),
22 Base2=as.numeric(str_split_fixed(X.Base, '-', 2)[,2])) %>%
23 (function (df) {
24 df1 = select(df, -Base2)
25 df2 = select(df, -Base1) %>% filter(Base2 != '')
26 colnames(df1) = c(colnames(df1)[1:2], 'Base')
27 colnames(df2) = c(colnames(df2)[1:2], 'Base')
28 res = rbind(df1, df2) %>% arrange(Base)
29 return(res)
30 })
31 pbnc_df$sample_id = rep(PBNC_file_paths[i,1], nrow(pbnc_df))
32 PBNC_df = rbind(PBNC_df, pbnc_df)
33 }
34 ```
35
36
37 ```{r}
38 PBNC_df$N.Count = PBNC_df$N.Count * 100
39 max_phred = max(PBNC_df$N.Count) + 5
40 hchart(PBNC_df, "line", hcaes(x = as.character(Base), y = N.Count, group = sample_id)) %>%
41 hc_title(
42 text = "Per Base N Content"
43 ) %>%
44 hc_xAxis(
45 title = list(text = "Base Position")
46 ) %>%
47 hc_yAxis(
48 title = list(text = "N %"),
49 plotLines = list(
50 list(label = list(text = "N = 5%"),
51 width = 2,
52 dashStyle = "dash",
53 color = "red",
54 value = 5)
55 )
56 ) %>%
57 hc_exporting(enabled = TRUE)
58 ```