forked from Ettwiller/Damage-estimator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_damage_location.R
executable file
·49 lines (31 loc) · 1.33 KB
/
plot_damage_location.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
#!/usr/bin/env Rscript
library(ggplot2)
library(reshape2)
args <- commandArgs(TRUE)
if (length(args)<2) {
stop("At least two argument must be supplied [1] imput_file (output of estimate_damage.pl) and [2] output file (for example figure1.png)", call.=FALSE)
}
argument2 = args[2]
mutation <- read.table(args[1], header=FALSE, sep="")
colnames(mutation) <- c("experiment","type","read","count","abs","loc");
typ = unique(mutation$type)
keep_only <-unique(mutation$experiment)
new_mutation = subset(mutation, experiment %in% keep_only)
new_mutation$experiment <- factor(new_mutation$experiment, level=keep_only)
exp = unique(new_mutation$experiment)
l = length(keep_only)
local_color <- rainbow(l)
for (selected_type in typ)
{
out = paste(selected_type, argument2, sep = "_")
d<-ggplot(subset(new_mutation,type %in% c(selected_type))) +
geom_point(aes(x=loc, y=count, group=experiment, color=experiment, shape=read)) +
facet_grid(~read, scales = "fixed") +
scale_colour_manual(values = local_color) +
theme(panel.background = element_rect(fill = 'white', colour = 'white')) +
#theme(legend.position = "none") +
#scale_x_continuous(limits = c(0, 100)) +
# scale_y_continuous(limits = c(0, 0.013)) +
ggtitle(selected_type)
ggsave(out, d, width=15, height=10)
}