modified: pixi.toml
[GalaxyCodeBases.git] / BioInfo / BS-Seq / bwa-meth / compare / src / plot-quals-bw.R
blobbd9d4eb0c0b4b23432709cbf2daeee8f86d42f2b
1 # make figure 1 from paper
2 options(stringsAsFactors=FALSE)
3 library(ggplot2)
4 args = commandArgs(TRUE)
7 df = read.delim(args[1])
9 df[df$method == "bis2", "method"] = "bismark-bt2"
10 df[df$method == "bis1", "method"] = "bismark-bt1"
11 df[df$method == "bwastrand", "method"] = "bwa-strand"
12 df[df$method == "bwa", "method"] = "bwameth"
14 df[grep("sim_R1", df$method, fixed=TRUE), "method"] = "bison"
15 df[grep("real_R1", df$method, fixed=TRUE), "method"] = "bison"
17 points = c('bismark-bt1', 'bismark-bt2', 'gsnap')
18 df$size = as.numeric(ifelse(df$method %in% points, 1.2, 0.4))
21 df = df[df$qual > 0,]
23 df = df[order(df$qual),]
25 df = df[(df$on + df$off) != 0,]
26 df$on = df$on * 100
27 df$off = df$off * 100
29 require("grid")
32 p = ggplot(df, aes(x=off, y=on, by=method)) +
33          geom_point(aes(shape=method, size=size, linestyle=method)) +
34          scale_size_identity() +
35          scale_shape(solid = FALSE) +
36          guides(size=FALSE, linestyle=FALSE) +
37          geom_line(data=df[!df$method %in% points,], aes(shape=method), size=0.4) +
38          scale_shape(solid = FALSE) +
39          guides(linestyle=FALSE) 
42          #geom_line(aes(linestyle=method), size=1.4) + scale_shape(solid=FALSE)
43          #geom_line(aes(color=method), linetype="dotted") 
44 p = p + ylab("% Reads On Target")
45 p = p + xlab("% Reads Off Target")
46 p = p + theme_bw()
47 p = p + theme(
48              #legend.position = c(0.55, 0.25),
49              legend.position = c(0.75, 0.25),
50               legend.text=element_text(size=6, lineheight=5),
51               axis.text=element_text(size=6),
52               axis.title=element_text(size=8),
53               legend.key.size=unit(6, "mm")
55 #              legend.key.height=5
56               )
57 p = p + guides(shape=guide_legend(ncol=2, title=NULL), size=FALSE, method=FALSE)
58 ggsave(file=args[2], units="cm", width=8.6, height=6.3,
59     dpi=400)