suppressWarnings(library(ggplot2))

x <- read.table("/home/jforment/biovice/internal_projects/240913_fjescmaz_pil/04-manticore/SY05/5_tables/RES.SY05.SY04.whole.txt", header=T)
x$Frac_pos <- as.numeric(as.character(x$Frac_pos))
x$Mean_cov <- as.numeric(as.character(x$Mean_cov))
x <- x[x$Jaccard >= 0 , ]

P1 <- ggplot() + 
theme(plot.title=element_text(family="sans", face="bold", colour="grey20", size=13),
axis.title.x=element_text(family="Helvetica", face="plain", colour="grey20", size=10),
axis.title.y=element_text(family="Helvetica", face="plain", colour="grey20", size=10),
axis.text.x=element_text(family="sans", face="plain", colour="grey20", size=11),
axis.text.y=element_text(family="sans", face="italic", colour="grey20", size=11),
legend.text=element_text(family="sans", face="italic", colour="black", size=9),
legend.title=element_text(family="sans", face="plain", colour="black", size=9),
panel.background=element_rect(fill="grey90", colour="grey90"),
aspect.ratio=0.35) + 
ggtitle("Coverage, SY04, whole") +
xlab("") + 
ylab("Mean coverage [x]") +
geom_violin(data=x, mapping=aes(x=1, y=Mean_cov)) + 
geom_jitter(data=x, mapping=aes(x=3, y=Mean_cov, col=Frac_pos)) + 
scale_x_discrete(breaks=c(1,3), labels=c("","")) +
scale_y_continuous(limits=c(0, 100)) + 
scale_color_gradient2(breaks=seq(0,100,20), limits=c(0,100), low="green3", high="darkorchid4", midpoint=50, name="% covered") +
coord_flip()

basename <- paste("SY05", "cov", "SY04", "whole", sep=".")

svg(paste("/home/jforment/biovice/internal_projects/240913_fjescmaz_pil/04-manticore/SY05/6_plots", "svg", paste(basename, "svg", sep="."), sep="/"))
plot(P1)
dev.off()

png(paste("/home/jforment/biovice/internal_projects/240913_fjescmaz_pil/04-manticore/SY05/6_plots", "png", paste(basename, "png", sep="."), sep="/"), height=400, width=1000, pointsize=11, units="px", type="cairo", res=200)
suppressWarnings(plot(P1))
dev.off()
