-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPlot_Trace.R
More file actions
47 lines (40 loc) · 1.31 KB
/
Plot_Trace.R
File metadata and controls
47 lines (40 loc) · 1.31 KB
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
args = commandArgs(trailingOnly=TRUE)
source("PolyGraphFunc.R")
file <- args[1]
qfile <- args[2]
phenoname <- args[3]
graphscript <- args[4]
output_boxplot <- args[5]
output_phenograph <- args[6]
output_phenograph_qfile <- args[7]
minbranch <- args[8]
# Load admixture graph
source(graphscript)
if( file != "NA"){
# Load table
table <- read.table(file,header=TRUE)
# Remove burn-in
trace <- table[seq(10,dim(table)[1]-1,1),]
# Make pheno-graph from trace output
pdf(output_phenograph,width = 8, height = 8)
minsel <- -0.3
maxsel <- 0.3
MakeGraphPlot(file,edgevalues,"r",phenoname,minsel,maxsel,minbranch)
dev.off()
}
# Make pheno-graph from qfile output
pdf(output_phenograph_qfile,width = 8, height = 8)
minsel <- -10
maxsel <- 10
MakeGraphPlotQfile(qfile,edgevalues,"r",phenoname,minsel,maxsel,minbranch)
dev.off()
# Make boxplot
if( file != "NA"){
SNPs <- max(sapply(colnames(table),function(x){as.numeric(paste(unlist(strsplit(gsub("[^0-9]", "", x),"")),collapse=""))}),na.rm=TRUE)
titleboxplot <- paste("Posterior distributions of alpha parameters: ",phenoname," (num. SNPs: ",SNPs,")",sep="")
pdf(output_boxplot,width=15,height=5)
finalboxplot <- AlphaBoxPlot(trace,titleboxplot,FALSE,0)
grid.arrange(finalboxplot,ncol=1,nrow=1)
dev.off()
}