library(ggplot2) library(plyr) args = commandArgs(trailingOnly=TRUE) lm_eqn = function(plot) { m = lm(count ~ conc, plot); eq <- substitute(italic(y) == a + b %.% italic(x)*","~~italic(R)^2~"="~r2, list(a = format(coef(m)[1], digits = 2), b = format(coef(m)[2], digits = 2),r2 = format(summary(m)$r.squared, digits = 3))) as.character(as.expression(eq)); } cbPalette <- c("#22635b", "#87bd5b") plot <- read.table(args[1], header=F, as.is=T, sep="\t") colnames(plot)<-c("lab","plat", "spikeIn","count", "conc", "type", "category") plot$count[plot$count == 0] <-0.0001 plot$count=log10(plot$count) plot$conc=log10(plot$conc) forE=plot[plot$count > -2.5,] finalE=forE[forE$conc > -2.5,] pdf(gsub(".tsv",".pdf",args[1]), bg = "white", width = 7, height = 7) ggplot(plot, aes(x=conc, y=count, colour=type)) + geom_point(size=5, shape=19, alpha=0.6)+ scale_color_manual(values=cbPalette) + theme_bw() + xlim(-4,5) + ylim(-4,5) + xlab("log10(Spike-In concentration)") + ylab ("log10(#reads + 0.0001)") + theme(axis.text.x = element_text(size = 16, colour = "black"), axis.text.y = element_text(size = 16, colour = "black"), legend.text = element_text(size=18), plot.title = element_text(size = 22), legend.title =element_text(size=0, color="white"), axis.title.x = element_text(size = 18), axis.title.y = element_text(size = 18), legend.text.align=0.5, strip.text.x=element_text(size=22), strip.text.y=element_text(size=22)) + theme(legend.position="top") + ggtitle('') + facet_wrap(~ category, ncol=1, scales="free") + geom_smooth(data=finalE,method=lm,se=FALSE,fullrange=TRUE, size=1.5) dev.off()