-
Notifications
You must be signed in to change notification settings - Fork 0
/
subScriptPlotting
46 lines (43 loc) · 1.72 KB
/
subScriptPlotting
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
#!/usr/bin/env Rscript
# Embedded R script for domain plotting
pdf(NULL)
args <- commandArgs(TRUE)
TABLE <- args[1]
OUTPLOT <- args[2]
if (!isTRUE(suppressMessages(suppressWarnings(require(ggplot2))))) {
stop("The package 'ggplot2' was not found, plotting will not be performed. You can use the DomainCoordinates.txt file to plot externally", call. = F)
}
if (!isTRUE(suppressMessages(suppressWarnings(require(dplyr))))) {
stop("The package 'dplyr' was not found, plotting will not be performed. You can use the DomainCoordinates.txt file to plot externally", call. = F)
}
tabella <- read.delim(TABLE, sep = '\t', header = T)
if (nrow(tabella) == 0){
stop("No Domains found in supplied fasta.", call. = F)
}
tabella %>%
distinct() %>%
mutate(Start = as.numeric(as.character(Start)),
End = as.numeric(as.character(End)),
geneLength = as.numeric(as.character(geneLength)),
MidPoint = (Start+End)/2) %>%
ggplot()+
geom_segment(aes(y=geneName, yend = geneName,
x=1 , xend = geneLength))+
geom_rect(aes(xmin = Start, xmax = End,
ymin = as.numeric(geneName)-0.2, ymax = as.numeric(geneName)+0.2,
fill = Domain),
color = 'black')+
geom_text(aes(y=geneName, x = MidPoint, label = Domain),
size = 4,
position=position_jitter(width=0,height=0))+
theme_minimal()+
theme(panel.grid = element_blank(),
axis.text = element_text(color = 'black'))+
labs(y = '',
x = '') +
theme(legend.position="none",
axis.text.y = element_text(size = 10),
)
Hplot <- nrow(tabella)*0.1
Hplot <- ifelse(Hplot <= 30, 30, Hplot)
suppressMessages(suppressWarnings(ggsave(OUTPLOT, width = 30, height = Hplot, limitsize = FALSE)))