# NOT RUN {
library(optiSel)
data(map)
data(Cattle)
dir <- system.file("extdata", package = "optiSel")
files <- paste(dir, "/Chr", 1:2, ".phased", sep="")
#####################################################################
# Find the optimum breed composition using segment based kinship #
#####################################################################
IBD <- segIBD(files, minSNP=15, map=map, minL=1.0)
mb <- opticomp(IBD, Breed=Cattle$Breed, obj.fun="NGD")
#### Optimum breed composition: ###
round(mb$bc,3)
# Angler Fleckvieh Holstein Rotbunt
# 0.484 0.395 0.072 0.049
#### Average kinships within and between breeds: ###
round(mb$f,4)
# Angler Fleckvieh Holstein Rotbunt
#Angler 0.0699 0.0171 0.0584 0.0590
#Fleckvieh 0.0171 0.0956 0.0135 0.0138
#Holstein 0.0584 0.0135 0.1233 0.1065
#Rotbunt 0.0590 0.0138 0.1065 0.1227
#### Genetic distances between breeds: ###
round(mb$Dist,4)
# Angler Fleckvieh Holstein Rotbunt
#Angler 0.0000 0.2561 0.1953 0.1930
#Fleckvieh 0.2561 0.0000 0.3098 0.3087
#Holstein 0.1953 0.3098 0.0000 0.1284
#Rotbunt 0.1930 0.3087 0.1284 0.0000
#####################################################################
# The optimum breed composition depends on the kinship matrix #
# and the objective function: #
#####################################################################
bc <- opticomp(IBD, Breed=Cattle$Breed, obj.fun="NTD")$bc
round(bc,3)
# Angler Fleckvieh Holstein Rotbunt
# 0.253 0.433 0.168 0.146
# }
Run the code above in your browser using DataLab