# NOT RUN {
data(Ped_griffin)
# find all relatives of a specific individual
Rel42 <- GetRelCat("i042_2003_F", Ped_griffin)
Rel42[Rel42 != "U"]
# make NxN matrix with relationship categories:
Ped_griffin_sub <- Ped_griffin[Ped_griffin$birthyear<2003,] # quicker
RCM <- sapply(seq_along(Ped_griffin_sub$id), GetRelCat, Ped_griffin_sub)
table(RCM)
# M MHS O P S U
# 10 6 16 6 40 1522
# note that sibling & cousin pairs are counted twice!
# Parent-offspring pairs are counted directionally:
# once as offspring (O), once as mother (M) or father (P)
# for large pedigrees, table(factor()) is much faster:
table(factor(RCM, levels=c("M","P","FS","MHS","PHS","U")))
# list the maternal half-siblings:
these <- which(RCM=="MHS", arr.ind=TRUE)
data.frame(id1 = Ped_griffin_sub$id[these[,1]],
id2 = Ped_griffin_sub$id[these[,2]])
# Get Colony-style lists of full sibs & half sibs dyads:
# }
# NOT RUN {
RCM <- sapply(seq_along(MyPedigree$id), GetRelCat, Pedigree = MyPedigree,
GenBack = 1, patmat = FALSE)
# rownumbers of pairs of FS & HS
FullSibDyads <- which(RCM == "FS", arr.ind=TRUE)
HalfSibDyads <- which(RCM == "HS", arr.ind=TRUE)
# each pair is listed 2x - fix:
FullSibDyads <- FullSibDyads[FullSibDyads[,1] < FullSibDyads[,2], ]
HalfSibDyads <- HalfSibDyads[HalfSibDyads[,1] < HalfSibDyads[,2], ]
# translate rownumbers into IDs
MyPedigree$id <- as.character(MyPedigree$id)
FullSibDyads <- cbind(MyPedigree$id[FullSibDyads[,1]],
MyPedigree$id[FullSibDyads[,2]])
HalfSibDyads <- cbind(MyPedigree$id[HalfSibDyads[,1]],
MyPedigree$id[HalfSibDyads[,2]])
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab