library(ggplot2) library(scales) library(wesanderson) library(stringr) args = commandArgs(trailingOnly=TRUE) cbPalette=c("#e4b5ff", "#5edba9") plot <- read.table(args[1], header=F, as.is=T, sep="\t") colnames(plot)<-c('seqTech', 'cap', 'size', 'sample', 'categ','count', 'prop') plot$categ=factor(plot$categ, levels=c("ERCCs", "SIRVs")) plot$seqTech=factor(plot$seqTech, 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(gsub(".tsv", ".pdf", args[1]), bg = "white", width = 70, height = 45) #pdf(gsub(".tsv", ".pdf", args[1]), bg = "white", width = 15, height = 10) ggplot(data=plot, aes(x=categ, y=prop, fill=categ)) + geom_bar(stat="identity") + ylab("Objects") + scale_y_continuous(limits=c(0,0.05), labels=percent)+ theme_bw() + ggtitle(unlist(str_split(args[1], "[.]"))[3]) + scale_fill_manual(values=cbPalette)+ xlab("") + theme(axis.text.x = element_text(size = 30, colour = "black", vjust=0.5), axis.text.y = element_text(size = 30, colour = "black"), legend.text = element_text(size=30), plot.title = element_text(size = 35), legend.title =element_text(size=0, color="white"), axis.title.x = element_text(size = 30), axis.title.y = element_text(size = 30), legend.text.align=0.5, strip.text.x=element_text(size=20), strip.text.y=element_text(size=20)) + theme(legend.position="top") + facet_grid(sample ~ seqTech, scales="free_x") + geom_text(aes(group=categ, y=prop, label = paste(round(prop*100,2), comma(count), sep="\n")), size=7, vjust=0.5) dev.off()