# Genetic Tools for Colony Management

## Documentation for package ‘nprcgenekeepr’ version 1.0.7

- DESCRIPTION file.
- User guides, package vignettes and other documentation.
- Package NEWS.

## Help Pages

A C D E F G H I K L M N O P Q R S T W

## -- A --

addAnimalsWithNoRelative | Adds an NA value for all animals without a relative
addBackSecondParents | Add back single parents trimmed pedigree
addGenotype | Add genotype data to pedigree file
addIdRecords | addIdRecords Adds Ego records added having NAs for parent IDs
addParents | Add parents
addSexAndAgeToGroup | Forms a dataframe with Id, Sex, and current Age given a list of Ids and a pedigree
addUIds | Eliminates partial parentage situations by adding unique placeholder IDs for the unknown parent.
alleleFreq | Calculates the count of each allele in the provided vector.
assignAlleles | Assign parent alleles randomly

## -- C --

calcA | Calculates 'a', the number of an individual's alleles that are rare in each simulation.
calcAge | Calculate animal ages.
calcFE | Calculates founder Equivalents
calcFEFG | Calculates Founder Equivalents and Founder Genome Equivalents
calcFG | Calculates Founder Genome Equivalents
calcGU | Calculates genome uniqueness for each ID that is part of the population.
calcRetention | Calculates Allelic Retention
calculateSexRatio | Calculates the sex ratio (number of non-males / number of males) given animal Ids and their pedigree
checkChangedColsLst | checkChangedColsLst examines list for non-empty fields
checkErrorLst | checkErrorLst examines list for non-empty fields
checkGenotypeFile | Check genotype file
checkParentAge | Check parent ages to be at least 'minParentAge'
checkRequiredCols | Examines column names, 'cols' for required column names
chooseAlleles | Combines two vectors of alleles by randomly selecting one allele or the other at each position.
chooseDate | Choose date based on 'earlier' flag.
convertAncestry | Converts the ancestry information to a standardized code
convertDate | Converts date columns formatted as characters to be of type datetime
convertFromCenter | Converts the fromCenter information to a standardized code
convertRelationships | Converts pairwise kinship values to a relationship category descriptor.
convertSexCodes | Converts sex indicator for an individual to a standardized codes.
convertStatusCodes | Converts status indicators to a Standardized code
correctParentSex | Sets sex for animals listed as either a sire or dam.
countFirstOrder | Count first-order relatives.
countKinshipValues | Counts the number of occurrences of each kinship value seen for a pair of individuals in a series of simulated pedigrees.
countLoops | Count the number of loops in a pedigree tree.
createExampleFiles | Creates a folder with CSV files containing example pedigrees and ID lists used to demonstrate the package.
createPedTree | Create a pedigree tree (PedTree).
createSimKinships | Makes a list object of kinship matrices from simulated pedigrees of possible parents for animals with unknown parents
create_wkbk | Creates an Excel workbook with worksheets.
cumulateSimKinships | Makes a list object containing kinship summary statistics using the list object from *createSimKinships*.

## -- D --

dataframe2string | dataframe2string converts a data.frame object to a character vector

## -- E --

exampleNprcgenekeeprConfig | exampleNprcgenekeeprConfig is a loadable version of the example configuration file 'example_nprcgenekeepr_config'
examplePedigree | examplePedigree is a pedigree object created by 'qcStudbook'

## -- F --

fillGroupMembersWithSexRatio | Forms breeding group(s) with an effort to match a specified sex ratio
filterKinMatrix | Filters a kinship matrix to include only the egos listed in 'ids'
filterPairs | Filters kinship values from a long-format kinship table based on the sexes of the two animals involved.
filterReport | Filters a genetic value report down to only the specified animals
filterThreshold | Filters kinship to remove rows with kinship values less than the specified threshold
finalRpt | finalRpt is a list object created from the list object _rpt_ prepared by 'reportGV'. It is created inside 'orderReport'. This version is at the state just prior to calling 'rankSubjects' inside 'orderReport'.
findGeneration | Determines the generation number for each id.
findLoops | Find loops in a pedigree tree
findOffspring | Finds the number of total offspring for each animal in the provided pedigree.
findPedigreeNumber | Determines the generation number for each id.
fixColumnNames | fixColumnNames changes original column names and into standardized names.
focalAnimals | focalAnimals is a dataframe with one column (_id_) containing the of animal Ids from the *examplePedigree* pedigree.

## -- G --

geneDrop | Gene drop simulation based on the provided pedigree information
getAncestors | Recursively create a character vector of ancestors for an individual ID.
getAnimalsWithHighKinship | Forms a list of animal Ids and animals related to them
getChangedColsTab | getChangedColsTab skeleton of list of errors
getConfigFileName | getConfigFileName returns the configuration file name appropriate for the system.
getCurrentAge | Age in years using the provided birthdate.
getDatedFilename | Returns a character vector with an file name having the date prepended.
getDateErrorsAndConvertDatesInPed | Converts columns of dates in text form to 'Date' object columns
getDemographics | Get demographic data
getEmptyErrorLst | Creates a empty errorLst object
getErrorTab | getErrorTab skeleton of list of errors
getFocalAnimalPed | Get pedigree based on list of focal animals
getGenotypes | Get genotypes from file
getGVGenotype | Get Genetic Value Genotype data structure for reportGV function.
getGVPopulation | Get the population of interest for the Genetic Value analysis.
getIdsWithOneParent | getIdsWithOneParent extracts IDs of animals pedigree without either a sire or a dam
getIncludeColumns | Get the superset of columns that can be in a pedigree file.
getLkDirectAncestors | Get the direct ancestors of selected animals
getLkDirectRelatives | Get the direct ancestors of selected animals
getLogo | Get Logo file name
getOffspring | Get offspring to corresponding animal IDs provided
getParents | Get parents to corresponding animal IDs provided
getPedDirectRelatives | Get the direct ancestors of selected animals from supplied pedigree.
getPedigree | Get pedigree from file
getPedMaxAge | Get the maximum age of live animals in the pedigree.
getPossibleCols | Get possible column names for a studbook.
getPotentialParents | Get the lists of portential parents for all individuals born in the colony with one or two unknown parents.
getPotentialSires | Provides list of potential sires
getProbandPedigree | Gets pedigree to ancestors of provided group leaving uninformative ancestors.
getPyramidAgeDist | Get the age distribution for the pedigree
getPyramidPlot | Creates a pyramid plot of the pedigree provided.
getRequiredCols | Get required column names for a studbook.
getSiteInfo | Get site information
getTokenList | Gets tokens from character vector of lines
getVersion | getVersion Get the version number of nprcgenekeepr
get_and_or_list | Returns a one element character string with correct punctuation for a list made up of the elements of the character vector argument.
get_elapsed_time_str | Returns the elapsed time since start_time.
groupAddAssign | Add animals to an existing breeding group or forms groups:

## -- H --

hasBothParents | hasBothParents checks to see if both parents are identified.
hasGenotype | Check for genotype data in dataframe
headerDisplayNames | Convert internal column names to display or header names.

## -- I --

is_valid_date_str | Returns TRUE if the string is a valid date.

## -- K --

kinMatrix2LongForm | Reformats a kinship matrix into a long-format table.
kinship | Generates a kinship matrix.
kinshipMatricesToKValues | Forms kValue matrix from list of kinship matrices
kinshipMatrixToKValues | Extracts a dataframe with a row for each kinship coeficient in the kinship matrix

## -- L --

lacy1989Ped | lacy1989Ped small hypothetical pedigree
lacy1989PedAlleles | lacy1989PedAlleles is a dataframe produced by 'geneDrop' on 'lacy1989Ped' with 5000 iterations.

## -- M --

makeCEPH | Make a CEPH-style pedigree for each id
makeExamplePedigreeFile | Write copy of nprcgenekeepr::examplePedigree into a file
makeGroupMembers | Convenience function to make the initial groupMembers animal list
makeGrpNum | Convenience function to make the initial grpNum list
makeRelationClassesTable | Make relation classes table from 'kin' dataframe.
makeSimPed | Makes a simulated pedigree using representative sires and dams
mapIdsToObfuscated | Map IDs to Obfuscated IDs
meanKinship | Calculates the mean kinship for each animal in a kinship matrix

## -- N --

nprcgenekeepr | Genetic Tools for Colony Management

## -- O --

obfuscateDate | obfucateDate adds a random number of days bounded by plus and minus max delta
obfuscateId | obfucateId creates a vector of ID aliases of specified length
obfuscatePed | obfuscatePed takes a pedigree object and creates aliases for all IDs and adjusts all date within a specified amount.
offspringCounts | Finds the total number of offspring for each animal in the pedigree

## -- P --

ped1Alleles | ped1Alleles is a dataframe created by the geneDrop function
pedDuplicateIds | pedDuplicateIds is a dataframe with 9 rows and 5 columns (ego_id, sire, dam_id, sex, birth_date) representing a full pedigree with a duplicated record.
pedFemaleSireMaleDam | pedFemaleSireMaleDam is a dataframe with 8 rows and 5 columns (ego_id, sire, dam_id, sex, birth_date) representing a full pedigree with the errors of having a sire labeled as female and a dam labeled as male.
pedGood | pedGood is a dataframe with 8 rows and 5 columns (ego_id, sire, dam_id, sex, birth_date) representing a full pedigree with no errors.
pedInvalidDates | pedInvalidDates is a dataframe with 8 rows and 5 columns (ego_id, sire, dam_id, sex, birth_date) representing a full pedigree with values in the 'birth_date' column that are not valid dates.
pedMissingBirth | pedMissingBirth is a dataframe with 8 rows and 5 columns (ego_id, sire, dam_id, sex, birth_date) representing a full pedigree with no errors.
pedOne | pedOne is a loadable version of a pedigree file fragment used for testing and demonstration
pedSameMaleIsSireAndDam | pedSameMaleIsSireAndDam is a dataframe with 8 rows and 5 columns (ego_id, sire, dam_id, sex, birth_date) representing a full pedigree with no errors.
pedSix | pedSix is a loadable version of a pedigree file fragment used for testing and demonstration
pedWithGenotype | pedWithGenotype is a dataframe produced from qcPed by adding made up genotypes.
pedWithGenotypeReport | pedWithGenotypeReport is a list containing the output of 'reportGV'.
print.summary.nprcgenekeeprErr | print.summary.nprcgenekeepr print.summary.nprcgenekeeprGV
print.summary.nprcgenekeeprGV | print.summary.nprcgenekeepr print.summary.nprcgenekeeprGV

## -- Q --

qcBreeders | qcBreeders is a list of 29 baboon IDs that are potential breeders
qcPed | qcPed is a dataframe with 277 rows and 6 columns
qcPedGvReport | qcPedGvReport is a genetic value report
qcStudbook | Quality Control for the Studbook or pedigree

## -- R --

rankSubjects | Ranks animals based on genetic value.
removeAutoGenIds | Remove automatically generated IDs from pedigree
removeDuplicates | Remove duplicate records from pedigree
removeEarlyDates | removeEarlyDates removes dates before a specified year
removePotentialSires | Removes potential sires from list of Ids
removeUninformativeFounders | Remove uninformative founders.
removeUnknownAnimals | removeUnknownAnimals Removes unknown animals added to pedigree that serve as placeholders for unknown parents.
reportGV | Generates a genetic value report for a provided pedigree.
rhesusGenotypes | rhesusGenotypes is a dataframe with two haplotypes per animal
rhesusPedigree | rhesusPedigree is a pedigree object
runGeneKeepR | Allows running 'shiny' application with 'nprcgenekeepr::runGeneKeepR()'

## -- S --

saveDataframesAsFiles | Write copy of dataframes to either CSV, TXT, or Excel file.
setExit | Sets the exit date, if there is no exit column in the table
setPopulation | Population designation function
set_seed | Work around for unit tests using sample() among various versions of R
smallPed | smallPed is a hypothetical pedigree
smallPedTree | smallPedTree is a pedigree tree made from 'smallPed'
summarizeKinshipValues | Summary statistics for imputed kinship values
summary.nprcgenekeeprErr | summary.nprcgenekeeprErr Summary function for class nprcgenekeeprErr
summary.nprcgenekeeprGV | summary.nprcgenekeeprErr Summary function for class nprcgenekeeprErr

## -- T --

toCharacter | Force dataframe columns to character
trimPedigree | Trim pedigree to ancestors of provided group by removing uninformative individuals

## -- W --

withinIntegerRange | Get integer within a range