R/getAncestors.R
getAncestors.Rd
Part of Pedigree Sampling From PedigreeSampling.R 2016-01-28
getAncestors(id, ptree)
id | character vector of length 1 having the ID of interest |
---|---|
ptree | a list of lists forming a pedigree tree as constructed by
|
A character vector of ancestors for an individual ID.
Contains functions to build pedigrees from sub-samples of genotyped individuals.
The goal of sampling is to reduce the number of inbreeding loops in the resulting pedigree, and thus, reduce the amount of time required to perform calculations with SIMWALK2 or similar programs.
# \donttest{ library(nprcgenekeepr) ped <- nprcgenekeepr::qcPed ped <- qcStudbook(ped, minParentAge = 0) pedTree <- createPedTree(ped) pedLoops <- findLoops(pedTree) ids <- names(pedTree) allAncestors <- list() for (i in seq_along(ids)) { id <- ids[[i]] anc <- getAncestors(id, pedTree) allAncestors[[id]] <- anc } head(allAncestors)#> $`0K7VJN` #> [1] "UN3A1F" "YAYD44" #> #> $`0NG81L` #> [1] "OC8QQZ" "LG9I3M" #> #> $`168Q0A` #> [1] "HRBVOE" "P4CQ2T" #> #> $`2FUS6G` #> [1] "UI9CUS" "YKG4ZM" #> #> $`3CQZ3E` #> [1] "UONB0Y" "MBJMH1" #> #> $`3O7TMT` #> [1] "WORLYK" "FHY041" #>countOfAncestors <- unlist(lapply(allAncestors, length)) idsWithMostAncestors <- names(allAncestors)[countOfAncestors == max(countOfAncestors)] allAncestors[idsWithMostAncestors]#> $HLI95R #> [1] "WMUJC5" "H00H7D" "ZWBMTP" "HRBVOE" "RD6KMA" "K7QBLH" "UL1ZA5" "VHXHVH" #> [9] "NY9FEC" "ZWBMTP" "HRBVOE" "RD6KMA" "TINMGJ" "UKKA3A" "6MXDVM" "AXDMJM" #> [17] "L6D4ZC" "5EP5AL" "HB9B30" "I31V3S" "3O7TMT" "WORLYK" "FHY041" "43TUN9" #> [25] "5EP5AL" "HB9B30" "I31V3S" "8G72QV" #> #> $I9TQ0T #> [1] "CN4GMN" "QBLTI6" "F0YSEE" "SA1ZC1" "ZXJQQ5" "6MIRJI" "UKK94T" "596J7E" #> [9] "82IE3M" "F0YSEE" "SA1ZC1" "ZXJQQ5" "JNWPY2" "MQB1AE" "ZXJQQ5" "BNMWNZ" #> [17] "DZ3B9K" "CQMWGX" "N2XF08" "P9GZ32" "HKOSVZ" "ZQ0DRX" "RX08B3" "N2XF08" #> [25] "P9GZ32" "HKOSVZ" "1B71NB" "BRLQFI" #># }