-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlot hybrid Triangle
55 lines (42 loc) · 1.69 KB
/
Plot hybrid Triangle
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
#-------------------------------------------------------------------------------
# This script performs hybrid index estimation with introgress (Gompert & Buerkle 2010).
#-------------------------------------------------------------------------------
# Install dependencies
install.packages("introgress",dependencies=TRUE)
library(introgress)
## produce triangle plots
#
## use prepare.data to produce introgress.data
introgress.data<-prepare.data(admix.gen=AdmixDataSim1,
loci.data=loci.data,
parental1="P1", parental2="P2",
pop.id=FALSE, ind.id=TRUE,
fixed=TRUE)
## estimate hybrid index
hi.index<-est.h(introgress.data=introgress.data,
loci.data=loci.data, fixed=TRUE, p1.allele="P1",
p2.allele="P2")
## Estimate interspecific heterozygosity
int.het<-calc.intersp.het(introgress.data=hybrid.index)
## make plot
triangle.plot(hi.index=hi.index, int.het=int.het, pdf=FALSE)
#######Plotting triange plot raw code
hi.index=hybrid.index
int.het=int.het
hi.index<-hi.index[,2]
hi.index$Colour="black"
hi.index$Colour[hi.index$h>=0.5]="red"
hi.index$Colour[hi.index$h<=0.5]="blue"
# plot
plot(data$col_name1,data$col_name2, ylim=c(0,5), col=data$Colour, ylim=c(0,10))
plot(hi.index$h,int.het,xlab="Hybrid index",ylab="Interspecific heterozygosity",xlim=c(0,1),ylim=c(0,1),pch=19, col=hi.index$Colour, cex=1.5)
lines(c(0,0.5),c(0,1),lwd = 2)
lines(c(0.5,1),c(1,0),lwd = 2)
text(0.5,0.15,"Historical Introgression")
text(0.5,0.9,"F1")
text(0.5,0.52,"F2")
text(0.2,0.65,"Bx P1")
text(0.8,0.65,"Bx P2")
#Parental
text(0.1,0.02,"P1 S.cinereus")
text(0.9,0.02,"P2 S.ugyunak")