# NOT RUN {
# # Simulation of a two-way crossbreeding program.
# The crossbreeding scheme in this example involves three steps:
#Step 1: Historical population is created.
#Step 2: Two recent populations named as Breed A and B
# are created by sampling individuals from historical population.
#Step 3: Breed A and B are crossed.
#--------------------------------------
# # STEP 1: CREATE HISTORICAL POPULATION
# Genome consisted of 3 chromosomes
genome<-data.frame(matrix(NA, nrow=3, ncol=6))
names(genome)<-c("chr","len","nmrk","mpos","nqtl","qpos")
genome$chr<-c(1:3)
genome$len<-rep(100,3)
genome$nmrk<-rep(100,3)
genome$mpos<-rep('rnd',3)
genome$nqtl<-rep(25,3)
genome$qpos<-rep('rnd',3)
genome
historical<-make_hp(hpsize=300
,ng=10,h2=0.25,d2=0.10,phen_var=1
,genome=genome,mutr=5*10**-4,laf=0.5)
# # STEP 2: MAKE BREED A AND B
# BREED A
Breed_A_Male_fndrs<-data.frame(number=50,select='rnd')
Breed_A_Female_fndrs<-data.frame(number=50,select='rnd')
# Selection and matings in Breed A
# Selection of 50 sires and 50 dam
# Selection criteria is "rnd" for both sires and dams
Selection<-data.frame(matrix(NA, nrow=2, ncol=2))
names(Selection)<-c("Number","type")
Selection$Number[1:2]<-c(50,50)
Selection$type[1:2]<-c("rnd","rnd")
Selection
Breed_A<-sample_hp(hp_out=historical,Male_founders=
Breed_A_Male_fndrs,Female_founders=Breed_A_Female_fndrs,
ng=5,Selection=Selection,
litter_size=3,Display=TRUE)
# BREED B
Breed_B_Male_fndrs<-data.frame(number=50,select="rnd")
Breed_B_Female_fndrs<-data.frame(number=50,select="rnd")
# Selection and matings in Breed B
# Selection of 50 sires and 50 dam
# Selection criteria is "phen" for both sires and dams
Selection<-data.frame(matrix(NA, nrow=2, ncol=3))
names(Selection)<-c("Number","type","Value")
Selection$Number[1:2]<-c(50,50)
Selection$type[1:2]<-c("phen","phen")
Selection$Value[1:2]<-c("h","h")
Selection
Breed_B<-sample_hp(hp_out=historical,Male_founders=
Breed_B_Male_fndrs,Female_founders=Breed_B_Female_fndrs,
ng=5,Selection=Selection,
litter_size=3,Display=TRUE)
# # STEP 3: CROSSING BETWEEN BREED A AND B
# Selection of founders in crossbreeding for Breed A
# Selection of 50 sires and 50 dams
# from last generation of pop in step 2.
# Selection criteria is "rnd" for both sires and dams
founder_pop1<-data.frame(matrix(NA, nrow=2, ncol=3))
names(founder_pop1)<-c("size","generation","select")
founder_pop1[1,]<-c(50,5,"rnd")
founder_pop1[2,]<-c(50,5,"rnd")
founder_pop1
# Selection of founders in crossbreeding for Breed B
# Selection of 40 sires and 40 dams
# Selection criteria is "phen" for sires
# Selection criteria is "rnd" for dams
founder_pop2<-data.frame(matrix(NA, nrow=2, ncol=4))
names(founder_pop2)<-c("size","generation","select","value")
founder_pop2[1,]<-c(40,5,"phen","h")
founder_pop2[2,]<-c(40,5,"rnd","h") # "h" will be ignored as SC is "rnd"
founder_pop2
# Selection of animals from founder_pop1 and founder_pop2 to be crossed
founder_cross<-data.frame(matrix(NA, nrow=2, ncol=4))
names(founder_cross)<-c("pop","size","select","value")
founder_cross[1,]<-c("pop1",35,"tbv","h") # Select males from Breed A
founder_cross[2,]<-c("pop2",40,"phen","h") # Select females from Breed B
founder_cross
# Selection scheme in Breed A to produce purebred replacement animals
Selection_pop1<-data.frame(matrix(NA, nrow=2, ncol=3))
names(Selection_pop1)<-c("Number","type","Value")
Selection_pop1$Number[1:2]<-c(70,70)
Selection_pop1$type[1:2]<-c("tbv","tbv")
Selection_pop1$Value[1:2]<-c("h","h")
Selection_pop1
# Selection scheme in Breed B to produce purebred replacement animals
Selection_pop2<-data.frame(matrix(NA, nrow=2, ncol=3))
names(Selection_pop2)<-c("Number","type","Value")
Selection_pop2$Number[1:2]<-c(40,40)
Selection_pop2$type[1:2]<-c("phen","phen")
Selection_pop2$Value[1:2]<-c("h","h")
Selection_pop2
# Selection scheme for crossing between A and B
Cross_design<-data.frame(matrix(NA, nrow=2, ncol=4))
names(Cross_design)<-c("pop","size","select","value")
Cross_design[1,]<-c("pop1",50,"phen","h")
Cross_design[2,]<-c("pop2",100,"phen","h")
Cross_design
# Save data for crossbred AB
output_cross<-data.frame(matrix(NA, nrow=1, ncol=1))
output_cross[,1]<-c(1)
output_cross
cross_AB<-xbreed(pop1=Breed_A,pop2=Breed_B,founder_pop1=
founder_pop1,founder_pop2=founder_pop2,
founder_cross=founder_cross,
Selection_pop1=Selection_pop1,Selection_pop2=Selection_pop2,
Cross_design=Cross_design,ng=2,litter_size=4,
saveAt="cross_pop",output_cross=output_cross,Display=TRUE)
# }
Run the code above in your browser using DataLab