-
Notifications
You must be signed in to change notification settings - Fork 1
/
IV-A_coverage.R
executable file
·32 lines (27 loc) · 1.11 KB
/
IV-A_coverage.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
library(tidyverse)
selected_cols <- cols_only(position = col_integer(), coverage = col_integer(),
segment = col_integer(), molis = col_integer())
data_path <- '/Volumes/analyses/Diagnostics/experiments/tables-190626_IV-A'
files <- dir(path = data_path, pattern = "*.csv")
# create a data frame holding the file names
data <- tibble(filename = files) %>%
# a new data column
mutate(file_contents = map(filename, ~ read_csv(file.path(data_path, .),
col_types = selected_cols))) %>%
separate(filename, c('molis', 'segment', 'ext'))
#coverage_avg <- data %>%
# unnest() %>%
# group_by(molis, segment) %>%
# summarise(avg = round(mean(coverage), 1)) %>%
# write_csv(paste0(data_path, '/cov_average.csv'))
for (molis_nr in unique(data$molis)){
print(molis_nr)
p <- data %>%
filter(molis == molis_nr) %>%
unnest() %>%
ggplot(aes(x = position, y = coverage)) +
geom_bar(stat = 'identity') +
facet_wrap(~ segment, scales = "free") +
labs(caption = molis_nr)
ggsave(paste0('covplot-', molis_nr, '.pdf'), path = data_path)
}