| Title: | Haplotype-Based Tracking of Admixed Population for Breed Composition Estimation |
|---|---|
| Description: | Simulate populations and track haplotypes over generations to evaluate population admixture. The 'HAPTRACE' supports customisable population parameters, including size, number of markers, mutation rates and recombination. |
| Authors: | Shweta Sahoo [aut, cre] (ORCID: <https://orcid.org/0000-0002-5154-5719>), Sara de las Heras-Saldana [aut] (ORCID: <https://orcid.org/0000-0002-8665-6160>), Julius H. J. van der Werf [aut] (ORCID: <https://orcid.org/0000-0003-2512-1696>), Mohammad H. Ferdosi [aut] (ORCID: <https://orcid.org/0000-0001-5385-4913>) |
| Maintainer: | Shweta Sahoo <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.1.2 |
| Built: | 2026-10-11 15:42:27 UTC |
| Source: | https://github.com/cran/HAPTRACE |
Generates barplot of true breed composition of the animals with haplotype information coded according to the breed of origin.
Admixplot(trueBC, color, legendlabels)Admixplot(trueBC, color, legendlabels)
trueBC |
True breed composition estimated by the haplotype information coded according to the breed of origin. |
color |
Colors specifying the number of populations contributing to the true breed composition. |
legendlabels |
Population label to add as a legend to the plot. |
Returns an admixture plot of animals where x axis shows number of animals and y axis shows the proportion of different breeds in different colors.
popAdm <- matrix(c(-1, 2, 3, -4, 2, 1,-1,2,2,3, 1,2,-3,-4,-5, 2,-3,2,4,-5), byrow = TRUE, nrow = 4, ncol = 5) TBC <- trueBreedComp(Haplotype = popAdm) Admixplot(trueBC = TBC, color = c("#FFC107", "#2E7D32", "#FB8072", "#386CB0", "#4d4a49"), legendlabels = c("A", "B", "C", "D", "E"))popAdm <- matrix(c(-1, 2, 3, -4, 2, 1,-1,2,2,3, 1,2,-3,-4,-5, 2,-3,2,4,-5), byrow = TRUE, nrow = 4, ncol = 5) TBC <- trueBreedComp(Haplotype = popAdm) Admixplot(trueBC = TBC, color = c("#FFC107", "#2E7D32", "#FB8072", "#386CB0", "#4d4a49"), legendlabels = c("A", "B", "C", "D", "E"))
Function to calculate allele frequency at each locus of a population.
AlleleFreq(df)AlleleFreq(df)
df |
A matrix consisting of a genotype information of the animals in (0,1,2) format. |
Returns the value of allele frequency at each locus.
popC <- matrix(data = sample(c(0,1,2), 60, replace = TRUE), nrow = 6, ncol = 10) allelefreq <- AlleleFreq(df = popC)popC <- matrix(data = sample(c(0,1,2), 60, replace = TRUE), nrow = 6, ncol = 10) allelefreq <- AlleleFreq(df = popC)
Function to estimate TBV for animals having different SNP effects according to breed of origin.
BreedEff_Haplo(Haplotype, Breed_Effect)BreedEff_Haplo(Haplotype, Breed_Effect)
Haplotype |
A matrix comprising a coded haplotype information of the population where rows are number of animals and columns are number of markers in matrix form. In case of haplotype, 2 rows provide information on genomic material of an animal. |
Breed_Effect |
A matrix comprising the breed effect defined according to the breed of origin such that row depicts the breeds and columns depicts the SNP effects. |
Returns a matrix of coded Haplotype with TBV estimated according to the breed of origin.
pop_BH <- matrix(sample(c(-1,1,-2,2,-3,3), 16, replace = TRUE), nrow = 4, byrow = TRUE) Breed_Eff <- matrix(runif(4 * 4, 0, 1), nrow = 4, byrow = TRUE) Breed_Hap <- BreedEff_Haplo(Haplotype = pop_BH, Breed_Effect = Breed_Eff)pop_BH <- matrix(sample(c(-1,1,-2,2,-3,3), 16, replace = TRUE), nrow = 4, byrow = TRUE) Breed_Eff <- matrix(runif(4 * 4, 0, 1), nrow = 4, byrow = TRUE) Breed_Hap <- BreedEff_Haplo(Haplotype = pop_BH, Breed_Effect = Breed_Eff)
Function to cross two population and estimation of TBV with breed effect according to the breed of origin.
BreedPopCross( map = map, populationSim_A, populationSim_B, nSireA = 54, nDamA = 1000, nSireB = 26, nDamB = 1000, Sire_From, mutationRate = 2.5 * 10^-5, SelType, h2 = 0.3, trait_mean, VarE_PopA, VarE_PopB, Breed_Effect_A, Breed_Effect_B, IndStartVal = 1, prefixID = "Cr", nProgeny = 1000, recL, nChr, recProb, minLength )BreedPopCross( map = map, populationSim_A, populationSim_B, nSireA = 54, nDamA = 1000, nSireB = 26, nDamB = 1000, Sire_From, mutationRate = 2.5 * 10^-5, SelType, h2 = 0.3, trait_mean, VarE_PopA, VarE_PopB, Breed_Effect_A, Breed_Effect_B, IndStartVal = 1, prefixID = "Cr", nProgeny = 1000, recL, nChr, recProb, minLength )
map |
Map file for the population comprising of marker ID, chromosome number and marker position. |
populationSim_A |
Coded haplotype information of the population A where rows are number of animals and columns are number of markers in matrix form. In case of haplotype, 2 rows provide information on genomic material of an animal. |
populationSim_B |
Coded haplotype information of the population B where rows are number of animals and columns are number of markers in matrix form. In case of haplotype, 2 rows provide information on genomic material of an animal. |
nSireA |
Number of sires to be selected as parents for the simulation from population A. |
nDamA |
Number of dams to be selected as parents for the simulation from population A. |
nSireB |
Number of sires to be selected as parents for the simulation from population B. |
nDamB |
Number of dams to be selected as parents for the simulation from population B. |
Sire_From |
The population from which sires should being selected for cross population. If sire should be selected from population A, then use "A" and if sire should be selected from population B, then use "B". |
mutationRate |
Mutation rate to added to the simulated population. |
SelType |
Selection Type. It can be based on phenotype, random or true breeding value. The default selection type is "random". For phenotypic selection, use "Pheno" and for true breeding value, use "TBV". |
h2 |
Heritability of the trait to be simulated. |
trait_mean |
Mean of the trait to be simulated. |
VarE_PopA |
Error Variance obtained after rescaling the QTL effects for PopA. |
VarE_PopB |
Error Variance obtained after rescaling the QTL effects for PopB. |
Breed_Effect_A |
A matrix comprising breed effect according to the breed of origin for population A. |
Breed_Effect_B |
A matrix comprising breed effect according to the breed of origin for population B. |
IndStartVal |
Starting value for the animal ID. |
prefixID |
Prefix to be added to the ID of the animal. |
nProgeny |
Number of progeny to be simulated in the population. |
recL |
Average number of recombinations to be introduced per animal. |
nChr |
Number of haploid chromosomes (n) defined in the population. |
recProb |
A vector of recombination probability between the markers. Its length should be total number of markers minus 1. User can define the recombination probability between markers helping in simulating a desired population. |
minLength |
Minimum length between recombination points beyond which recombination is allowed. The default value is 0. If a user define minimum length, it will ensure that difference between two recombination points less than minimum length won't allow recombination. |
Returns a list of Haplotype information, ID of the simulated animals, population with TBV and phenotype, recombination point list of sire and dam.
BreedEff_Haplo(), BreedPopSelect()
crossmap <- generateMAP(nChr = 5, n_markers = 2, len_Chr = 20) QTL_cross <- matrix(data = c(-0.001, 0.0003, 0, 0, 0, 0.0032, 0.0023, -0.0012,0, 0) , nrow = 1, ncol = 10) P1cross <- matrix(data = sample(c(-1, 1), 40, replace = TRUE), nrow = 4, ncol = 10) P2cross <- matrix(data = sample(c(-2, 2), 40, replace = TRUE), nrow = 4, ncol = 10) P1cross <- PopulationID(Population = P1cross, PopCode = "P1") P2cross <- PopulationID(Population = P2cross, PopCode = "P2") F2cross <- BreedPopCross(map = crossmap, populationSim_A = P1cross, populationSim_B = P2cross, nSireA = 1, nDamA = 1, nSireB = 1, nDamB = 1, Sire_From = "A",mutationRate = 2.5 * 10^-5, SelType = "TBV", h2 = 0.3, Breed_Effect_A = QTL_cross, Breed_Effect_B = QTL_cross, IndStartVal = 1, prefixID = "Cr", nProgeny = 10, recL = 1, nChr = 2, minLength = 0, trait_mean = 5, VarE_PopA = 0.6, VarE_PopB = 0.6)crossmap <- generateMAP(nChr = 5, n_markers = 2, len_Chr = 20) QTL_cross <- matrix(data = c(-0.001, 0.0003, 0, 0, 0, 0.0032, 0.0023, -0.0012,0, 0) , nrow = 1, ncol = 10) P1cross <- matrix(data = sample(c(-1, 1), 40, replace = TRUE), nrow = 4, ncol = 10) P2cross <- matrix(data = sample(c(-2, 2), 40, replace = TRUE), nrow = 4, ncol = 10) P1cross <- PopulationID(Population = P1cross, PopCode = "P1") P2cross <- PopulationID(Population = P2cross, PopCode = "P2") F2cross <- BreedPopCross(map = crossmap, populationSim_A = P1cross, populationSim_B = P2cross, nSireA = 1, nDamA = 1, nSireB = 1, nDamB = 1, Sire_From = "A",mutationRate = 2.5 * 10^-5, SelType = "TBV", h2 = 0.3, Breed_Effect_A = QTL_cross, Breed_Effect_B = QTL_cross, IndStartVal = 1, prefixID = "Cr", nProgeny = 10, recL = 1, nChr = 2, minLength = 0, trait_mean = 5, VarE_PopA = 0.6, VarE_PopB = 0.6)
Function to simulate a population with different breed effect according to breed of origin.
BreedPopSelect( map, Haplotype, nSire, nDam, rate = 2.5 * 10^-5, nProgeny, SelType = "random", Breed_Effect, h2, trait_mean, VarE, recL, nChr, recProb, minLength )BreedPopSelect( map, Haplotype, nSire, nDam, rate = 2.5 * 10^-5, nProgeny, SelType = "random", Breed_Effect, h2, trait_mean, VarE, recL, nChr, recProb, minLength )
map |
Map file for the population comprising of marker ID, chromosome number and marker position. |
Haplotype |
A matrix with coded haplotype information of the population where rows are number of animals and columns are number of markers. In case of haplotype, two rows provide information on genomic material of an animal. |
nSire |
Number of sires to be used for simulation. |
nDam |
Number of dams to be used for simulation. |
rate |
Mutation rate to introduce mutation in the simulated population. |
nProgeny |
Number of progeny to be simulated in each generation. |
SelType |
A character value specifying the selection criteria of the simulated population. Selection criteria can be based on phenotype, random or true breeding value. The default selection type is "random". For phenotypic selection, use "Pheno" and for true breeding value, use "TBV". |
Breed_Effect |
A matrix comprising breed effect according to the breed of origin where rows contain information on SNP effects. |
h2 |
A numeric value describing the heritability of the trait to be simulated ranging from 0 to 1. |
trait_mean |
A positive integer value describing mean of the phenotype of the trait to be simulated. |
VarE |
A positive integer value depicting error variance obtained after rescaling the QTL effects. |
recL |
A numeric value describing the average number of recombinations to be introduced per animal. |
nChr |
A numeric value describing the number of haploid chromosomes (N) defined in the simulated population. |
recProb |
A vector of recombination probability between the markers. Its length should be total number of markers minus 1. User can define the recombination probability between markers helping in simulating a desired population. |
minLength |
Minimum length between recombination points beyond which recombination is allowed. The default value is 0. If a user define minimum length, it will ensure that difference between two recombination points less than minimum length won't allow recombination. |
Returns selected sire and dams along with with their ID, recombination points of sire and dam, and population coded haplotype with phenotype and TBV.
PopS <- matrix(data = sample(c(-1,1, -2,2), 200, replace = TRUE), nrow = 20, ncol = 10) PopS_map <- generateMAP(2, 5, 5) PopS_QTL <- matrix(c(-0.001, 0.0003, 0, 0, 0, 0.0032, 0.0023, -0.0012,0, 0, -0.002, 0.004, 0, 0, 0.002, 0, 0.002, 0,0, -0.0012), byrow = 2, nrow = 2, ncol = 10) Selpop <- BreedPopSelect(map = PopS_map, Haplotype = PopS, nSire = 2, nDam = 2, rate = 2.5 * 10^-5, nProgeny = 6, SelType = "random", Breed_Effect = PopS_QTL, trait_mean = 5,VarE = 0.6, h2 = 0.2, recL = 1, nChr = 2, minLength = 0)PopS <- matrix(data = sample(c(-1,1, -2,2), 200, replace = TRUE), nrow = 20, ncol = 10) PopS_map <- generateMAP(2, 5, 5) PopS_QTL <- matrix(c(-0.001, 0.0003, 0, 0, 0, 0.0032, 0.0023, -0.0012,0, 0, -0.002, 0.004, 0, 0, 0.002, 0, 0.002, 0,0, -0.0012), byrow = 2, nrow = 2, ncol = 10) Selpop <- BreedPopSelect(map = PopS_map, Haplotype = PopS, nSire = 2, nDam = 2, rate = 2.5 * 10^-5, nProgeny = 6, SelType = "random", Breed_Effect = PopS_QTL, trait_mean = 5,VarE = 0.6, h2 = 0.2, recL = 1, nChr = 2, minLength = 0)
This function requires the file with information on markerID, chromosome and marker information with prefix "lm_mrk_qtl", total number of SNP markers ,and QTL effects generated from ReadQTL function. It generates SNP effects of length of total number of markers along with QTLs.
CalQTLeffect(filename, nSNP, QTLfile)CalQTLeffect(filename, nSNP, QTLfile)
filename |
Requires the name of the file with markerID, chr, and marker position. |
nSNP |
Total number of SNP markers. |
QTLfile |
QTL effects generated from ReadQTL function. |
Returns a vector of the SNP effects with length equals to the total number of SNP markers.
## Not run: # This example is not executed since it needs large files. popQM <- read_qmsim_geno("p1_mrk_qtl_001.txt") QTL <- ReadQTL(filename = "effect_qtl_001.txt") QTLeffect <- CalQTLeffect(filename = "lm_mrk_qtl_001.txt", nSNP = ncol(popQM),QTLfile = QTL) ## End(Not run)## Not run: # This example is not executed since it needs large files. popQM <- read_qmsim_geno("p1_mrk_qtl_001.txt") QTL <- ReadQTL(filename = "effect_qtl_001.txt") QTLeffect <- CalQTLeffect(filename = "lm_mrk_qtl_001.txt", nSNP = ncol(popQM),QTLfile = QTL) ## End(Not run)
Function to recode the coded haplotype back to its original form.
Coded_to_Haplo(df)Coded_to_Haplo(df)
df |
A matrix consisting of coded haplotype information of the animals according to the breed of origin. |
Returns a matrix consisting of a haplotype information in (0,1) format.
popB <- matrix(data = sample(c(-1,1), 60, replace = TRUE), nrow = 6, ncol = 10) coded_haplo <- Coded_to_Haplo(df = popB)popB <- matrix(data = sample(c(-1,1), 60, replace = TRUE), nrow = 6, ncol = 10) coded_haplo <- Coded_to_Haplo(df = popB)
Function to select the dams.
DamSample(Haplotype, nDam, nProgeny)DamSample(Haplotype, nDam, nProgeny)
Haplotype |
Haplotype information of the population where rows are number of animals and columns are number of markers in matrix form. In case of haplotype, 2 rows provide information on genomic material of an animal. |
nDam |
Number of Dams to be selected as parents for the simulation. |
nProgeny |
Number of progeny to be simulated in the population. |
Return a list of dam IDs and haplotype information of the dam.
pop_J <- matrix(data = sample(c(0,1), 60, replace = TRUE), nrow = 6, ncol = 10) pop_J_dam <- DamSample(Haplotype = pop_J, nDam = 1, nProgeny = 4)pop_J <- matrix(data = sample(c(0,1), 60, replace = TRUE), nrow = 6, ncol = 10) pop_J_dam <- DamSample(Haplotype = pop_J, nDam = 1, nProgeny = 4)
Extract TBV and Phenotype
Ext_Pheno(df)Ext_Pheno(df)
df |
A matrix comprising the haplotype information along with TBV and Phenotype. Ensure that rownames of the matrix is Animal ID |
A datafile comprising Animal ID, TBV and phenotype.
popEP <- matrix(data= sample(c(0,1), 16, replace= TRUE), nrow = 4, ncol = 4) popEP <- PopulationID(Population = popEP, PopCode = "EP") QTLEff <- c(0.2, 0.1, 0.3, 0.1) TBV_haplotype2 <- TBV_Haplo(Haplotype = popEP, Effect = QTLEff) Var_Ph_R <- Var_PhenoRecords(Haplotype = TBV_haplotype2, h2 = 0.3, trait_mean = 20, VarE = 0.6) Haplo_TBV_Ph <- Var_Ph_R$Haplo_pheno Datafile <- Ext_Pheno(Haplo_TBV_Ph)popEP <- matrix(data= sample(c(0,1), 16, replace= TRUE), nrow = 4, ncol = 4) popEP <- PopulationID(Population = popEP, PopCode = "EP") QTLEff <- c(0.2, 0.1, 0.3, 0.1) TBV_haplotype2 <- TBV_Haplo(Haplotype = popEP, Effect = QTLEff) Var_Ph_R <- Var_PhenoRecords(Haplotype = TBV_haplotype2, h2 = 0.3, trait_mean = 20, VarE = 0.6) Haplo_TBV_Ph <- Var_Ph_R$Haplo_pheno Datafile <- Ext_Pheno(Haplo_TBV_Ph)
Generate Population of a crossbred with breed effect specific to the breed of origin.
GenBreedPop( ngenerations = 5, map = map, populationSim, nSire = 54, nDam = 1000, mutationRate = 2.5 * 10^-5, SelType = "random", h2 = 0.3, trait_mean, VarE, Breed_Effect, recL, nChr, recProb, minLength, IndStartVal = 1, prefixID = "A", nProgeny = 1000 )GenBreedPop( ngenerations = 5, map = map, populationSim, nSire = 54, nDam = 1000, mutationRate = 2.5 * 10^-5, SelType = "random", h2 = 0.3, trait_mean, VarE, Breed_Effect, recL, nChr, recProb, minLength, IndStartVal = 1, prefixID = "A", nProgeny = 1000 )
ngenerations |
Number of generations to be simulated. |
map |
Map file for the population comprising of marker ID, chromosome number and marker position. |
populationSim |
Coded haplotype information of the population where rows are number of animals and columns are number of markers in matrix form. In case of haplotype, 2 rows provide information on genomic material of an animal. |
nSire |
Number of sires to be selected as parents for the simulation. |
nDam |
Number of Dams to be selected as parents for the simulation. |
mutationRate |
Mutation rate to added to the simulated population. |
SelType |
Selection Type. It can be based on phenotype, random or true breeding value. The default selection type is "random". For phenotypic selection, use "Pheno" and for true breeding value, use "TBV". |
h2 |
Heritability of the trait to be simulated. |
trait_mean |
Mean of the trait to be simulated. |
VarE |
Error Variance obtained after rescaling the QTL effects. |
Breed_Effect |
A matrix comprising breed effect according to the breed of origin where rows contain information on SNP effects. |
recL |
Average number of recombinations to be introduced per animal. |
nChr |
Number of haploid chromosomes (n) defined in the population. |
recProb |
A vector of recombination probability between the markers. Its length should be total number of markers minus 1. User can define the recombination probability between markers helping in simulating a desired population. |
minLength |
Minimum length between recombination points beyond which recombination is allowed. The default value is 0. If a user define minimum length, it will ensure that difference between two recombination points less than minimum length won't allow recombination. |
IndStartVal |
Starting value for the Animal ID of the simulated population. |
prefixID |
Prefix to be added to the ID of the animal. |
nProgeny |
Number of progeny to be simulated in the population. |
Returns a list of Haplotype information, pedigree of the simulated animals, population with TBV and phenotype, recombination point list of sire and dam.
BreedEff_Haplo(), BreedPopSelect()
PopGen <- matrix(data = sample(c(-1, 1), 200, replace = TRUE), nrow = 20, ncol = 10) PopGen <- PopulationID(Population = PopGen, PopCode = "PG1") PopGen_map <- generateMAP(nChr = 2, n_markers = 5, len_Chr = 5) QTL_PopGen <- matrix(data = c(-0.001, 0.0003, 0, 0, 0, 0.0032, 0.0023, -0.0012,0, 0), nrow = 1, ncol = 10) PopF1 <- GenBreedPop(ngenerations = 2, map = PopGen_map, populationSim = PopGen, nSire = 1, nDam = 1,mutationRate = 2.5 * 10^-5, SelType = "TBV", h2 = 0.3, trait_mean = 5, VarE = 0.6, Breed_Effect = QTL_PopGen, recL = 1, nChr = 2, minLength = 0, IndStartVal = 1,prefixID = "A", nProgeny = 10)PopGen <- matrix(data = sample(c(-1, 1), 200, replace = TRUE), nrow = 20, ncol = 10) PopGen <- PopulationID(Population = PopGen, PopCode = "PG1") PopGen_map <- generateMAP(nChr = 2, n_markers = 5, len_Chr = 5) QTL_PopGen <- matrix(data = c(-0.001, 0.0003, 0, 0, 0, 0.0032, 0.0023, -0.0012,0, 0), nrow = 1, ncol = 10) PopF1 <- GenBreedPop(ngenerations = 2, map = PopGen_map, populationSim = PopGen, nSire = 1, nDam = 1,mutationRate = 2.5 * 10^-5, SelType = "TBV", h2 = 0.3, trait_mean = 5, VarE = 0.6, Breed_Effect = QTL_PopGen, recL = 1, nChr = 2, minLength = 0, IndStartVal = 1,prefixID = "A", nProgeny = 10)
Function to simulate historical population.
generateHP( n_generations, n_animals, map, nSire, nDam, nProgeny, mutationRate = 2.5 * 10^-5, SelType = "random", Effect, h2 = 0.3, trait_mean = 10, VarE, recL = 5, nChr, recProb, minLength = 0, IndStartVal = 1, prefixID = "H" )generateHP( n_generations, n_animals, map, nSire, nDam, nProgeny, mutationRate = 2.5 * 10^-5, SelType = "random", Effect, h2 = 0.3, trait_mean = 10, VarE, recL = 5, nChr, recProb, minLength = 0, IndStartVal = 1, prefixID = "H" )
n_generations |
Number of generations to be simulated. |
n_animals |
Number of animals to be simulated. |
map |
Map file for the population. |
nSire |
Number of sires to be selected as parents for the simulation. |
nDam |
Number of Dams to be selected as parents for the simulation. |
nProgeny |
Number of progeny to be simulated in the population. |
mutationRate |
Mutation rate to added to the simulated population. |
SelType |
Selection Type. It can be based on phenotype, random or true breeding value. The default selection type is random. For phenotypic selection, use "Pheno" and for true breeding value, use "TBV". |
Effect |
SNP effect for calculation of TBV. |
h2 |
Heritability of the trait to be simulated. |
trait_mean |
Mean of the trait to be simulated. |
VarE |
Error Variance obtained after rescaling the QTL effects. |
recL |
Average number of recombinations to be introduced per animal. |
nChr |
Number of haploid chromosomes (n) defined in the population. |
recProb |
A vector of recombination probability between the markers. Its length should be total number of markers minus 1. User can define the recombination probability between markers helping in simulating a desired population. |
minLength |
Minimum length between recombination points beyond which recombination is allowed. The default value is 0. If a user define minimum length, it will ensure that difference between two recombination points less than minimum length won't allow recombination. |
IndStartVal |
Starting value for the Animal ID of the historical population. |
prefixID |
Prefix to be added to the ID of the animal of the historical population |
Returns haplotype information of the historical population.
MutationRate(), mapQTLfile(), generateMAP(), QTLeffects()
HP_map <- generateMAP(nChr = 2, n_markers = 5, len_Chr = 5) QTL_HP <- QTLeffects(n_QTL_Chr = 2, nChr = 2, len_Chr = 5, shape_gamma = 0.4, effect_distribution = "gamma") HP_mapqtl <- mapQTLfile(map = HP_map, QTL = QTL_HP) HP_effect <- as.numeric(HP_mapqtl$Effect) H1 <- generateHP(n_generations = 5, n_animals = 20, map = HP_mapqtl, nSire = 1, nDam = 1, nProgeny = 6, mutationRate = 2.5 * 10^-5, SelType = "random", Effect = HP_effect, h2 = 0.3, trait_mean = 10, VarE = 0.6,recL = 2,nChr = 2, minLength = 0)HP_map <- generateMAP(nChr = 2, n_markers = 5, len_Chr = 5) QTL_HP <- QTLeffects(n_QTL_Chr = 2, nChr = 2, len_Chr = 5, shape_gamma = 0.4, effect_distribution = "gamma") HP_mapqtl <- mapQTLfile(map = HP_map, QTL = QTL_HP) HP_effect <- as.numeric(HP_mapqtl$Effect) H1 <- generateHP(n_generations = 5, n_animals = 20, map = HP_mapqtl, nSire = 1, nDam = 1, nProgeny = 6, mutationRate = 2.5 * 10^-5, SelType = "random", Effect = HP_effect, h2 = 0.3, trait_mean = 10, VarE = 0.6,recL = 2,nChr = 2, minLength = 0)
Function to generate MAP file with marker ID, chromosome and marker position columns.
generateMAP(nChr, n_markers, len_Chr)generateMAP(nChr, n_markers, len_Chr)
nChr |
Number of haploid chromosomes (n) defined in the population. |
n_markers |
Number of SNP markers to be generated per chromosome. This parameter is independent of QTL effects at this stage. |
len_Chr |
Length of the chromosome. It can be a single value or vector specifying different length per chromosome in cM. If users wants to use base pairs(bp) as a measure to determine position, it can be obtained by bp = cM *10^6 .The base pair position should be calculated by users as it is not part of this function. |
Returns a map file of the population with marker ID, chromosome number and position of the markers on the chromosome.
map <- generateMAP(nChr = 2, n_markers = 10, len_Chr = 5)map <- generateMAP(nChr = 2, n_markers = 10, len_Chr = 5)
This function simulates a population for multiple number of generations as specified by the users. It generates coded Haplotype as per breed of origin, from which we can extract haplotype and genotype.It also generates pedigree file, true breeding value, phenotype, recombination points and recombination probability.
GenOnePopulation( ngenerations = 5, map = map, populationSim, nSire = 54, nDam = 1000, mutationRate = 2.5 * 10^-5, SelType = "random", h2 = 0.3, trait_mean, VarE, Effect, recL, nChr, recProb, minLength, IndStartVal = 1, prefixID = "A", nProgeny = 1000 )GenOnePopulation( ngenerations = 5, map = map, populationSim, nSire = 54, nDam = 1000, mutationRate = 2.5 * 10^-5, SelType = "random", h2 = 0.3, trait_mean, VarE, Effect, recL, nChr, recProb, minLength, IndStartVal = 1, prefixID = "A", nProgeny = 1000 )
ngenerations |
Number of generations to be simulated |
map |
Map file for the population comprising of marker ID, chromosome number and marker position. |
populationSim |
Coded haplotype information of the population where rows are number of animals and columns are number of markers in matrix form. In case of haplotype, 2 rows provide information on genomic material of an animal. |
nSire |
Number of sires to be selected as parents for the simulation. |
nDam |
Number of Dams to be selected as parents for the simulation. |
mutationRate |
Mutation rate to added to the simulated population. |
SelType |
Selection Type. It can be based on phenotype, random or true breeding value. The default selection type is "random". For phenotypic selection, use "Pheno" and for true breeding value, use "TBV". |
h2 |
Heritability of the trait to be simulated. |
trait_mean |
Mean of the trait to be simulated. |
VarE |
Error Variance obtained after rescaling the QTL effects. |
Effect |
SNP effect for the calculation of TBV. |
recL |
Average number of recombinations to be introduced per animal. |
nChr |
Number of haploid chromosomes (n) defined in the population. |
recProb |
A vector of recombination probability between the markers. Its length should be total number of markers minus 1. User can define the recombination probability between markers helping in simulating a desired population. |
minLength |
Minimum length between recombination points beyond which recombination is allowed. The default value is 0. If a user define minimum length, it will ensure that difference between two recombination points less than minimum length won't allow recombination. |
IndStartVal |
Starting value for the Animal ID of the simulated population. |
prefixID |
Prefix to be added to the ID of the animal of simulated population. |
nProgeny |
Number of progeny to be simulated in the population. |
List of Haplotype information , pedigree of the simulated animals, population with TBV and phenotype, recombination point list of sire and dam.
PopGen <- matrix(data = sample(c(-1, 1), 200, replace = TRUE), nrow = 20, ncol = 10) PopGen <- PopulationID(Population = PopGen, PopCode = "A1") PopGen_map <- generateMAP(nChr = 2, n_markers = 5, len_Chr = 5) QTL_PopGen <- c(-0.001, 0.0003, 0, 0, 0, 0.0032, 0.0023, -0.0012,0, 0 ) PopF1 <- GenOnePopulation(ngenerations = 2, map = PopGen_map, populationSim = PopGen, nSire = 1, nDam = 1, mutationRate = 2.5 * 10^-5, SelType = "TBV", h2 = 0.3, trait_mean = 5,VarE = 0.6, Effect = QTL_PopGen, recL = 1, nChr = 2, minLength = 0, IndStartVal = 1, prefixID = "A", nProgeny = 10)PopGen <- matrix(data = sample(c(-1, 1), 200, replace = TRUE), nrow = 20, ncol = 10) PopGen <- PopulationID(Population = PopGen, PopCode = "A1") PopGen_map <- generateMAP(nChr = 2, n_markers = 5, len_Chr = 5) QTL_PopGen <- c(-0.001, 0.0003, 0, 0, 0, 0.0032, 0.0023, -0.0012,0, 0 ) PopF1 <- GenOnePopulation(ngenerations = 2, map = PopGen_map, populationSim = PopGen, nSire = 1, nDam = 1, mutationRate = 2.5 * 10^-5, SelType = "TBV", h2 = 0.3, trait_mean = 5,VarE = 0.6, Effect = QTL_PopGen, recL = 1, nChr = 2, minLength = 0, IndStartVal = 1, prefixID = "A", nProgeny = 10)
Function to generate genotype information from haplotype (0,1) information.
MakeGeno(df)MakeGeno(df)
df |
Haplotype (0,1) information of the population where rows are number of animals and columns are number of markers in matrix form. In case of haplotype, 2 rows provide information on genomic material of an animal. |
Returns the genotype information of the animal.
popD <- matrix(data = sample(c(0,1), 60, replace = TRUE), nrow = 6, ncol = 10) genotype <- MakeGeno(df = popD)popD <- matrix(data = sample(c(0,1), 60, replace = TRUE), nrow = 6, ncol = 10) genotype <- MakeGeno(df = popD)
This function combines marker and qtl file together. SNP markers are often observed to be near or away from the QTL in real life scenario. However, QTL position is included along with map file to get combined marker file for simulation purpose in this package. This step is crucial to calculate the true breeding value and simulate the phenotype with desired population parameters.
mapQTLfile(map, QTL)mapQTLfile(map, QTL)
map |
map file with marker ID, chromosome, and marker position |
QTL |
qtl file with QTL ID, chromosome, marker position and effect |
combined file with marker and QTL ID, chromosome, position and QTL effects.
popmap <- generateMAP(nChr = 5, n_markers = 10, len_Chr = c(10, 20, 40, 50, 60)) popQTL <- QTLeffects(n_QTL_Chr = 2, nChr = 5, len_Chr = c(10, 20, 40, 50, 60), shape_gamma = 0.4, effect_distribution = "gamma") pop_mapqtl <- mapQTLfile(map = popmap, QTL = popQTL)popmap <- generateMAP(nChr = 5, n_markers = 10, len_Chr = c(10, 20, 40, 50, 60)) popQTL <- QTLeffects(n_QTL_Chr = 2, nChr = 5, len_Chr = c(10, 20, 40, 50, 60), shape_gamma = 0.4, effect_distribution = "gamma") pop_mapqtl <- mapQTLfile(map = popmap, QTL = popQTL)
Function to generate progeny from selected sires and dams.
MatingPop(Sire, Dam)MatingPop(Sire, Dam)
Sire |
Haplotype information of the Sire in matrix format. |
Dam |
Haplotype information of the Dam in matrix format. |
Returns haplotype information of the progeny.
Sire_K <- matrix(data = sample(c(0,1), 30, replace = TRUE), nrow = 3, ncol = 10) Dam_K <- matrix(data = sample(c(0,1), 30, replace = TRUE), nrow = 3, ncol = 10) popK <- MatingPop(Sire = Sire_K, Dam = Dam_K)Sire_K <- matrix(data = sample(c(0,1), 30, replace = TRUE), nrow = 3, ncol = 10) Dam_K <- matrix(data = sample(c(0,1), 30, replace = TRUE), nrow = 3, ncol = 10) popK <- MatingPop(Sire = Sire_K, Dam = Dam_K)
Function to add mutation rate to the haplotype information of the animals.
MutationRate(Haplotype, rate)MutationRate(Haplotype, rate)
Haplotype |
Haplotype information of the population where rows are number of animals and columns are number of markers in matrix form. In case of haplotype, 2 rows provide information on genomic material of an animal. |
rate |
Mutation rate. The default mutation rate is = 2.5*10^-5. However, user can also define mutation rate as per requirement. |
Returns a haplotype matrix with mutations.
popH <- matrix(data = sample(c(0,1), 60, replace = TRUE), nrow = 6, ncol = 10) popH_Mutation <- MutationRate(Haplotype = popH, rate = 2.5*10^-5)popH <- matrix(data = sample(c(0,1), 60, replace = TRUE), nrow = 6, ncol = 10) popH_Mutation <- MutationRate(Haplotype = popH, rate = 2.5*10^-5)
Combine Pedigree and Phenotype data
Ped_Pheno(Pedigree, Phenotype)Ped_Pheno(Pedigree, Phenotype)
Pedigree |
Pedigree file comprising AnimalID, Sire ID, Dam ID and Sex of the animal. |
Phenotype |
Phenotype file comprising Animal ID, TBV and phenotype of the animal |
A datafile comprising AnimalID, Sire ID, Dam ID, Sex, TBV and phenotype of the animal.
PopGen1 <- matrix(data = sample(c(-1, 1), 200, replace = TRUE), nrow = 20, ncol = 10) PopGen1 <- PopulationID(Population = PopGen1, PopCode = "PG") PopGen1_map <- generateMAP(2, 5, 5) QTL_PopGen1 <- c(-0.001, 0.0003, 0, 0, 0, 0.0032, 0.0023, -0.0012,0, 0) PopPP <- GenOnePopulation(ngenerations=2, map=PopGen1_map, PopGen1,nSire=1,nDam=1,mutationRate=2.5 * 10^-5, SelType = "TBV", h2 = 0.3, trait_mean = 5 ,VarE = 0.6, Effect = QTL_PopGen1, recL = 1, nChr = 2, minLength = 0, IndStartVal=1,prefixID="A",nProgeny=10) Phenofile <- Ext_Pheno(df = PopPP$population) Ped_Phenofile <- Ped_Pheno(Pedigree = PopPP$parents, Phenotype = Phenofile)PopGen1 <- matrix(data = sample(c(-1, 1), 200, replace = TRUE), nrow = 20, ncol = 10) PopGen1 <- PopulationID(Population = PopGen1, PopCode = "PG") PopGen1_map <- generateMAP(2, 5, 5) QTL_PopGen1 <- c(-0.001, 0.0003, 0, 0, 0, 0.0032, 0.0023, -0.0012,0, 0) PopPP <- GenOnePopulation(ngenerations=2, map=PopGen1_map, PopGen1,nSire=1,nDam=1,mutationRate=2.5 * 10^-5, SelType = "TBV", h2 = 0.3, trait_mean = 5 ,VarE = 0.6, Effect = QTL_PopGen1, recL = 1, nChr = 2, minLength = 0, IndStartVal=1,prefixID="A",nProgeny=10) Phenofile <- Ext_Pheno(df = PopPP$population) Ped_Phenofile <- Ped_Pheno(Pedigree = PopPP$parents, Phenotype = Phenofile)
Function to generate ped file for PLINK analysis.
plinkped(Genotype, AnimalID, filename)plinkped(Genotype, AnimalID, filename)
Genotype |
A matrix containing the genotype information of the animals where rows |
AnimalID |
Animal ID for the animals in the population |
filename |
Naming a ped file |
A ped file for PLINK analysis. As of now, it only saves animal ID and genotypes. Saving pedigree in ped file is in our plan for the update.
pop_plink <- matrix(data = sample(c(0,1,2), 60, replace = TRUE), nrow = 6, ncol = 10) rownames(pop_plink) <- paste("PP", 1:nrow(pop_plink), sep = "_") output_path <- file.path(tempdir(), "pop") plinkped(Genotype = pop_plink, AnimalID = rownames(pop_plink), filename = output_path)pop_plink <- matrix(data = sample(c(0,1,2), 60, replace = TRUE), nrow = 6, ncol = 10) rownames(pop_plink) <- paste("PP", 1:nrow(pop_plink), sep = "_") output_path <- file.path(tempdir(), "pop") plinkped(Genotype = pop_plink, AnimalID = rownames(pop_plink), filename = output_path)
Function to generate plot of haplotype segments inherited from different breeds.It utilises the coded haplotype information according to the breed of origin and generates plot at all chromosomes.
plotHaplo(Haplotype, colors, map, nChr, legendlabels)plotHaplo(Haplotype, colors, map, nChr, legendlabels)
Haplotype |
Haplotype information of the animals to be plotted. |
colors |
Colors to be defined for different populations. |
map |
Mapfile of the population comprising of marker ID, chromosome number and marker position. |
nChr |
Haploid number of chromosomes(n). |
legendlabels |
Population label to add as a legend to the plot. |
Haplotype plot showing blocks from different population for animals.
Haplotype <- matrix(data = sample(c(-1, 1, -2, 2, -3, 3), 100, replace = TRUE), nrow = 10, ncol = 10) Haplotype_ID <- PopulationID(Population = Haplotype, PopCode = "H1") map <- generateMAP(nChr = 2, n_markers = 5, len_Chr = 5) colors = c("gold", "forestgreen", "steelblue") plot <- plotHaplo(Haplotype = Haplotype_ID, colors = colors, map = map, nChr = 2, legendlabels = c("A", "B", "C"))Haplotype <- matrix(data = sample(c(-1, 1, -2, 2, -3, 3), 100, replace = TRUE), nrow = 10, ncol = 10) Haplotype_ID <- PopulationID(Population = Haplotype, PopCode = "H1") map <- generateMAP(nChr = 2, n_markers = 5, len_Chr = 5) colors = c("gold", "forestgreen", "steelblue") plot <- plotHaplo(Haplotype = Haplotype_ID, colors = colors, map = map, nChr = 2, legendlabels = c("A", "B", "C"))
This function select sires and dams of the population using random, phenotypic or true breeding value.
PopSelect( map, Haplotype, nSire, nDam, rate = 2.5 * 10^-5, nProgeny, SelType = "random", Effect, h2, trait_mean, VarE, recL, nChr, recProb, minLength )PopSelect( map, Haplotype, nSire, nDam, rate = 2.5 * 10^-5, nProgeny, SelType = "random", Effect, h2, trait_mean, VarE, recL, nChr, recProb, minLength )
map |
Map file for the population comprising of marker ID, chromosome number and marker position. |
Haplotype |
Coded haplotype information of the population where rows are number of animals and columns are number of markers in matrix form. In case of haplotype, 2 rows provide information on genomic material of an animal. |
nSire |
Number of Sires to be used for simulation. |
nDam |
Number of Dams to be used for simulation. |
rate |
Mutation rate to introduce mutation in the population. |
nProgeny |
Number of Progeny to be simulated in each generation. |
SelType |
Selection Type. It can be based on phenotype, random or true breeding value. The default selection type is "random". For phenotypic selection, use "Pheno" and for true breeding value, use "TBV". |
Effect |
SNP effect for the calculation of TBV. |
h2 |
Heritability of the trait to be simulated. |
trait_mean |
Mean of the trait to be simulated. |
VarE |
Error Variance obtained after rescaling the QTL effects. |
recL |
Average number of recombinations to be introduced per animal. |
nChr |
Number of haploid chromosomes (n) defined in the population. |
recProb |
A vector of recombination probability between the markers. Its length should be total number of markers minus 1. User can define the recombination probability between markers helping in simulating a desired population. |
minLength |
Minimum length between recombination points beyond which recombination is allowed. The default value is 0. If a user define minimum length, it will ensure that difference between two recombination points less than minimum length won't allow recombination. |
It generates selected sire and dams along with with their ID, recombination points of sire and dam, and population coded haplotype with phenotype and TBV.
PopS <- matrix(data = sample(c(0,1), 200, replace = TRUE), nrow = 20, ncol = 10) PopS_map <- generateMAP(nChr = 2, n_markers = 5, len_Chr = 5) PopS_QTL <- c(-0.001, 0.0003, 0, 0, 0, 0.0032, 0.0023, -0.0012,0, 0 ) Selpop <- PopSelect(map = PopS_map, Haplotype = PopS, nSire = 2, nDam = 2, rate = 2.5 * 10^-5, nProgeny = 6, SelType = "random", Effect = PopS_QTL, trait_mean = 5, VarE = 0.6, h2 = 0.2, recL = 1, nChr = 2, minLength = 0)PopS <- matrix(data = sample(c(0,1), 200, replace = TRUE), nrow = 20, ncol = 10) PopS_map <- generateMAP(nChr = 2, n_markers = 5, len_Chr = 5) PopS_QTL <- c(-0.001, 0.0003, 0, 0, 0, 0.0032, 0.0023, -0.0012,0, 0 ) Selpop <- PopSelect(map = PopS_map, Haplotype = PopS, nSire = 2, nDam = 2, rate = 2.5 * 10^-5, nProgeny = 6, SelType = "random", Effect = PopS_QTL, trait_mean = 5, VarE = 0.6, h2 = 0.2, recL = 1, nChr = 2, minLength = 0)
Function to add Population code to the population which will help in generating parent IDs.
PopulationID(Population, PopCode)PopulationID(Population, PopCode)
Population |
Haplotype information of the base population to be used for simulating the population. |
PopCode |
Code to be assigned for the base population which will appear in IDs. |
Returns a population with provided PopCode, which will appear as PopulationID.
PopN_Check <- matrix(data = sample(c(0,1), 200, replace = TRUE), nrow = 10, ncol = 20) PopN_CheckID <- PopulationID(Population = PopN_Check, PopCode = "P1")PopN_Check <- matrix(data = sample(c(0,1), 200, replace = TRUE), nrow = 10, ncol = 20) PopN_CheckID <- PopulationID(Population = PopN_Check, PopCode = "P1")
Function to format map file from QMSim for PLINK analysis.
QMSim_PlinkMAP(filepath, outputpath, filename)QMSim_PlinkMAP(filepath, outputpath, filename)
filepath |
Map file generated from the QMSim. |
outputpath |
Path directory for the output file |
filename |
Name of the map file to be extracted |
Returns a map file that can be used for PLINK analysis.
## Not run: # This example is not executed since it needs large files. output_folder <- file.path(tempdir(), "map") dir.create(output_folder, showWarnings = FALSE, recursive = TRUE) QMSim_PlinkMAP(filepath = "lm_mrk_qtl_001.txt", outputpath = output_folder, filename = "pop") ## End(Not run)## Not run: # This example is not executed since it needs large files. output_folder <- file.path(tempdir(), "map") dir.create(output_folder, showWarnings = FALSE, recursive = TRUE) QMSim_PlinkMAP(filepath = "lm_mrk_qtl_001.txt", outputpath = output_folder, filename = "pop") ## End(Not run)
Generates the density plot for the QTL effects.
QTL_densityplot(QTL_eff_file, color = "steelblue")QTL_densityplot(QTL_eff_file, color = "steelblue")
QTL_eff_file |
QTL file with information on QTL effects. |
color |
color of the density plot. |
shows density plot depicting the distribution of the QTL effects.
example_QTL <- QTLeffects(n_QTL_Chr = 1, nChr = 5, len_Chr = c(10, 8, 6, 4, 2), shape_gamma = 0.4) plot <- QTL_densityplot(QTL_eff_file = example_QTL, color = "forestgreen")example_QTL <- QTLeffects(n_QTL_Chr = 1, nChr = 5, len_Chr = c(10, 8, 6, 4, 2), shape_gamma = 0.4) plot <- QTL_densityplot(QTL_eff_file = example_QTL, color = "forestgreen")
Function to estimate QTL effects with output of QTL ID, chromosome, QTL position and QTL effects
QTLeffects( n_QTL_Chr, nChr, len_Chr, shape_gamma = 0.4, effect_distribution = "gamma" )QTLeffects( n_QTL_Chr, nChr, len_Chr, shape_gamma = 0.4, effect_distribution = "gamma" )
n_QTL_Chr |
Number of QTL to be simulated per chromosome |
nChr |
Number of haploid chromosomes (n) defined in the population. |
len_Chr |
Length of the chromosome.It can be either provided single constant value or vector specifying varied length of the chromosomes. |
shape_gamma |
Shape of the QTL effects if simulated using gamma distribution. |
effect_distribution |
Define the distribution of QTL effects. It can be either gamma, normal or uniform distribution. |
file comprising of QTL ID, chromosomes, position of the QTL and QTL effects.
QTL <- QTLeffects(n_QTL_Chr = 1, nChr = 2, len_Chr = 10, shape_gamma = 0.4, effect_distribution = "gamma")QTL <- QTLeffects(n_QTL_Chr = 1, nChr = 2, len_Chr = 10, shape_gamma = 0.4, effect_distribution = "gamma")
Random selection of sire and dam gametes
Random_gametes(Gamete_Matrix)Random_gametes(Gamete_Matrix)
Gamete_Matrix |
A matrix comprising haplotype information of sire or dam gametes after recombination |
Returns matrix comprising random selection of gametes
mat = matrix(data = sample(c(-1,1,-2,2), 100*10, replace = TRUE) , nrow = 100, ncol = 10) mat = PopulationID(Population = mat, PopCode = "M") rev_mat = Random_gametes(Gamete_Matrix = mat)mat = matrix(data = sample(c(-1,1,-2,2), 100*10, replace = TRUE) , nrow = 100, ncol = 10) mat = PopulationID(Population = mat, PopCode = "M") rev_mat = Random_gametes(Gamete_Matrix = mat)
Efficiently reads a QMSim p1_mrk_qtl_*.txt genotype file using
compiled C++ code (Rcpp) and returns a single integer matrix.
read_qmsim_geno(file_path, geno_mode = "haplotype", phase_seed = 42L)read_qmsim_geno(file_path, geno_mode = "haplotype", phase_seed = 42L)
file_path |
Character string. Path to the QMSim genotype file. |
geno_mode |
Character string controlling output layout. One of:
|
phase_seed |
Integer seed for deterministic phasing of unphased
heterozygotes (code 1). Only used when |
Each character in the QMSim genotype string represents one locus:
| Code | Genotype | Paternal | Maternal |
| 0 | 0|0 | 0 | 0 |
| 1 | het (unphased) | ? | ? |
| 2 | 1|1 | 1 | 1 |
| 3 | 0|1 | 0 | 1 |
| 4 | 1|0 | 1 | 0 |
Lines ending with > are continuation lines and are concatenated
automatically.
An integer matrix with rownames set to animal IDs.
## Not run: # This example is not executed since it needs large files. # Two 0/1 rows per individual (paternal / maternal haplotypes) hap <- read_qmsim_geno("p1_mrk_qtl_001.txt") dim(hap) # 2*n_ind x n_loci # Raw genotype codes (0-4) as in the file geno <- read_qmsim_geno("p1_mrk_qtl_001.txt", geno_mode = "allele") dim(geno) # n_ind x n_loci ## End(Not run)## Not run: # This example is not executed since it needs large files. # Two 0/1 rows per individual (paternal / maternal haplotypes) hap <- read_qmsim_geno("p1_mrk_qtl_001.txt") dim(hap) # 2*n_ind x n_loci # Raw genotype codes (0-4) as in the file geno <- read_qmsim_geno("p1_mrk_qtl_001.txt", geno_mode = "allele") dim(geno) # n_ind x n_loci ## End(Not run)
This function reads the effect file generated from QMSim with the file prefix "effect_qtl". It generates the effects for the defined QTLs in QMSim.
ReadQTL(filename)ReadQTL(filename)
filename |
Requires the name of the QTL file with allele effect obtained from QMSim. |
Returns a readable QTL effect
## Not run: # This example is not executed since it needs large files. QTLfile <- ReadQTL(filename = "effect_qtl_001.txt") ## End(Not run)## Not run: # This example is not executed since it needs large files. QTLfile <- ReadQTL(filename = "effect_qtl_001.txt") ## End(Not run)
Function to recode the haplotype according to different breed codes as specified by users.
Recode_Haplotype(df, popBase)Recode_Haplotype(df, popBase)
df |
A matrix consisting of haplotype information of the population where rows are number of animals and columns are number of markers in matrix form. In case of haplotype, 2 rows provide information on genomic material of an animal. |
popBase |
Code specified according to the specific breed. |
Returns a matrix consisting of coded haplotype information of the animals according to the defined popBase.
popA <- matrix(data = sample(c(0,1), 60, replace = TRUE), nrow = 6, ncol = 10) PA_Haplo <- Recode_Haplotype(df = popA, popBase = 1)popA <- matrix(data = sample(c(0,1), 60, replace = TRUE), nrow = 6, ncol = 10) PA_Haplo <- Recode_Haplotype(df = popA, popBase = 1)
Function to add recombination to the haplotype information of the animals.
RecombinationPoint(map, Haplotype, recL, nChr, recProb)RecombinationPoint(map, Haplotype, recL, nChr, recProb)
map |
Mapfile of the population comprising of marker ID, chromosome number and marker position. |
Haplotype |
Haplotype information of the population where rows are number of animals and columns are number of markers in matrix form. In case of haplotype, 2 rows provide information on genomic material of an animal. |
recL |
Average number of recombinations to be introduced per animal. |
nChr |
Number of haploid chromosomes (n) defined in the population. |
recProb |
A vector of recombination probability between the markers. Its length should be total number of markers minus 1. User can define the recombination probability between markers helping in simulating a desired population. |
Returns a list of recombination points and number of recombinations per animal.
popG <- matrix(data = sample(c(0,1), 40, replace = TRUE), nrow = 4, ncol = 10) popGmap <- generateMAP(nChr = 2, n_markers = 5, len_Chr = 10) popGRec <- RecombinationPoint(map = popGmap, Haplotype = popG, recL = 2, nChr = 2)popG <- matrix(data = sample(c(0,1), 40, replace = TRUE), nrow = 4, ncol = 10) popGmap <- generateMAP(nChr = 2, n_markers = 5, len_Chr = 10) popGRec <- RecombinationPoint(map = popGmap, Haplotype = popG, recL = 2, nChr = 2)
Function to generate plot for recombination points and recombination probability.
recProbplot(recList, n_markers, col = "steelblue", map)recProbplot(recList, n_markers, col = "steelblue", map)
recList |
List of recombination points with each list containing information of recombination points of an animal. |
n_markers |
Total number of markers. |
col |
Color of the recombination probability plot. |
map |
Map file of the markers for the population. |
This function returns the plots for recombination points and recombination probability.
generateMAP(), RecombinationPoint()
map_rec <- generateMAP(nChr = 2, n_markers = 5, len_Chr = 10) poprec <- matrix(data = sample(c(0,1), 1000, replace = TRUE), nrow = 100, ncol = 10) RecPoint <- RecombinationPoint(map = map_rec, Haplotype = poprec, recL = 2, nChr = 2) reclist <- RecPoint$recList recom_plot <- recProbplot(recList = reclist, n_markers = 10, map = map_rec)map_rec <- generateMAP(nChr = 2, n_markers = 5, len_Chr = 10) poprec <- matrix(data = sample(c(0,1), 1000, replace = TRUE), nrow = 100, ncol = 10) RecPoint <- RecombinationPoint(map = map_rec, Haplotype = poprec, recL = 2, nChr = 2) reclist <- RecPoint$recList recom_plot <- recProbplot(recList = reclist, n_markers = 10, map = map_rec)
Function to format genotype file for BLUPF90 analysis.
Reformat_BLUPF90(Genodata, savefile)Reformat_BLUPF90(Genodata, savefile)
Genodata |
A matrix comprising genotype information (0,1,2) of the animals where rownames depicts the animal ID. |
savefile |
File name in which the genotype data will be saved. |
Returns a text file comprising of genotype data for its use in BLUPF90.
Geno <- matrix(data = sample(c(0,1,2), 100, replace = TRUE), nrow = 10, ncol = 10) rownames(Geno) <- paste("G", 1:nrow(Geno), sep = "_") output_path <- file.path(tempdir(), "genotype") Reformat_BLUPF90(Genodata = Geno, savefile = output_path)Geno <- matrix(data = sample(c(0,1,2), 100, replace = TRUE), nrow = 10, ncol = 10) rownames(Geno) <- paste("G", 1:nrow(Geno), sep = "_") output_path <- file.path(tempdir(), "genotype") Reformat_BLUPF90(Genodata = Geno, savefile = output_path)
This function allows scaling of the SNP effects based on the scaling factor derived from genotype of the base population and standard deviation of the phenotype. This allows users to scale the SNP effects to get desirable variance components.
Rescale(Haplotype, Effect, Phenosd, h2)Rescale(Haplotype, Effect, Phenosd, h2)
Haplotype |
A matrix where each row represents a haplotype (0,1) and each column represents a marker. |
Effect |
A vector with SNP effect of a population to be scaled before the simulation of a population |
Phenosd |
A value of phenotypic standard deviation which will help in estimating desirable variance components |
h2 |
Heritability of the trait to be simulated for the population. |
This function returns a scaled SNP effect, scaled BV along with phenotypic, additive and residual variance.
popRescale <- matrix(c(0,1,1,0, 1,0,0,0, 1,1,1,1, 1,1,1,0), byrow = TRUE, nrow = 4, ncol = 4) QTLEff = c(0.1, 0.2, 0, 0) RescaleEff <- Rescale(Haplotype = popRescale, Effect = QTLEff, Phenosd = 4, h2 = 0.2)popRescale <- matrix(c(0,1,1,0, 1,0,0,0, 1,1,1,1, 1,1,1,0), byrow = TRUE, nrow = 4, ncol = 4) QTLEff = c(0.1, 0.2, 0, 0) RescaleEff <- Rescale(Haplotype = popRescale, Effect = QTLEff, Phenosd = 4, h2 = 0.2)
Function to select the sire.
SireSample(Haplotype, nSire, nProgeny)SireSample(Haplotype, nSire, nProgeny)
Haplotype |
Haplotype information of the population where rows are number of animals and columns are number of markers in matrix form. In case of haplotype, 2 rows provide information on genomic material of an animal. |
nSire |
Number of sires to be selected as parents for the simulation. |
nProgeny |
Number of progeny to be simulated in the population. |
Returns a list of sire IDs and haplotype information of the sire.
popH <- matrix(data = sample(c(0,1), 60, replace = TRUE), nrow = 6, ncol = 10) popH_Sire <- SireSample(Haplotype = popH, nSire = 1, nProgeny = 4)popH <- matrix(data = sample(c(0,1), 60, replace = TRUE), nrow = 6, ncol = 10) popH_Sire <- SireSample(Haplotype = popH, nSire = 1, nProgeny = 4)
Function to estimate true breeding value.
TBV_Haplo(Haplotype, Effect)TBV_Haplo(Haplotype, Effect)
Haplotype |
Haplotype (0,1) information of the population where rows are number of animals and columns are number of markers in matrix form. In case of haplotype, 2 rows provide information on genomic material of an animal. |
Effect |
A vector comprising the SNP effects of the population. |
Returns a haplotype information with TBV estimated from animal's haplotype information. The TBV mentioned in "TBV" column provides final TBV (sum of TBV from haplotype of the animal) for an animal.
popE <- matrix(data= sample(c(0,1), 16, replace= TRUE), nrow = 4, ncol = 4) QTLEff <- c(0.2, 0.1, 0.3, 0.1) TBV_haplotype <- TBV_Haplo(Haplotype = popE, Effect = QTLEff)popE <- matrix(data= sample(c(0,1), 16, replace= TRUE), nrow = 4, ncol = 4) QTLEff <- c(0.2, 0.1, 0.3, 0.1) TBV_haplotype <- TBV_Haplo(Haplotype = popE, Effect = QTLEff)
Function to calculate true breed proportion in an animal with coded haplotype information.
trueBreedComp(Haplotype)trueBreedComp(Haplotype)
Haplotype |
A matrix with coded haplotype information of the population where rows are number of animals and columns are number of markers in matrix form. In case of haplotype, 2 rows provide information on genomic material of an animal. |
Returns true breed proportion of population with coded haplotype.
P1 <- matrix(data = sample(c(-1, 1, 2, -2), 20, replace = TRUE), nrow = 4, ncol = 5) TBP <- trueBreedComp(Haplotype = P1)P1 <- matrix(data = sample(c(-1, 1, 2, -2), 20, replace = TRUE), nrow = 4, ncol = 5) TBP <- trueBreedComp(Haplotype = P1)
Function for making a cross between two populations.
TwoPopCross( map = map, populationSim_A, populationSim_B, nSireA = 54, nDamA = 1000, nSireB = 26, nDamB = 1000, Sire_From, mutationRate = 2.5 * 10^-5, SelType, h2 = 0.3, trait_mean, VarE_PopA, VarE_PopB, Effect_PopA, Effect_PopB, IndStartVal = 1, prefixID = "Cr", nProgeny = 1000, recL, nChr, recProb, minLength )TwoPopCross( map = map, populationSim_A, populationSim_B, nSireA = 54, nDamA = 1000, nSireB = 26, nDamB = 1000, Sire_From, mutationRate = 2.5 * 10^-5, SelType, h2 = 0.3, trait_mean, VarE_PopA, VarE_PopB, Effect_PopA, Effect_PopB, IndStartVal = 1, prefixID = "Cr", nProgeny = 1000, recL, nChr, recProb, minLength )
map |
Map file for the population comprising of marker ID, chromosome number and marker position. |
populationSim_A |
Coded haplotype information of the population A where rows are number of animals and columns are number of markers in matrix form. In case of haplotype, 2 rows provide information on genomic material of an animal. |
populationSim_B |
Coded haplotype information of the population B where rows are number of animals and columns are number of markers in matrix form. In case of haplotype, 2 rows provide information on genomic material of an animal. |
nSireA |
Number of sires to be selected as parents for the simulation from population A. |
nDamA |
Number of dams to be selected as parents for the simulation from population A. |
nSireB |
Number of sires to be selected as parents for the simulation from population B. |
nDamB |
Number of dams to be selected as parents for the simulation from population B. |
Sire_From |
The population from which sires should being selected for cross population. If sire should be selected from population A, then use "A" and if sire should be selected from population B, then use "B". |
mutationRate |
Mutation rate to added to the simulated population. |
SelType |
Selection Type. It can be based on phenotype, random or true breeding value. The default selection type is "random". For phenotypic selection, use "Pheno" and for true breeding value, use "TBV". |
h2 |
Heritability of the trait to be simulated. |
trait_mean |
Mean of the trait to be simulated. |
VarE_PopA |
Error Variance obtained after rescaling the QTL effects for PopA. |
VarE_PopB |
Error Variance obtained after rescaling the QTL effects for PopB. |
Effect_PopA |
SNP effect for the calculation of TBV for population A. |
Effect_PopB |
SNP effect for the calculation of TBV for population B. |
IndStartVal |
Starting value for the animal ID. |
prefixID |
Prefix to be added to the ID of the animal. |
nProgeny |
Number of progeny to be simulated in the population. |
recL |
Average number of recombinations to be introduced per animal. |
nChr |
Number of haploid chromosomes (n) defined in the population. |
recProb |
A vector of recombination probability between the markers. Its length should be total number of markers minus 1. User can define the recombination probability between markers helping in simulating a desired population. |
minLength |
Minimum length between recombination points beyond which recombination is allowed. The default value is 0. If a user define minimum length, it will ensure that difference between two recombination points less than minimum length won't allow recombination. |
List of Haplotype information , ID of the simulated animals, population with TBV and phenotype, recombination point list of sire and dam.
generateMAP(), PopSelect(), RecombinationPoint()
crossmap <- generateMAP(nChr = 5, n_markers = 2, len_Chr = 20) QTL_cross <- c(-0.001, 0.0003, 0, 0, 0, 0.0032, 0.0023, -0.0012,0, 0 ) P1cross <- matrix(data = sample(c(-1, 1), 40, replace = TRUE), nrow = 4, ncol = 10) P2cross <- matrix(data = sample(c(-2, 2), 40, replace = TRUE), nrow = 4, ncol = 10) P1cross <- PopulationID(Population = P1cross, PopCode = "P1") P2cross <- PopulationID(Population = P2cross, PopCode = "P2") F2cross <- TwoPopCross(map = crossmap, populationSim_A = P1cross, populationSim_B = P2cross, nSireA = 1, nDamA = 1, nSireB = 1, nDamB = 1, Sire_From = "A", mutationRate = 2.5 * 10^-5, SelType = "TBV", h2 = 0.3, Effect_PopA = QTL_cross, Effect_PopB = QTL_cross, IndStartVal = 1, prefixID ="Cr", nProgeny = 10, recL = 1, nChr = 2, minLength = 0, trait_mean = 5, VarE_PopA = 0.6, VarE_PopB = 0.6)crossmap <- generateMAP(nChr = 5, n_markers = 2, len_Chr = 20) QTL_cross <- c(-0.001, 0.0003, 0, 0, 0, 0.0032, 0.0023, -0.0012,0, 0 ) P1cross <- matrix(data = sample(c(-1, 1), 40, replace = TRUE), nrow = 4, ncol = 10) P2cross <- matrix(data = sample(c(-2, 2), 40, replace = TRUE), nrow = 4, ncol = 10) P1cross <- PopulationID(Population = P1cross, PopCode = "P1") P2cross <- PopulationID(Population = P2cross, PopCode = "P2") F2cross <- TwoPopCross(map = crossmap, populationSim_A = P1cross, populationSim_B = P2cross, nSireA = 1, nDamA = 1, nSireB = 1, nDamB = 1, Sire_From = "A", mutationRate = 2.5 * 10^-5, SelType = "TBV", h2 = 0.3, Effect_PopA = QTL_cross, Effect_PopB = QTL_cross, IndStartVal = 1, prefixID ="Cr", nProgeny = 10, recL = 1, nChr = 2, minLength = 0, trait_mean = 5, VarE_PopA = 0.6, VarE_PopB = 0.6)
Function to generate variance components and phenotype records for the simulated population.
Var_PhenoRecords(Haplotype, h2, trait_mean, VarE)Var_PhenoRecords(Haplotype, h2, trait_mean, VarE)
Haplotype |
Haplotype information (0,1) of the population where rows are number of animals and columns are number of markers in matrix form. In case of haplotype, 2 rows provide information on genomic material of an animal. |
h2 |
Heritability of the trait to be simulated. |
trait_mean |
Mean of the trait to be simulated. |
VarE |
Error Variance obtained after rescaling the QTL effects |
Additive genetic variance, phenotypic variance, error variance and haplotype marker information with phenotypic records.
popF <- matrix(data= sample(c(0,1), 16, replace= TRUE), nrow = 4, ncol = 4) QTLEff <- c(0.2, 0.1, 0.3, 0.1) TBV_haplotype <- TBV_Haplo(Haplotype = popF, Effect = QTLEff) Var_Ph_R <- Var_PhenoRecords(Haplotype = TBV_haplotype, h2 = 0.3, trait_mean = 20, VarE = 0.6)popF <- matrix(data= sample(c(0,1), 16, replace= TRUE), nrow = 4, ncol = 4) QTLEff <- c(0.2, 0.1, 0.3, 0.1) TBV_haplotype <- TBV_Haplo(Haplotype = popF, Effect = QTLEff) Var_Ph_R <- Var_PhenoRecords(Haplotype = TBV_haplotype, h2 = 0.3, trait_mean = 20, VarE = 0.6)