-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_srss.r
executable file
·22 lines (18 loc) · 1023 Bytes
/
plot_srss.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env Rscript
## USAGE:
## ./plot_srss.r /my/folder/with/snptable spl1,spl2,spl3
## Script requires the folder that contains the snptable.tsv file. No trailing '/'. Second argument is the individual ID(s) that shall be plotted. Several IDs should be separated by ','.
## Output will be written to input folder: site_read_support_spectrum_ID.pdf
args = commandArgs(trailingOnly=TRUE)
folder=args[1]
colIDs=args[2]
d=read.table(paste(folder,'snpTable.tsv',sep="/"),header=T,stringsAsFactors=F,sep="\t",check.names = FALSE)
colIDs <- strsplit(colIDs,",")[[1]]
for (colID in colIDs){
d2 <- as.numeric(gsub("\\(|\\)","",substring(grep(" ",d[,colID],invert=F,value=T),3)))/100
d3 <- d2[ d2 != 1 ]
pdf(paste(folder,'/site_read_support_spectrum_',colID,".pdf",sep=""))
hist(d3,xlim=c(0,1),main=paste(colID,": SNPs w/o 100% read support",sep="") ,xlab="read support",col='grey',ylab='# SNPs')
legend('topleft',legend=c(paste('All Sites:',length(d2)),paste('Var Sites:',length(d3))))
dev.off()
}