/
plot-link-counts-threeway.R
executable file
·62 lines (46 loc) · 1.89 KB
/
plot-link-counts-threeway.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env Rscript --vanilla
# Isaac Turner 2017-02-16
args <- commandArgs(trailingOnly=TRUE)
if(length(args) != 4) {
stop("Usage: ./plot-link-counts.R <linkcounts.pdf> <perfect.csv> <stoch.csv> <stocherr.csv>\n")
}
plot_path <- "latest/linkcounts.se.pdf"
perf_path <- "latest/perfect.linkcounts.se.csv"
stoch_path <- "latest/stoch.linkcounts.se.csv"
error_path <- "latest/stocherr.linkcounts.se.csv"
plot_path = args[1]
perf_path <- args[2]
stoch_path <- args[3]
error_path <- args[4]
a <- read.table(perf_path, sep='\t',head=T,comment.char='#',as.is=T)
b <- read.table(stoch_path, sep='\t',head=T,comment.char='#',as.is=T)
c <- read.table(error_path, sep='\t',head=T,comment.char='#',as.is=T)
nlinkkmers_ylim <- ceiling(max(a$n_link_kmers, b$n_link_kmers, c$n_link_kmers))
kmers <- a$K
# * joins with no spaces, ~ joins with a space
xlabel = expression(italic('k'))
ylabel = expression('no. of '*italic('k')*'mers with links (log)')
pdf(plot_path, width=6, height=6)
# Remove empty title space
par(mar=c(4,5,2,2)+0.1) # set margins: bottom, left, top and right
par(xpd=TRUE)
legend_labels <- c("perfect", "stochastic", "error")
cols <- c('#1b9e77', '#d95f02', '#7570b3') # from color brewer
pnts <- c(19,4,17) # point styles pch=
jf <- 0.2 # jitter factor
lt <- 2 # line thickness
plot(1, type='n', bty="n", xlab='', ylab='', log='y',
xlim=c(20,100), ylim=c(1,nlinkkmers_ylim), axes=F)
points(jitter(a$K,jf), a$n_link_kmers, type='b', lwd=lt, pch=pnts[1], col=cols[1], lty=1)
points(jitter(b$K,jf), b$n_link_kmers, type='b', lwd=lt, pch=pnts[2], col=cols[2], lty=1)
points(jitter(c$K,jf), c$n_link_kmers, type='b', lwd=lt, pch=pnts[3], col=cols[3], lty=1)
mtext(side=1, text=xlabel, line=2)
mtext(side=2, text=ylabel, line=4)
axis(1, at=a$K)
axis(2, las=2)
par(xpd=TRUE)
legend("topright", bty="n", inset=c(0.2,0),
legend=legend_labels,
col=cols, lwd=lt, lty=c(1,1,1),
pch=pnts)
dev.off()