suppressWarnings(library(ggplot2))

x <- read.table("/home/jforment/biovice/internal_projects/240913_fjescmaz_pil/04-manticore/SY05/5_tables/RES.SY05.wt.whole.txt", header=T)

P1 <- ggplot(data=x, mapping=aes(x=Jaccard))+ 
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.15) + 
ggtitle("SY05, whole") +
xlab("Jaccard index [0,1]") +
ylab("%") +
geom_histogram(mapping=aes(y= ..count.. / sum(..count..) * 100), binwidth=0.1, color="grey50", fill="#FFEBCC") +
geom_vline(xintercept=mean(as.numeric(as.character(x[x$Jaccard >= 0 , ]$Jaccard))), color="#562A72", size=0.5) +
scale_x_continuous(limits=c(-0.16,1.06), breaks=seq(-0.1,1,0.1),
        labels=c("NA", seq(0,1,0.1))) +
scale_y_continuous()

basename <- paste("SY05", "jac", "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=300, width=1000, pointsize=11, units="px", type="cairo", res=200)
suppressWarnings(plot(P1))
dev.off()
