genomicSimulationC 0.3
|
For calculations related to the loaded allele effects and internal additive breeding value model. More...
Functions | |
gsc_GroupNum | gsc_split_by_bv (gsc_SimData *d, const gsc_GroupNum group, const gsc_EffectID effID, const unsigned int top_n, const _Bool lowIsBest) |
Takes the top_n individuals in the group with the best breeding values/fitnesses and puts them in a new group. More... | |
gsc_DecimalMatrix | gsc_calculate_bvs (const gsc_SimData *d, const gsc_GroupNum group, const gsc_EffectID effID) |
Calculate the fitness metric/breeding value for every genotype in the simulation or every genotype in a certain group. More... | |
gsc_DecimalMatrix | gsc_calculate_utility_bvs (gsc_BidirectionalIterator *targets, const gsc_MarkerEffects *effset) |
Calculate the fitness metric/breeding value for a set of genotypes. More... | |
gsc_DecimalMatrix | gsc_calculate_utility_local_bvs (gsc_BidirectionalIterator *targets, gsc_MarkerBlocks b, gsc_MarkerEffects e) |
Calculate local haplotype block breeding values for a set of genotypes. More... | |
gsc_DecimalMatrix | gsc_calculate_allele_counts (const gsc_SimData *d, const gsc_GroupNum group, const char allele) |
Calculates the number of times at each marker that a particular allele appears. More... | |
gsc_MarkerBlocks | gsc_create_evenlength_blocks_each_chr (const gsc_SimData *d, const gsc_MapID mapid, const unsigned int n) |
Divide the genotype into blocks where each block contains all markers within a 1/n length section of each chromosome in the map, and return the resulting blocks in a struct. More... | |
gsc_MarkerBlocks | gsc_load_blocks (const gsc_SimData *d, const char *block_file) |
Given a file containing definitions of blocks of markers, process that file and return a struct containing the definitions of those blocks. More... | |
gsc_DecimalMatrix | gsc_calculate_local_bvs (const gsc_SimData *d, const gsc_GroupNum group, const gsc_MarkerBlocks b, const gsc_EffectID effID) |
Calculate local breeding values for every genotype in the simulation or every genotype in a certain group across a given set of chromosome blocks. More... | |
void | gsc_calculate_optimal_haplotype (const gsc_SimData *d, const gsc_EffectID effID, const char symbol_na, char *opt_haplotype) |
Create a string containing the allele at each marker with the highest contributions to the additive breeding value. More... | |
void | gsc_calculate_optimal_possible_haplotype (const gsc_SimData *d, const gsc_GroupNum group, const gsc_EffectID effID, const char symbol_na, char *opt_haplotype) |
Calculates the highest-breeding-value haplotype that can be created from the alleles present in a given group. More... | |
double | gsc_calculate_optimal_bv (const gsc_SimData *d, const gsc_EffectID effID) |
Calculate the highest possible breeding value any (diploid) genotype could score using this set of marker effect values. More... | |
double | gsc_calculate_optimal_possible_bv (const gsc_SimData *d, const gsc_GroupNum group, const gsc_EffectID effID) |
Calculates the breeding value of the highest breeding-value genotype that can be created from the alleles present in a given group. More... | |
double | gsc_calculate_minimal_bv (const gsc_SimData *d, const gsc_EffectID effID) |
Calculate the lowest possible breeding value any (diploid) genotype could score using this set of marker effect values. More... | |
For calculations related to the loaded allele effects and internal additive breeding value model.
gsc_DecimalMatrix gsc_calculate_allele_counts | ( | const gsc_SimData * | d, |
const gsc_GroupNum | group, | ||
const char | allele | ||
) |
Calculates the number of times at each marker that a particular allele appears.
Returns the results in a calculated DecimalMatrix. This structure should be deleted with delete_dmatrix once there is no more use for it.
Has short name: calculate_allele_counts
d | simulation object containing the genotypes whose alleles will be counted |
group | NO_GROUP to count alleles of all genotypes in the simulation, or a specific group identifier to count only the alleles of members of that group. |
allele | the single-character allele to be counting. |
Definition at line 9569 of file sim-operations.c.
gsc_DecimalMatrix gsc_calculate_bvs | ( | const gsc_SimData * | d, |
const gsc_GroupNum | group, | ||
const gsc_EffectID | effID | ||
) |
Calculate the fitness metric/breeding value for every genotype in the simulation or every genotype in a certain group.
To calculate the breeding value, the number of copies of each allele at each marker for each genotype are counted. The counts of each allele are multiplied by the additive marker effect of that allele at that marker. Then, each genotype's allele effects across all markers are summed up.
Has short name: calculate_bvs
d | pointer to the gsc_SimData object in which the marker effects and genotypes to be used to calculate breeding values are stored. |
group | NO_GROUP to calculate breeding values for all genotypes in the simulation, or a group number to calculate breeding values for all members of that group. |
effID | Identifier of the marker effect set to be used to calculate these breeding values |
Definition at line 9469 of file sim-operations.c.
gsc_DecimalMatrix gsc_calculate_local_bvs | ( | const gsc_SimData * | d, |
const gsc_GroupNum | group, | ||
const gsc_MarkerBlocks | b, | ||
const gsc_EffectID | effID | ||
) |
Calculate local breeding values for every genotype in the simulation or every genotype in a certain group across a given set of chromosome blocks.
One local breeding value score will be calculated for each haplotype of a candidate at each chromosome block. Local breeding values are calculated the same way as full-genotype breeding values, by taking the allele counts, subtracting the centering value for the allele at that marker (if there is one), then multiplying by the effect value for that allele at that marker, and finally summing across all (relevant) markers. For a local breeding value, the relevant markers will be the ones that appear in the corresponding chromosome block, and only one allele per marker (from one haplotype) will contribute to the score.
Has short name: calculate_local_bvs
d | pointer to the gsc_SimData object that holds the genotypes to inspect |
group | NO_GROUP to calculate local breeding values for all genotypes in the simulation, or a group number to calculate local breeding values for members of that group. |
b | Set of chromosome blocks over which local breeding values should be calculated |
effID | Identifier of the marker effect set to be used to calculate local breeding values |
Definition at line 9876 of file sim-operations.c.
double gsc_calculate_minimal_bv | ( | const gsc_SimData * | d, |
const gsc_EffectID | effID | ||
) |
Calculate the lowest possible breeding value any (diploid) genotype could score using this set of marker effect values.
Has short name: calculate_minimal_bv
d | pointer to the gsc_SimData containing markers and marker effects. |
effID | Identifier of the marker effect set |
Definition at line 10291 of file sim-operations.c.
double gsc_calculate_optimal_bv | ( | const gsc_SimData * | d, |
const gsc_EffectID | effID | ||
) |
Calculate the highest possible breeding value any (diploid) genotype could score using this set of marker effect values.
The highest value genotype is completely homozygous with the same alleles as the haplotype from gsc_calculate_optimal_possible_haplotype(), because of the additive model of trait effects.
Has short name: calculate_optimal_bv
d | pointer to the gsc_SimData containing markers and marker effects. |
effID | Identifier of the marker effect set |
Definition at line 10172 of file sim-operations.c.
void gsc_calculate_optimal_haplotype | ( | const gsc_SimData * | d, |
const gsc_EffectID | effID, | ||
const char | symbol_na, | ||
char * | opt_haplotype | ||
) |
Create a string containing the allele at each marker with the highest contributions to the additive breeding value.
It saves the optimal haplotype as a null-terminated string to opt_haplotype. The alleles/markers are ordered as they are in d->genome.marker_names.
If two alleles have identical additive effects and centering values, there is no guarantee which one will be chosen as the "optimal" allele. If there are no marker effects recorded for alleles at that marker, no allele will be chosen and the marker's value in the optimal haplotype will be set to symbol_na.
Has short name: calculate_optimal_haplotype
d | pointer to the gsc_SimData containing markers and marker effects. |
effID | Identifier of the marker effect set to be used to calculate these breeding values |
symbol_na | character symbol to use to represent markers/positions where there are no marker effects and so no way to determine the best choice. |
opt_haplotype | an array of length at least ( d->genome.n_markers + 1 ), to which the optimal allele at each marker will be saved. |
Definition at line 10045 of file sim-operations.c.
double gsc_calculate_optimal_possible_bv | ( | const gsc_SimData * | d, |
const gsc_GroupNum | group, | ||
const gsc_EffectID | effID | ||
) |
Calculates the breeding value of the highest breeding-value genotype that can be created from the alleles present in a given group.
Has short name: calculate_optimal_possible_bv
d | pointer to the gsc_SimData containing markers and marker effects. |
group | number to look at the available alleles in |
effID | Identifier of the marker effect set to be used to calculate these breeding values |
Definition at line 10218 of file sim-operations.c.
void gsc_calculate_optimal_possible_haplotype | ( | const gsc_SimData * | d, |
const gsc_GroupNum | group, | ||
const gsc_EffectID | effID, | ||
const char | symbol_na, | ||
char * | opt_haplotype | ||
) |
Calculates the highest-breeding-value haplotype that can be created from the alleles present in a given group.
It saves the optimal haplotype that can be created with alleles from the group as a null-terminated string to opt_haplotype. The alleles/markers are ordered as they are in d->genome.marker_names.
If two alleles have identical additive effects and centering values, there is no guarantee which one will be chosen as the "optimal" allele. If there are no marker effects recorded for alleles at that marker, no allele will be chosen and the marker's value in the optimal haplotype will be set to symbol_na.
Has short name: calculate_optimal_possible_haplotype
d | pointer to the gsc_SimData containing markers and marker effects. |
group | group number to look at the available alleles in |
effID | Identifier of the marker effect set to be used to calculate these breeding values |
symbol_na | character symbol to use to represent markers/positions where there are no marker effects and so no way to determine the best choice. |
opt_haplotype | an array of length at least ( d->genome.n_markers + 1 ), to which the optimal allele at each marker will be saved. |
Definition at line 10104 of file sim-operations.c.
gsc_DecimalMatrix gsc_calculate_utility_bvs | ( | gsc_BidirectionalIterator * | targets, |
const gsc_MarkerEffects * | effset | ||
) |
Calculate the fitness metric/breeding value for a set of genotypes.
To calculate the breeding value, count each allele at each marker, subtract from those counts the centering value of the appropriate allele for that marker (if there is one), and then multiply the result by the effect value of that allele for that marker.
targets | Iterator for the genotypes whose breeding values are to be calculated. |
e | Set of additive marker effects to use to calculate the breeding values. |
Definition at line 9499 of file sim-operations.c.
gsc_DecimalMatrix gsc_calculate_utility_local_bvs | ( | gsc_BidirectionalIterator * | targets, |
gsc_MarkerBlocks | b, | ||
gsc_MarkerEffects | e | ||
) |
Calculate local haplotype block breeding values for a set of genotypes.
To calculate the breeding value for one haplotype of one chromosome block, for each marker, subtract the centering value of its allele (if there is such a value) from 1, then take the centered count (or raw count, if there is no centering value) and multiply it by the effect value for that allele at that marker, and add up these products acros all markers in the chromosome block.
targets | Iterator for the genotypes whose breeding values are to be calculated. |
b | Chromosome blocks for which local breeding values should be calculated. |
e | Set of additive marker effects to use to calculate the breeding values. |
Definition at line 9912 of file sim-operations.c.
gsc_MarkerBlocks gsc_create_evenlength_blocks_each_chr | ( | const gsc_SimData * | d, |
const gsc_MapID | mapid, | ||
const unsigned int | n | ||
) |
Divide the genotype into blocks where each block contains all markers within a 1/n length section of each chromosome in the map, and return the resulting blocks in a struct.
Chromosomes where there are no markers tracked are excluded/no blocks are created in those chromosomes.
Chromosomes where only one marker is tracked put the marker in the first block, and have all other blocks empty.
Empty blocks have blocks.num_markers_in_block[index] equal to 0 and contain a null pointer at blocks.markers_in_block[index].
Remember to call the gsc_MarkerBlocks destructor gsc_delete_markerblocks() on the returned struct.
Has short name: create_evenlength_blocks_each_chr
d | pointer to the gsc_SimData object to which the groups and individuals belong. It must have a marker effect file loaded to successfully run this function. |
mapid | ID of the recombination map whose markers and chromosomes will be divided into blocks, or NO_MAP to use the first-loaded/primary map by default. |
mapid | recombination map to use to determine block lengths and marker allocations to blocks. If this value is NO_MAP, uses first/primary map. |
n | number of blocks into which to split each chromosome. |
Definition at line 9630 of file sim-operations.c.
gsc_MarkerBlocks gsc_load_blocks | ( | const gsc_SimData * | d, |
const char * | block_file | ||
) |
Given a file containing definitions of blocks of markers, process that file and return a struct containing the definitions of those blocks.
The block file is designed after the output from a call to the R SelectionTools package's st.def.hblocks
function. It should have the format (tab-separated):
Chrom Pos Name Class Markers
[ignored] [ignored] [ignored] [ignored] [semicolon];[separated];[list] ;[of];[marker];[names];[belonging];[to];[this];[block];
...
Has short name: load_blocks
d | pointer to the gsc_SimData object to which the groups and individuals belong. It must have a marker effect file loaded to successfully run this function. |
block_file | string containing filename of the file with blocks |
Definition at line 9783 of file sim-operations.c.
gsc_GroupNum gsc_split_by_bv | ( | gsc_SimData * | d, |
const gsc_GroupNum | group, | ||
const gsc_EffectID | effID, | ||
const unsigned int | top_n, | ||
const _Bool | lowIsBest | ||
) |
Takes the top_n
individuals in the group with the best breeding values/fitnesses and puts them in a new group.
The new group number is returned.
Has short name: split_by_bv
d | pointer to the gsc_SimData object to which the groups and individuals belong. It must have a marker effect file loaded to successfully run this function. |
group | group number from which to split the top individuals. |
effID | Identifier of the set of marker effects to use to calculate BV. |
top_n | The number of individuals to put in the new group. |
lowIsBest | boolean, if TRUE the top_n with the lowest breeding value will be selected, if false the top_n with the highest breeding value are. |
Definition at line 9396 of file sim-operations.c.