library(visPedigree)
library(data.table)
# Drawing a simple pedigree
simple_ped_tidy <- tidyped(simple_ped)
visped(simple_ped_tidy,
cex=0.25,
symbolsize=5.5)
# Highlighting an individual and its ancestors and descendants
visped(simple_ped_tidy,
highlight = "J5X804",
trace = "all",
cex=0.25,
symbolsize=5.5)
# Showing inbreeding coefficients in the graph
simple_ped_tidy_inbreed <- tidyped(simple_ped, inbreed = TRUE)
visped(simple_ped_tidy_inbreed,
showf = TRUE,
cex=0.25,
symbolsize=5.5)
# Adjusting page width and symbol size for better layout
# Increase pagewidth to spread nodes horizontally in the pdf file
# Increase symbolsize for more padding around individual labels
visped(simple_ped_tidy,
cex=0.25,
symbolsize=5.5,
pagewidth = 100,
file = tempfile(fileext = ".pdf"))
# Highlighting multiple individuals with custom colors
visped(simple_ped_tidy,
highlight = list(ids = c("J3Y620", "J1X971"),
frame.color = "#4caf50",
color = "#81c784"),
cex=0.25,
symbolsize=5.5)
# Handling large pedigrees: Saving to PDF is recommended for legibility
# The 'trace' and 'tracegen' parameters in tidyped() help prune the graph
cand_labels <- big_family_size_ped[(Year == 2007) & (substr(Ind,1,2) == "G8"), Ind]
# \donttest{
big_ped_tidy <- tidyped(big_family_size_ped,
cand = cand_labels,
trace = "up",
tracegen = 2)
# Use compact = TRUE for large families
visped(big_ped_tidy,
compact = TRUE,
cex=0.08,
symbolsize=5.5,
file = tempfile(fileext = ".pdf"))
# Use outline = TRUE if individual labels are not required
visped(big_ped_tidy,
compact = TRUE,
outline = TRUE,
file = tempfile(fileext = ".pdf"))
# }
Run the code above in your browser using DataLab