tidyped: Tidy and prepare a pedigree

View source: R/tidyped.R

tidypedR Documentation

Tidy and prepare a pedigree

Description

tidyped function checks, sorts, traces, and returns a trimmed pedigree.

Usage

tidyped(ped, cand = NULL, trace = "up", tracegen = NULL,
  addgen = TRUE, addnum = TRUE)

Arguments

ped

A data.table or data frame including the pedigree, which including the first three columns: individual, sire and dam IDs. More columns, such as sex, generation can be included in the pedigree file. Names of the three columns can be assigend as you would like, but their orders must be not changded in the pedigree. Individual ID should not be coded as "", " ", "0", asterisk, and "NA", otherwise these individuals will be deleted from the pedigree. Missing parents should be denoted by either "NA", "0", asterisk. Space and "" will also be recoded as missing parents, but not be recommended.

cand

A character vector including individual IDs, or NULL. Only the candidates and their ancestors and offspring will be kept in the pedigree if this parameter is not NULL.

trace

A character value implying how to trace the pedigree of the candidates, is equal to "up", "down", or "all". "up" means tracing candidates's pedigree to ancestors; "down" means tracing candidates's pedigree to descendants, "all" means tracing candidaes' pedigree to ancestors and descendants simutaneously. This parameter can be used only if the cand parameter is not NULL. The defaulted value is "up".

tracegen

An integer means the number of tracing generation. This paramter can only be used when the trace parameter is not NULL. All generations of the candidates will be traced when the parameter tracegen is NULL or 0.

addgen

A logical value indicates whether individual generation number will be generated. The default values is TRUE, then a new column named Gen will be added in the returned data.table.

addnum

A logical value indicates whether numeric pedigree will be generated. The defaulted value is TRUE, then three new columns of IndNum, SireNum and DamNum will be added in the returned data.table.

Details

This function takes a pedigree, checks duplicated, bisexual individuals, detects pedigree loop, adds missing founders, sorts the pedigree, and traces the pedigree of the candidates. If the parameter cand contains individuals's IDs, then only these individuals and their ancestors or descendants will be kept in the pedigree. The tracing direction and tracing generation number can be provided when the parameters trace and tracegen are not NULL. Individual virtual generation will be infered and assigned when the parameter addgen is TRUE. Numeric pedigree will be generated when the parameter addnum is TRUE. All individuals' sex will be inferred if there is not sexual information in the pedigee. If the pedigree includes the column Sex, then individuals' sexes need to be recoded as "male", "female", or NA (unknown sex). Missing sexes will be identified from the pedigree structure and be added if possible.

Value

A data.table including the tidy pedigree is returned. Individual, sire and dam ID columns are renamed as Ind, Sire and Dam. Missing parent is replacted with the default missing value NA. The column Sex includes individuals' sex (male or female, NA for unknown sex). The column Cand will be included when the parameter cand is not NULL. The column Gen will be included when the parameter addgen is TRUE. The columns IndNum, SireNum, and DamNum will be included when the parameter addnum is TRUE. Ind, Sire, Dam and Sex columns are character; The column Cand is logical; The Gen, IndNum, SireNum and DamNum are integer.

Examples

require(visPedigree)
require(data.table)
simple_ped
tidy_ped <- tidyped(simple_ped)
tidy_ped
# The pedigree of individual J5X804 to ancestors is pruned,
# and the column Cand is added and returned
tidy_ped_J5X804 <- tidyped(simple_ped,cand="J5X804")
tidy_ped_J5X804
# The pedigree of individual J5X804 to parents and grandparents is pruned
tidy_ped_J5X804_up_2 <- tidyped(simple_ped,cand="J5X804",trace="up",tracegen=2)
tidy_ped_J5X804_up_2
# The pedigree of individual J5X804 to offspring is pruned
tidy_ped_J0Z990_down <- tidyped(simple_ped,cand="J0Z990",trace="down")
tidy_ped_J0Z990_down
# The pedigree of individual J0Z990 to child and grandchild is pruned
tidy_ped_J0Z990_down_2 <- tidyped(simple_ped,cand="J0Z990",trace="down",tracegen=2)
tidy_ped_J0Z990_down_2


luansheng/visPedigree documentation built on Feb. 4, 2023, 11:10 p.m.