library(MoBPS) library(MoBPSmaps) population <- creating.diploid(map=MoBPSmaps::map_cattle3, nindi= 2436, sex.s = c(rep(1, 250), rep(2, 2186)), genotyped.s =c(rep(1, 250), rep(0, 2186)) ) population <- creating.trait(population, n.additive = rep(500,5), mean.target = 100, var.target = 12^2, trait.name = c("RZM (Milk)", "RZE (exterior)", "RZR (fertility)", "RZS (somatic cell)", "RZKM (calving)"), shuffle.traits = 1:5, shuffle.cor = matrix(c(1, 0, -0.25, -0.05, -0.05, 0, 1, 0.1, 0.2, 0, -0.25, 0.1, 1, 0.2, 0.25, -0.05, 0.2, 0.2, 1, 0.1, -0.05, 0, 0.25, 0.1, 1), ncol=5), new.residual.correlation = matrix(c(1, 0, -0.25, -0.05, -0.05, 0, 1, 0.1, 0.2, 0, -0.25, 0.1, 1, 0.2, 0.25, -0.05, 0.2, 0.2, 1, 0.1, -0.05, 0, 0.25, 0.1, 1), ncol=5)) population <- breeding.diploid(population, heritability = c(0.3, 0.25, 0.02, 0.15, 0.05), repeatability = c(0.5, 0.25, 0.06, 0.22, 0.09)) ## Setting up of phenotyping_classes pheno <- list() pheno_matrix <- matrix(c(0,0,0,0,0, 0,0,1,0,0, 1,1,2,1,1, 2,1,3,2,2, 3,1,4,3,3), byrow=TRUE, ncol=5) ## Generation of the Founder cohorts population <- breeding.diploid(population, copy.individual.m = TRUE, breeding.size = c(250,0), selection.size = c(250,0), selection.m.database = cbind(1,1), name.cohort = "BC-Bulls_0", phenotyping.child = "obs", n.observation = pheno_matrix[1,]) population <- breeding.diploid(population, copy.individual.f = TRUE, breeding.size = c(0,2000), selection.size = c(0,2000), selection.f.database = cbind(1,2,1,2000), name.cohort = "BC-Cows_0", phenotyping.child = "obs", n.observation = pheno_matrix[5,]) population <- breeding.diploid(population, copy.individual.f = TRUE, breeding.size = c(0,62), selection.size = c(0,62), selection.f.database = cbind(1,2,2001,2062), name.cohort = "calf_0", phenotyping.child = "obs", n.observation = pheno_matrix[1,]) population <- breeding.diploid(population, copy.individual.f = TRUE, breeding.size = c(0,40), selection.size = c(0,40), selection.f.database = cbind(1,2,2063,2102), name.cohort = "heifer_0", phenotyping.child = "obs", n.observation = pheno_matrix[2,]) population <- breeding.diploid(population, copy.individual.f = TRUE, breeding.size = c(0,37), selection.size = c(0,37), selection.f.database = cbind(1,2,2103,2139), name.cohort = "cow-L1_0", phenotyping.child = "obs", n.observation = pheno_matrix[3,]) population <- breeding.diploid(population, copy.individual.f = TRUE, breeding.size = c(0,28), selection.size = c(0,28), selection.f.database = cbind(1,2,2140,2167), name.cohort = "cow-L2_0", phenotyping.child = "obs", n.observation = pheno_matrix[4,]) population <- breeding.diploid(population, copy.individual.f = TRUE, breeding.size = c(0,19), selection.size = c(0,19), selection.f.database = cbind(1,2,2168, 2186), name.cohort = "cow-L3_0", phenotyping.child = "obs", n.observation = pheno_matrix[5,]) for(index in 1:25){ ## Breeding Company ## if(index==1){ bve.cohorts <- c(paste0("BC-Cows_", index-1), paste0("BC-Bulls_", index-1)) } else{ bve.cohorts <- c(paste0("BC-Cows_", index-1), paste0("BC-Bulls_", index-1), paste0("BC-Cows_", index-2)) } population <- breeding.diploid(population, bve =TRUE, bve.cohorts = bve.cohorts, bve.insert.cohorts = paste0("BC-Bulls_", index-1), singlestep.active = TRUE, depth.pedigree = 7) population <- breeding.diploid(population, breeding.size = c(25,0), selection.size = c(25,0), copy.individual.m = TRUE, selection.m.cohorts = paste0("BC-Bulls_", index-1), multiple.bve.weights.m = c(45,15,10,7,3), name.cohort = paste0("BC-SelectedBulls_", index-1)) population <- breeding.diploid(population, breeding.size = c(0,2000), selection.m.cohorts = paste0("BC-SelectedBulls_", index-1), selection.f.cohorts = paste0("BC-Bulls_", index-1), phenotyping.child = "obs", share.genotyped = 0, n.observation = pheno_matrix[5,], name.cohort = paste0("BC-Cows_", index)) population <- breeding.diploid(population, breeding.size = c(250,0), selection.m.cohorts = paste0("BC-SelectedBulls_", index-1), selection.f.cohorts = paste0("BC-Bulls_", index-1), phenotyping.child = "obs", share.genotyped = 1, n.observation = pheno_matrix[1,], name.cohort = paste0("BC-Bulls_", index)) population <- breeding.diploid(population, breeding.size = c(62,0), selection.size = c(25,0), dh.mating = TRUE, dh.sex = 0, selection.m.cohorts = paste0("BC-SelectedBulls_", index-1), name.cohort = paste0("Semen_", index-1)) ## Generation of new calves population <- breeding.diploid(population, breeding.size = c(0,20), selection.m.cohorts = paste0("Semen_", index-1), selection.f.cohorts = paste0("heifer_", index-1), share.genotyped = 0, name.cohort = paste0("calf-h_", index-1)) population <- breeding.diploid(population, breeding.size = c(0,18), selection.m.cohorts = paste0("Semen_", index-1), selection.f.cohorts = paste0("cow-L1_", index-1), share.genotyped = 0, name.cohort = paste0("calf-L1_", index-1)) population <- breeding.diploid(population, breeding.size = c(0,14), selection.m.cohorts = paste0("Semen_", index-1), selection.f.cohorts = paste0("cow-L2_", index-1), share.genotyped = 0, name.cohort = paste0("calf-L2_", index-1)) population <- breeding.diploid(population, breeding.size = c(0,10), selection.m.cohorts = paste0("Semen_", index-1), selection.f.cohorts = paste0("cow-L3_", index-1), share.genotyped = 0, name.cohort = paste0("calf-L3_", index-1)) population <- breeding.diploid(population, breeding.size = c(0,62), combine = TRUE, selection.m.cohorts = c(paste0("calf-h_", index-1), paste0("calf-L1_", index-1), paste0("calf-L2_", index-1), paste0("calf-L3_", index-1)), phenotyping.child = "obs", n.observation = pheno_matrix[1,], name.cohort = paste0("calf_", index)) ## Aging of heifers / cows population <- breeding.diploid(population, breeding.size = c(0,40), selection.size = c(0,40), copy.individual.f = TRUE, selection.f.cohorts = paste0("calf_", index-1), phenotyping.child = "obs", selection.criteria = "pheno", n.observation = pheno_matrix[2,], share.genotyped = 0, name.cohort = paste0("heifer_", index)) population <- breeding.diploid(population, breeding.size = c(0,37), selection.size = c(0,37), copy.individual.f = TRUE, selection.f.cohorts = paste0("heifer_", index-1), phenotyping.child = "obs", selection.criteria = "pheno", n.observation = pheno_matrix[3,], share.genotyped = 0, name.cohort = paste0("cow-L1_", index)) population <- breeding.diploid(population, breeding.size = c(0,28), selection.size = c(0,28), copy.individual.f = TRUE, selection.f.cohorts = paste0("cow-L1_", index-1), phenotyping.child = "obs", selection.criteria = "pheno", n.observation = pheno_matrix[4,], share.genotyped = 0, name.cohort = paste0("cow-L2_", index)) population <- breeding.diploid(population, breeding.size = c(0,19), selection.size = c(0,19), copy.individual.f = TRUE, selection.f.cohorts = paste0("cow-L2_", index-1), phenotyping.child = "obs", selection.criteria = "pheno", n.observation = pheno_matrix[5,], share.genotyped = 0, name.cohort = paste0("cow-L3_", index)) }