load packages
require(ggplot2)
## Loading required package: ggplot2
require(stringr)
## Loading required package: stringr
require(plyr)
## Loading required package: plyr
suppressPackageStartupMessages(require(dplyr))
Plot code
## plot without Will be resequenced.
Will_be_resequenced <- read.delim("~/Projects/impute_to_Sequence/Sequencing_96_samples/Will_be_resequenced.txt",
header=FALSE, stringsAsFactors=FALSE)
x <- read.table("~tikn/Projects/impute_to_Sequence/Sequencing_96_samples/all_samples_with_frag_count_without_will_be_resequenced.txt",
stringsAsFactors = F, sep = "\t") %>% tbl_df()
x$V2 <- as.integer(str_replace_all(x$V2, pattern = ",", "")) ## remove , from file.
x2 <- arrange(x, V1)
x3 <- mutate(x2, bases = V2 * 125)
x3$Sample <- as.integer(stringr::str_extract(x3$V1, "^[0-9]{1,2}")) # pull out Sample number to column Sample
df1 <- mutate(x3, lane = str_extract(V1, "L[\\d]{3}"),
read = str_extract(V1, "R[12]{1}")) %>%
filter(read == "R1") %>%
mutate(yield = bases*2)
to_show <- seq(1,96)
to_plot <- split(to_show, ceiling(seq_along(to_show)/16))
names(to_plot) <- paste("Part", seq(1,6,1), sep = "")
yield_plot <- function(x) {
ggplot(data = filter(df1, Sample %in% x), aes(factor(Sample), yield/1e9, fill = lane)) +
geom_bar(stat = "identity", position = "dodge") +
theme_light() +
scale_fill_brewer(type="qual") +
# facet_wrap(~project, nrow = 2) +
xlab("Sample") + ylab("billion reads")
}
llply(to_plot, yield_plot)
## $Part1
##
## $Part2
##
## $Part3
##
## $Part4
##
## $Part5
##
## $Part6