genomicSimulationC 0.3
Functions
Breeding Value and Allele Count Calculators

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...
 

Detailed Description

For calculations related to the loaded allele effects and internal additive breeding value model.

Function Documentation

◆ gsc_calculate_allele_counts()

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

Parameters
dsimulation object containing the genotypes whose alleles will be counted
groupNO_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.
allelethe single-character allele to be counting.
Returns
a (num genotypes x num markers) gsc_DecimalMatrix, with each cell containing the number of incidences of the allele. The first axis of the DecimalMatrix corresponds to candidate genotypes, the second axis corresponds to genetic markers.

Definition at line 9569 of file sim-operations.c.

+ Here is the call graph for this function:

◆ gsc_calculate_bvs()

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

Parameters
dpointer to the gsc_SimData object in which the marker effects and genotypes to be used to calculate breeding values are stored.
groupNO_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.
effIDIdentifier of the marker effect set to be used to calculate these breeding values
Returns
A (1 x number of genotypes) gsc_DecimalMatrix containing the breeding value scores

Definition at line 9469 of file sim-operations.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gsc_calculate_local_bvs()

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

Parameters
dpointer to the gsc_SimData object that holds the genotypes to inspect
groupNO_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.
bSet of chromosome blocks over which local breeding values should be calculated
effIDIdentifier of the marker effect set to be used to calculate local breeding values
Returns
A (twice the number of genotypes under investigation) x (the number of chromsome blocks in b) gsc_DecimalMatrix containing the local breeding value scores for left and right haplotype of every candidate investigated across all the chromosome blocks.

Definition at line 9876 of file sim-operations.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gsc_calculate_minimal_bv()

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

Parameters
dpointer to the gsc_SimData containing markers and marker effects.
effIDIdentifier of the marker effect set
Returns
the breeding value of the lowest scoring genotype calculated using that marker effect set

Definition at line 10291 of file sim-operations.c.

+ Here is the call graph for this function:

◆ gsc_calculate_optimal_bv()

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

Parameters
dpointer to the gsc_SimData containing markers and marker effects.
effIDIdentifier of the marker effect set
Returns
the breeding value of the best/ideal genotype calculated using that marker effect set

Definition at line 10172 of file sim-operations.c.

+ Here is the call graph for this function:

◆ gsc_calculate_optimal_haplotype()

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

Parameters
dpointer to the gsc_SimData containing markers and marker effects.
effIDIdentifier of the marker effect set to be used to calculate these breeding values
symbol_nacharacter symbol to use to represent markers/positions where there are no marker effects and so no way to determine the best choice.
opt_haplotypean 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.

+ Here is the call graph for this function:

◆ gsc_calculate_optimal_possible_bv()

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

Parameters
dpointer to the gsc_SimData containing markers and marker effects.
groupnumber to look at the available alleles in
effIDIdentifier of the marker effect set to be used to calculate these breeding values
Returns
the fitness metric/breeding value of the best genotype

Definition at line 10218 of file sim-operations.c.

+ Here is the call graph for this function:

◆ gsc_calculate_optimal_possible_haplotype()

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

Parameters
dpointer to the gsc_SimData containing markers and marker effects.
groupgroup number to look at the available alleles in
effIDIdentifier of the marker effect set to be used to calculate these breeding values
symbol_nacharacter symbol to use to represent markers/positions where there are no marker effects and so no way to determine the best choice.
opt_haplotypean 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.

+ Here is the call graph for this function:

◆ gsc_calculate_utility_bvs()

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.

Parameters
targetsIterator for the genotypes whose breeding values are to be calculated.
eSet of additive marker effects to use to calculate the breeding values.
Returns
(1 x number of genotypes in iterator) gsc_DecimalMatrix, containing the breeding value scores

Definition at line 9499 of file sim-operations.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gsc_calculate_utility_local_bvs()

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.

Parameters
targetsIterator for the genotypes whose breeding values are to be calculated.
bChromosome blocks for which local breeding values should be calculated.
eSet of additive marker effects to use to calculate the breeding values.
Returns
(twice the of genotypes in iterator x number of chromosome blocks) gsc_DecimalMatrix, containing the breeding value scores. Even indexes of the first dimension contain local scores for the first haplotype, odd indexes contain local scores for the second haplotype. Candidates and chromsome blocks are ordered as they are in it and b respectively.

Definition at line 9912 of file sim-operations.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gsc_create_evenlength_blocks_each_chr()

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

Parameters
dpointer 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.
mapidID 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.
mapidrecombination map to use to determine block lengths and marker allocations to blocks. If this value is NO_MAP, uses first/primary map.
nnumber of blocks into which to split each chromosome.
Returns
a struct containing the markers identified as belonging to each block.

Definition at line 9630 of file sim-operations.c.

+ Here is the call graph for this function:

◆ gsc_load_blocks()

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

Parameters
dpointer 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_filestring containing filename of the file with blocks
Returns
a struct containing the markers identified as belonging to each block according to their definitions in the file.

Definition at line 9783 of file sim-operations.c.

+ Here is the call graph for this function:

◆ gsc_split_by_bv()

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

Parameters
dpointer 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.
groupgroup number from which to split the top individuals.
effIDIdentifier of the set of marker effects to use to calculate BV.
top_nThe number of individuals to put in the new group.
lowIsBestboolean, if TRUE the top_n with the lowest breeding value will be selected, if false the top_n with the highest breeding value are.
Returns
the group number of the newly-created split-off group

Definition at line 9396 of file sim-operations.c.

+ Here is the call graph for this function: