#example haplohh object (280 haplotypes, 1424 SNPs)
#see ?haplohh_cgu_bta12 for details
data(haplohh_cgu_bta12)
#computing shared haplotype lengths around the marker "F1205400"
#which displays a strong signal of selection
m <- calc_pairwise_haplen(haplohh_cgu_bta12, mrk = "F1205400")
#note that calc_haplen() returns the length of the longest shared haplotype:
f <- calc_furcation(haplohh_cgu_bta12, mrk = "F1205400")
h <- calc_haplen(f)
#all pairwise shared haplotype lengths to the left of the focal marker
m_left <- calc_pairwise_haplen(haplohh_cgu_bta12, mrk = "F1205400", side = "left")
#get for each chromosome the maximum shared haplotype length
max_left <- apply(m_left, 1, max)
all.equal(max_left, h$position - h$haplen$MIN, check.attributes = FALSE)
#the same for shared haplotypes to the right of the focal marker
m_right <- calc_pairwise_haplen(haplohh_cgu_bta12, mrk = "F1205400", side = "right")
max_right <- apply(m_right, 1, max)
all.equal(max_right, h$haplen$MAX - h$position, check.attributes = FALSE)
Run the code above in your browser using DataLab