forked from philippinespire/pire_fq_gz_processing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_read_length.R
executable file
·69 lines (57 loc) · 1.41 KB
/
plot_read_length.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#### Plot Read Length Distribution ####
## Take the output of read_length_counter.sh and visualize in a barplot.
## Kevin Labrador
#######################################
#### INITIALIZATION ####
# Delete all
rm(list=ls())
# Set working directory
setwd(dirname(rstudioapi::getActiveDocumentContext()$path))
# Load Libraries
pacman::p_load (
tidyverse,
janitor
)
#### USER DEFINED VARIABLES ####
# Change input and output file names
inFilePath <- "./read-length-distribution_fp1.txt"
outFilePath <- "./barplot_read-length-distribution.png"
#### READ IN DATA AND CURATE ####
df <-
read.table(inFilePath,
sep = "\t",
header = T
) %>%
mutate (filename = File,
library_id = str_extract(filename, "([^/]+)-[^-.]+"),
read = str_extract(filename, "r\\d")
) %>%
select (- File
) %>%
clean_names
#### VISUALIZE ####
(p1 <-
ggplot (df,
aes (x=read_length,
y = frequency,
fill=read)
) +
geom_col(alpha=0.5,
col="black") +
facet_grid(read~library_id) +
guides (fill = "none") +
# xlim (100, 151) +
theme_bw() +
theme (axis.text.x = element_text(angle=45,
hjust=1,
vjust=1)
)
)
# Save output
ggsave (p1,
filename = outFilePath,
width = 10,
height = 7,
units = "in"
)
#### END ####