-
Notifications
You must be signed in to change notification settings - Fork 3
/
GAPIT.GS.Visualization.R
executable file
·73 lines (49 loc) · 2.21 KB
/
GAPIT.GS.Visualization.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
`GAPIT.GS.Visualization` <-
function(gsBLUP = gsBLUP, BINS=BINS, name.of.trait = name.of.trait){
#Object: To build heat map to show distribution of BLUP and PEV
#Output: pdf
#Authors: Zhiwu Zhang
# Last update: May 15, 2011
##############################################################################################
nBin=BINS
BLUP= gsBLUP[,5]
PEV = gsBLUP[,6]
if(BLUP[1]=="NaN"){
warning ("It was not converged. BLUP was not created!")
}
if(BLUP[1]!="NaN" )
{
BLUP.max=try(max(BLUP))
BLUP.min=try(min(BLUP))
if(inherits(BLUP.max, "try-error")) return()
range.BLUP=BLUP.max-BLUP.min
range.PEV=max(PEV)-min(PEV)
interval.BLUP=range.BLUP/nBin
interval.PEV=range.PEV/nBin
bin.BLUP=floor(BLUP/max(BLUP)*nBin)*max(BLUP)/nBin
bin.PEV=floor(PEV/max(PEV)*nBin)*max(PEV)/nBin
distinct.BLUP=unique(bin.BLUP)
distinct.PEV=unique(bin.PEV)
if((length(distinct.BLUP)<2) | (length(distinct.PEV)<2) ) return() #nothing to plot
Position.BLUP=match(bin.BLUP,distinct.BLUP,nomatch = 0)
Position.PEV=match(bin.PEV,distinct.PEV,nomatch = 0)
value=matrix(1,length(Position.BLUP))
KG<- (tapply(as.numeric(value), list(Position.BLUP, Position.PEV), sum))
rownames(KG)=round(distinct.BLUP, digits = 4)
colnames(KG)=round(distinct.PEV, digits = 4)
#Sort the rows and columns in order from smallest to largest
rownames(KG) <- rownames(KG)[order(as.numeric(rownames(KG)))]
colnames(KG) <- colnames(KG)[order(as.numeric(colnames(KG)))]
#write.table(KG, "Input_Matrix_for_GS_Heat_Map.txt", quote = FALSE, sep = "\t", row.names = FALSE,col.names = FALSE)
pdf(paste("GAPIT.", name.of.trait,".GPS.BLUPvsPEV", ".pdf", sep = ""),width = 9)
#par(mfrow = c(1,1), mar = c(1,1,5,5), lab = c(5,5,7))
par(mar = c(5,5,6,5))
nba_heatmap <- heatmap(KG, Rowv=NA, Colv=NA, col = rev(heat.colors(256)), scale="column",
xlab = "PEV", ylab = "BLUP", main = " ")
#nba_heatmap <- heatmap.2(KG, cexRow =.2, cexCol = 0.2, scale="none", symkey=FALSE, trace="none" )
#cexRow =0.9, cexCol = 0.9)
dev.off()
}
#print("GAPIT.GS.Visualization accomplished successfully!")
} #GAPIT.GS.Visualization ends here
#=============================================================================================