library(ggplot2) library(purrr) library(scales) library(wesanderson) library(dplyr) library(data.table) args = commandArgs(trailingOnly=TRUE) cbPalette=c("#a6a6a6","#b3e0ff","#C453C4","#e5b3e5") #lengths = fread(paste0("/users/rg/tperteghella/CapTrapPaper/read_lengths_benchmark/all_mapped/benchmark.readlength.",args[1],".finite.tsv")) #colnames(lengths) = c("id","platform","capture","frac","sample","length") #files = list.files("/users/rg/tperteghella/CapTrapPaper/completeness_read_level_benchmark/tmp/", pattern=paste0("*",args[1],"*"), full.names = T) %>% map_dfr(readRDS) #data = merge(files, lengths, by="id") #bins = seq(0, 3000, by = 200) #data$binned = cut(as.numeric(data$length), breaks=bins,include.lowest=T) #saveRDS(data, paste0(args[1], ".altogether.info.rds")) data = readRDS(paste0(args[1], ".altogether.info.rds")) data = data %>% filter( !sirvs & !is.na(data$length)) data$categ = factor(data$categ, levels=c("noCageNoPolyA", "polyAOnly", "cageAndPolyA", "cageOnly")) data$platform = factor(data$platform, levels=c("ont-Crg-CapTrap","ont-Crg-dRNA","ont-Crg-Smarter","ont-Crg-Telop","ont-Cshl-CapTrap","ont-Cshl-dRNA","ont-Cshl-Smarter","pacBio-Cshl-CapTrap","pacBio-Cshl-Smarter","pacBioSII-Cshl-CapTrap")) pdf(paste0(args[1], ".binned.completeness.pdf"), bg = "white", width=70, height=100) ggplot(data=data, aes(x=binned, fill=categ)) + geom_bar(position = "fill") + scale_y_continuous(limits=c(0,1.05), labels=percent) + ylab(" Proportion of reads") + theme_bw() + ggtitle(args[1]) + scale_fill_manual(values=cbPalette)+ xlab("") + theme(axis.text.x = element_text(size = 30, colour = "black", vjust=0.5, angle = 90, hjust=1), axis.text.y = element_text(size = 30, colour = "black", vjust=0.5), legend.text = element_text(size=30), plot.title = element_text(size = 30), legend.title =element_text(size=0, color="white"), axis.title.x = element_text(size = 14), axis.title.y = element_text(size = 14), legend.text.align=0.5, strip.text.x=element_text(size=40), strip.text.y=element_text(size=40))+ theme(legend.position="top") + facet_grid( sample ~ platform, scales="free_x") dev.off()