visped: Visualize a tidy pedigree

View source: R/visped.R

vispedR Documentation

Visualize a tidy pedigree

Description

visped function draws a graph of a full or compact pedigree.

Usage

visped(ped, compact = FALSE, outline = FALSE, cex = NULL,
  showgraph = TRUE, file = NULL)

Arguments

ped

A data.table including the pedigree tidied by the tidyped function with the parameter addnum=TRUE. It is recommended that the pedigree is tidied and pruned by candidates using the tidyped function with the not null parameter cand.

compact

A logical value indicating whether IDs of full-sib individuals in one generation will be deleted and replaced with the number of full-sib individuals. For example, if there are 100 full-sib individuals in one generation, they will be deleted from the pedigree and be replaced with one individual label of "100" when compact = TRUE. The default value is FALSE

outline

A logical value indicating whether shapes without label will be shown. A graph of the pedigree without individuals' label is shown when setting outline = TRUE. It is very useful for viewing the outline of the pedigree and finding the immigrant individuals in each generation when the width of a pedigree graph is longer than the maximum width (200 inches) of the pdf file. The defaulted value is FALSE.

cex

NULL or a numeric value changing the size of individual label shown in the graph. cex is an abbreviation of character expansion factor. visped function will try to guess (cex=NULL) the matched cex value and returned it in the messages. According to the returned cex of the last run, this parameter should be increased if the label's width is longer than that of the shape in the output pdf file; Contrariwise, this parameter should be decreased if the label's width is shorter than that of the shape in the output pdf file; then rerunning visped function. The default value is NULL.

showgraph

A logical value indicating whether a plot will be shown in the defaulted graphic device, such as the Plots panel of Rstudio. It is useful for quick viewing of the pedigree graph without opening the pdf file. However, the graph on the defaulted graphic device may be not legible, such as overlapped labels, aliasing lines due to the restricted width and height. It's a good choice to set showgraph = FALSE when the pedigree is large. The default value is TRUE.

file

NULL or a character value means whether the pedigree graph will be saved in a pdf file. The graph in the pdf file is a legible vector drawing, and labels isn't overlapped especially when the number of individuals is big and width of the individual label is long in one generation. It is recommended that saving a pedigree graph in the pdf file. The default value is NULL.

Details

This function takes a pedigree tidied by the tidyped function, outputs a hierarchical graph for all individuals in the pedigree. The graph can be shown on the defaulted graphic device and be saved in a pdf file. The graph in the pdf file is a vector drawing, is legible and isn't overlapped. It is especially useful when the number of individuals is big and the width of individual label is long in one generation. This function can draw the graph of a very large pedigree (> 10,000 individuals per generation) by compacting the full-sib individuals. It is very effective for drawing the pedigree of aquatic animal, which usually including many full-sib families per generation in the nucleus breeding population. The outline of a pedigree without individuals' label is still shown if the width of a pedigree graph is longer than the maximum width (200 inches) of the pdf file.

In the graph, two shapes and three colors are used. Circle is for individual, square is for family. Dark sky blue means male, dark golden rod means female, dark olive green means unknown sex. For example, one circle with dark sky blue means a male individual; One square with dark golden rod means all female individuals in a full-sib family when compact = TRUE.

Value

No returned values. The graph will be plotted directly on graphic devices.

Examples

library(data.table)
# Drawing a simple pedigree
simple_ped
simple_ped_tidy <- tidyped(simple_ped)
visped(simple_ped_tidy)
# Drawing a simple pedigree of a individual with id of J5X804
simple_ped_J5X804_tidy <- tidyped(simple_ped,cand=c("J5X804"))
visped(simple_ped_J5X804_tidy)
# Drawing the graph in the pdf file
visped(simple_ped_J5X804_tidy,file="output.pdf")
# Drawing a compact pedigree
# The candidates' labels in 2007
cand_labels <- big_family_size_ped[(Year == 2007) & (substr(Ind,1,2) == "G8"),Ind]
big_ped_tidy <- tidyped(big_family_size_ped,cand=cand_labels)
visped(big_ped_tidy,compact=TRUE)
visped(big_ped_tidy,compact=TRUE, file="output.pdf")
# Individual labels are not shown
visped(big_ped_tidy,compact=TRUE, outline=TRUE, file="output.pdf")


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