genomicSimulationC 0.2.6
|
For saving persistent simulation results. More...
Functions | |
void | gsc_save_markerblocks (const char *fname, const gsc_SimData *d, const gsc_MarkerBlocks b, const gsc_MapID labelMapID) |
Prints the markers contained in a set of blocks to a file. More... | |
void | gsc_save_genotypes (const char *fname, const gsc_SimData *d, const gsc_GroupNum groupID, const _Bool markers_as_rows) |
Prints genotypes from the simulation to a file. More... | |
void | gsc_save_allele_counts (const char *fname, const gsc_SimData *d, const gsc_GroupNum groupID, const char allele, const _Bool markers_as_rows) |
Prints allele counts of genotypes from the simulation to a file. More... | |
void | gsc_save_pedigrees (const char *fname, const gsc_SimData *d, const gsc_GroupNum groupID, const _Bool full_pedigree) |
Prints pedigrees of genotypes in the simulation to a file. More... | |
void | gsc_save_bvs (const char *fname, const gsc_SimData *d, const gsc_GroupNum groupID, const gsc_EffectID effID) |
Prints breeding values of genotypes in the simulation to a file. More... | |
void | gsc_save_utility_markerblocks (FILE *f, const gsc_MarkerBlocks b, const unsigned int n_markers, char **const marker_names, const gsc_RecombinationMap *map) |
Prints the markers contained in a set of blocks to a file. More... | |
void | gsc_save_utility_genotypes (FILE *f, gsc_BidirectionalIterator *targets, const unsigned int n_markers, char **const marker_names, const _Bool markers_as_rows) |
Prints simulated genotypes to a file. More... | |
void | gsc_save_utility_allele_counts (FILE *f, gsc_BidirectionalIterator *targets, const unsigned int n_markers, char **const marker_names, const _Bool markers_as_rows, const char allele) |
Prints allele counts of simulated genotypes to a file. More... | |
void | gsc_save_utility_pedigrees (FILE *f, gsc_BidirectionalIterator *targets, const _Bool full_pedigree, const gsc_AlleleMatrix *parent_pedigree_store) |
Prints pedigrees to a file. More... | |
void | gsc_save_utility_bvs (FILE *f, gsc_BidirectionalIterator *targets, const gsc_EffectMatrix *eff) |
Calculate and print breeding values to a file. More... | |
For saving persistent simulation results.
void gsc_save_allele_counts | ( | const char * | fname, |
const gsc_SimData * | d, | ||
const gsc_GroupNum | groupID, | ||
const char | allele, | ||
const _Bool | markers_as_rows | ||
) |
Prints allele counts of genotypes from the simulation to a file.
The output file will contain a matrix of genetic markers by genotypes (or vice-versa), with each cell in the body of the matrix containing the the allele counts of a some allele for each genetic marker.
For more details on printings format,
Has short name: save_allele_counts
fname | name of the file to which the output will be saved. Any prior file contents will be overwritten. |
d | pointer to the gsc_SimData in which the genotypes to be saved can be found. |
groupID | group number of the group of genotypes to save allele counts for, or NO_GROUP to save allele counts for all genotypes in the simulation. |
allele | the allele to count occurences of |
markers_as_rows | If true, genetic markers will be rows in the output matrix, and genotypes will be columns. If false, genetic markers will be columns in the output matrix, and genotypes will be rows. |
Definition at line 10175 of file sim-operations.c.
void gsc_save_bvs | ( | const char * | fname, |
const gsc_SimData * | d, | ||
const gsc_GroupNum | groupID, | ||
const gsc_EffectID | effID | ||
) |
Prints breeding values of genotypes in the simulation to a file.
Has short name: save_bvs
fname | name of the file to which the output will be saved. Any prior file contents will be overwritten. |
d | pointer to the gsc_SimData in which the genotypes whose breeding values will be calculated can be found. |
groupID | group number of the group of genotypes whose breeding values will be saved, or NO_GROUP to save breeding values of all genotypes in the simulation. |
effID | identifier of the set of marker effects in d that will be used to calculate the breeding values. |
Definition at line 10249 of file sim-operations.c.
void gsc_save_genotypes | ( | const char * | fname, |
const gsc_SimData * | d, | ||
const gsc_GroupNum | groupID, | ||
const _Bool | markers_as_rows | ||
) |
Prints genotypes from the simulation to a file.
The output file will contain a matrix of genetic markers by genotypes (or vice-versa), with each cell in the body of the matrix containing the (phased) pair of alleles belonging to that genotype at that genetic marker.
For more details on printings format,
Has short name: save_genotypes
fname | name of the file to which the output will be saved. Any prior file contents will be overwritten. |
d | pointer to the gsc_SimData in which the genotypes to be saved can be found. |
groupID | group number of the group of genotypes to save, or NO_GROUP to save all genotypes in the simulation. |
markers_as_rows | If true, genetic markers will be rows in the output matrix, and genotypes will be columns. If false, genetic markers will be columns in the output matrix, and genotypes will be rows. |
Definition at line 10137 of file sim-operations.c.
void gsc_save_markerblocks | ( | const char * | fname, |
const gsc_SimData * | d, | ||
const gsc_MarkerBlocks | b, | ||
const gsc_MapID | labelMapID | ||
) |
Prints the markers contained in a set of blocks to a file.
Two printing formats are available.
Has short name: save_markerblocks
fname | name of the file to which the output will be saved. Any prior file contents will be overwritten. |
d | pointer to the gsc_SimData from which marker names and chromsome allocations will be accessed. |
b | gsc_MarkerBlocks struct containing the groupings of markers to print. |
labelMapID | If this paramter is a valid map ID, the function will save the marker blocks in the three-column format, with their chromosome index and size. Otherwise, if this value is NO_MAP or an invalid map ID, the function will save the marker blocks in the simple format. The formats are described in the documentation of the function gsc_save_utility_markerblocks |
Definition at line 10101 of file sim-operations.c.
void gsc_save_pedigrees | ( | const char * | fname, |
const gsc_SimData * | d, | ||
const gsc_GroupNum | groupID, | ||
const _Bool | full_pedigree | ||
) |
Prints pedigrees of genotypes in the simulation to a file.
Two printing formats are available.
Genotype information is not retained after deletion. This includes PedigreeIDs. This means that if the parents or ancestor genotypes have already been deleted, they will be deemed missing and will not appear in the pedigree.
Has short name: save_pedigrees
fname | name of the file to which the output will be saved. Any prior file contents will be overwritten. |
d | pointer to the gsc_SimData in which the genotypes whose pedigrees will be saved can be found. |
groupID | group number of the group of genotypes whose pedigrees will be saved, or NO_GROUP to save pedigrees of all genotypes in the simulation. |
full_pedigree | If true, pedigrees will be traced back recursively through all genotypes in the simulation. If false, only the two immediate parents of the genotype will be located. For more information |
Definition at line 10216 of file sim-operations.c.
void gsc_save_utility_allele_counts | ( | FILE * | f, |
gsc_BidirectionalIterator * | targets, | ||
unsigned int | n_markers, | ||
char **const | marker_names, | ||
const _Bool | markers_as_rows, | ||
const char | allele | ||
) |
Prints allele counts of simulated genotypes to a file.
For a more user-friendly interface to this function:
The output file will contain a matrix of genetic markers by genotypes (or vice-versa), with each cell in the body of the matrix containing the allele counts of a some allele for each genetic marker.
If the genetic markers are the columns of the matrix (i.e. markers_as_rows = GSC_FALSE) the output file format will be approximately:
1 [marker name] [marker name]
[pedigree id]OR[genotype name] [allele count for each marker]
[pedigree id]OR[genotype name] [allele count for each marker]
...
The top left corner cell will be blank, if the iterator targets is iterating through all genotypes. If the iterator is iterating through the members of a group, the top left corner cell will contain the group number.
If a genetic marker does not have a name, the corresponding header row cell will be left blank. If a genotype does not have a name, the corresponding header column cell will contain its PedigreeID instead. If it has no name and no allocated PedigreeID, this cell will read 0 (because NO_PEDIGREE.id = 0).
If the genetic markers are the rows of the matrix (i.e. markers_as_rows = GSC_TRUE), the above matrix will be transposed.
This function can be called with targets = NULL. In that case, it will print only the marker names, as a header row or a header column, depending on the value of markers_as_rows.
f | file pointer opened for writing to put the output |
targets | iterator for the genotypes whose genotypes will be saved |
n_markers | length of the vector marker_names |
marker_names | list of marker names, ordered so that they correspond to the order of markers in the genotypes in targets. This is best achieved by taking marker_names from a SimData.genome.marker_names, and the AlleleMatrix input for gsc_create_bidirectional_iter for targets being the same SimData's SimData->m. |
markers_as_rows | If GSC_TRUE, genetic markers will be rows in the output matrix, and genotypes will be columns. If GSC_FALSE, genetic markers will be columns in the output matrix, and genotypes will be rows. |
allele | the allele to count |
Definition at line 10687 of file sim-operations.c.
void gsc_save_utility_bvs | ( | FILE * | f, |
gsc_BidirectionalIterator * | targets, | ||
const gsc_EffectMatrix * | eff | ||
) |
Calculate and print breeding values to a file.
For a more user-friendly interface to this function:
The output file format will be a three-column tab-separated file. The three columns will contain the genotype's pedigree ID in the first column, its name (if it has one; blank if it has no name) in the second column, and the calculated breeding value in the third column:
[genotype's PedigreeID] [genotype's name] [bv]
...
f | file pointer opened for writing to put the output |
targets | iterator for the genotypes whose breeding values will be saved |
eff | matrix of additive marker effects to be used to calculate the breeding values |
Definition at line 10931 of file sim-operations.c.
void gsc_save_utility_genotypes | ( | FILE * | f, |
gsc_BidirectionalIterator * | targets, | ||
unsigned int | n_markers, | ||
char **const | marker_names, | ||
const _Bool | markers_as_rows | ||
) |
Prints simulated genotypes to a file.
For a more user-friendly interface to this function:
The output file will contain a matrix of genetic markers by genotypes (or vice-versa), with each cell in the body of the matrix containing the (phased) pair of alleles belonging to that genotype at that genetic marker.
If the genetic markers are the columns of the matrix (i.e. markers_as_rows = GSC_FALSE) the output file format will be approximately:
1 [marker name] [marker name]
[pedigree id]OR[genotype name] [allele pairs for each marker]
[pedigree id]OR[genotype name] [allele pairs for each marker]
...
The top left corner cell will be blank, if the iterator targets is iterating through all genotypes. If the iterator is iterating through the members of a group, the top left corner cell will contain the group number.
If a genetic marker does not have a name, the corresponding header row cell will be left blank. If a genotype does not have a name, the corresponding header column cell will contain its PedigreeID instead. If it has no name and no allocated PedigreeID, this cell will read 0 (because NO_PEDIGREE.id = 0).
If the genetic markers are the rows of the matrix (i.e. markers_as_rows = GSC_TRUE), the above matrix will be transposed.
This function can be called with targets = NULL. In that case, it will print only the marker names, as a header row or a header column, depending on the value of markers_as_rows.
f | file pointer opened for writing to put the output |
targets | iterator for the genotypes whose genotypes will be saved |
n_markers | length of the vector marker_names |
marker_names | list of marker names, ordered so that they correspond to the order of markers in the genotypes in targets. This is best achieved by taking marker_names from a SimData.genome.marker_names, and the AlleleMatrix input for gsc_create_bidirectional_iter for targets being the same SimData's SimData->m. |
markers_as_rows | If GSC_TRUE, genetic markers will be rows in the output matrix, and genotypes will be columns. If GSC_FALSE, genetic markers will be columns in the output matrix, and genotypes will be rows. |
Definition at line 10630 of file sim-operations.c.
void gsc_save_utility_markerblocks | ( | FILE * | f, |
const gsc_MarkerBlocks | b, | ||
const unsigned int | n_markers, | ||
char **const | marker_names, | ||
const gsc_RecombinationMap * | map | ||
) |
Prints the markers contained in a set of blocks to a file.
For a more user-friendly interface to this function:
Two printing formats are available. The simple printing format each block's markers as a semicolon-separated list, with each line representing one block. Eg:
m1;m2;m3;m4;
m7;m9;
...
where m1, m2, m3, m4 are the names of the markers in the first block and m7 and m9 are the names of the markers in the second block. This format will be printed if no genetic map is provided.
Alternatively, if a valid genetic map is provided, this function will print out two extra columns of information. If all markers in the block belong to the same linkage group/chromosome, according to the suggested genetic map, then the first column of the file will contain the index of the chromosome in the map, and the second column will contain the length of the block in centimorgans. If not all markers in the block belong to the same chromosome, these columns' values will be replaced with dashes. Eg:
Chrom Len Markers
0 5.500000 m1;m2;m3;m4;
...
where m7 and m9 from the second block are not on the same chromosome, but m1, m2, m3, and m4 are all on the first chromosome (index=0) in the map. The largest distance between two markers out of m1, m2, m3 and m4 is 5.5 centimorgans.
Note that, since genomicSimulation does not save the names of chromosomes, the values in the "Chrom" column will not correspond to the names of the chromosomes in the input genetic map. To find which chromsomes correspond to which chromosome indexes in the output of this function, you can order the chromosome names from shortest to longest, and order chromosome names of the same length alphanumerically. Eg. Chromosome names "1A", "1B", and "2" would be ordered as: 2 (chrom index 0), 1A (chrom index 1), 1B (chrom index 2).
f | file pointer opened for writing to put the output |
b | gsc_MarkerBlocks struct containing the groupings of markers to print |
n_markers | length of the vector marker_names |
marker_names | list of marker names, ordered so that indexes in b can be accessed to get the corresponding marker name |
map | If NULL, this function will save the marker blocks in the simple format. If not null, this function will save the marker blocks in the three-column format, with their chromosome index and length calculated from this genetic map. Both formats are described in this function's documentation. |
Definition at line 10362 of file sim-operations.c.
void gsc_save_utility_pedigrees | ( | FILE * | f, |
gsc_BidirectionalIterator * | targets, | ||
const _Bool | full_pedigree, | ||
const gsc_AlleleMatrix * | parent_pedigree_store | ||
) |
Prints pedigrees to a file.
For a more user-friendly interface to this function:
Where genotypes and their parents have names, their names will be printed as their identifiers within the pedigrees. When an individual in the pedigree does not have a name, its PedigreeID will be printed in the pedigree instead. When an individual in the pedigree has no name and no PedigreeID, it is considered equivalent to an unknown individual and nothing is printed in the pedigree.
There are two output formats available with this function.
If only the immediate parents are to be printed (i.e. full_pedigree = false), then the output file format will be a three-column tab-delimited file, with the genotype's identifier in the first column and its parents' identifiers in the second and third columns. The second and third columns will be blank if no parent can be located in parent_pedigree_store. Example of this file format follows, where g1206 has unknown parents:
g1204 g30 g31
g1205 founderC founderC
g1206
...
The alternate output format is printed if full_pedigree = true. In this format, the first column of the file gives the pedigree ID of the genotype. The second column is a recursively constructed string. First, it contains the identifier of the genotype. If the genotype's parents can be located, it then prints an equals sign and open bracket ("=("), the (similarly generated) pedigree of the first and second parents, separated by a comma. Finally, it adds a closing bracket (")"). If the parent is repeated, its pedigree is only printed once (see second row of the example format below):
204 g1204=(g30,g31=(founderA,founderB))
205 g1205=(founderC)
206 g1206
...
In the first column of this file format, a missing or untracked PedigreeID will be printed as 0. (As stated above in this documentation, elsewhere in these pedigree output files, missing/untracked PedigreeIDs are not printed.)
f | file pointer opened for writing to put the output |
targets | iterator for the genotypes whose pedigrees will be saved |
full_pedigree | If GSC_FALSE, the three-column immediate-parents-only file format will be printed. If GSC_TRUE, the file format with the recursively constructed full pedigrees will be printed. |
parent_pedigree_store | All parents and ancestors that are to be included in the printed pedigree must exist somewhere in this linked list of AlleleMatrix structures. Parents or ancestors that cannot be found in here will be deemed "unknown" and will not be printed. |
Definition at line 10841 of file sim-operations.c.