-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotting_TE-piRNAs.R
53 lines (46 loc) · 1.37 KB
/
plotting_TE-piRNAs.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
### this script is to plot the abundance of piRNA 5' and 3' ends across the transposon sequence
### it is designed to be used in a bash script with the command 'Rscript'
### get in variables from bash
args = commandArgs(TRUE);
argmat = sapply(strsplit(args, "="), identity)
for (i in seq.int(length=ncol(argmat))) {
assign(argmat[1, i], argmat[2, i])
}
### R libraries
library(reshape2)
pdf.options(useDingbats = FALSE)
### import the count table
v=c(DIRECTORY,"/",LIB,"_",TE,"_3MM_mappers.counts")
vname=paste(v,collapse="")
table=read.table(vname,header=F)
table_d <- dcast(table,V1~V3, value.var="V2")
### barplot
scale=max(table[,2])
widthw=as.numeric(LENGTH)/1000*20
p=c(DIRECTORY,"/",LIB,"_",TE,"_3MM_mappers.pdf")
pname=paste(p,collapse="")
m=c(LIB," ",TE," 3MM piRNAs >22nt, black: plus_5end, gray: plus_3end, red: minus_5end, pink: minus_3end")
mains=paste(m,collapse="")
pdf(file=pname,width=widthw,height=7)
barplot(table_d$plus_5end,
main=mains,
ylim=c(-scale,scale),
col="black",
border=NA)
abline(h=0)
par(new=TRUE)
barplot(table_d$plus_3end,
ylim=c(-scale,scale),
col="gray",
border=NA)
par(new=TRUE)
barplot(-table_d$minus_5end,
ylim=c(-scale,scale),
col="red",
border=NA)
par(new=TRUE)
barplot(-table_d$minus_3end,
ylim=c(-scale,scale),
col="pink",
border=NA)
dev.off()