Package: BGmisc 1.8.0

S. Mason Garrison

BGmisc: An R Package for Extended Behavior Genetics Analysis

Provides functions for behavior genetics analysis, including variance component model identification [Hunter et al. (2021) <doi:10.1007/s10519-021-10055-x>], calculation of relatedness coefficients using path-tracing methods [Wright (1922) <doi:10.1086/279872>; McArdle & McDonald (1984) <doi:10.1111/j.2044-8317.1984.tb00802.x>], inference of relatedness, pedigree conversion, and simulation of multi-generational family data [Lyu et al. (2025) <doi:10.1007/s10519-025-10225-1>]. For a full overview, see [Garrison et al. (2024) <doi:10.21105/joss.06203>]. For a big data application see [Burt et al. (2025) <doi:10.1016/j.ebiom.2025.105911>].

Authors:S. Mason Garrison [aut, cre], Michael D. Hunter [aut], Xuanyu Lyu [aut], Rachel N. Good [ctb], Jonathan D. Trattner [aut], S. Alexandra Burt [aut]

BGmisc_1.8.0.tar.gz
BGmisc_1.8.0.zip(r-4.7)BGmisc_1.8.0.zip(r-4.6)BGmisc_1.8.0.zip(r-4.5)
BGmisc_1.8.0.tgz(r-4.6-any)BGmisc_1.8.0.tgz(r-4.5-any)
BGmisc_1.8.0.tar.gz(r-4.7-any)BGmisc_1.8.0.tar.gz(r-4.6-any)
BGmisc_1.8.0.tgz(r-4.6-emscripten)
manual.pdf |manual.html
card.svg |card.png
BGmisc/json (API)
NEWS

# Install 'BGmisc' in R:
install.packages('BGmisc', repos = c('https://r-computing-lab.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/r-computing-lab/bgmisc/issues

Pkgdown/docs site:https://r-computing-lab.github.io

Datasets:
  • hazard - Simulated pedigree with two extended families and an age-related hazard
  • inbreeding - Artificial pedigree data on eight families with inbreeding
  • potter - Fictional pedigree data on a wizarding family
  • royal92 - Royal pedigree data from 1992

On CRAN:

Conda:

behavior-genetics

8.98 score 3 stars 1 packages 134 scripts 935 downloads 70 exports 14 dependencies

Last updated from:bbef98b904. Checks:9 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-x86_64OK335
source / vignettesOK294
linux-release-x86_64OK242
macos-release-arm64OK159
macos-oldrel-arm64OK159
windows-develOK196
windows-releaseOK179
windows-oldrelOK186
wasm-releaseOK157

Exports:addPersonToPedalignPhenToMatrixbuildFamilyGroupsbuildOneFamilyGroupbuildPedigreeModelCovariancebuildPedigreeMxbuildTreeGridcalcAllGenscalcFamilySizecalculateCIscalculateRelatednesscheckIDscheckParentIDscheckPedigreeNetworkcheckSexcom2linkscomp2vechcomputeParentAdjacencycreateGenDataFramedetermineSexdropLinkfindLeavesfitComponentModelfitPedigreeModelgetGenDistgetWikiTreeSummaryidentifyComponentModelinferRelatednessmakeInbreedingmakeTwinsped2addped2addFocalped2ceped2cnped2cnFocalped2comped2famped2focalped2genped2genDistped2genDistFocalped2genFocalped2graphped2maternalped2mitped2mitFocalped2paternalreadGedreadgedcomreadGedcomreadWikifamilytreerecodeSexrelated_coefrepairIDsrepairSexSimPedsimulatePedigreesimulatePedigreessliceFamiliessummariseFamiliessummariseMatrilinessummarisePatrilinessummarisePedigreessummarizeFamiliessummarizeMatrilinessummarizePatrilinessummarizePedigreestraceTreePathstrimPedigreevech

Dependencies:clicpp11data.tableglueigraphlatticelifecyclemagrittrMatrixpkgconfigrlangstringistringrvctrs

ASOIAF: How related are Jon and Danny?

Rendered fromv5_ASOIAF.Rmdusingknitr::rmarkdownon Jun 02 2026.

Last update: 2026-02-19
Started: 2025-05-29

Fitting Pedigree-Based Variance Component Models

Rendered fromv60_pedigree_model_fitting.Rmdusingknitr::rmarkdownon Jun 02 2026.

Last update: 2026-06-02
Started: 2026-03-31

Modeling variance components

Rendered fromv1_modelingvariancecomponents.Rmdusingknitr::rmarkdownon Jun 02 2026.

Last update: 2026-04-01
Started: 2025-05-29

Network tools for finding extended pedigrees and path tracing

Rendered fromv0_network.Rmdusingknitr::rmarkdownon Jun 02 2026.

Last update: 2026-02-19
Started: 2025-05-29

Pedigree Simulation and Visualization with BGmisc

Rendered fromv2_pedigree.Rmdusingknitr::rmarkdownon Jun 02 2026.

Last update: 2026-05-27
Started: 2025-05-29

Understanding and Computing Relatedness from Pedigree Data

Rendered fromv3_analyticrelatedness.Rmdusingknitr::rmarkdownon Jun 02 2026.

Last update: 2026-04-01
Started: 2025-05-29

Validating and Repairing Pedigree Data with BGmisc

Rendered fromv4_validation.Rmdusingknitr::rmarkdownon Jun 02 2026.

Last update: 2026-01-08
Started: 2025-05-29

Readme and manuals

Help Manual

Help pageTopics
Construct Adjacency Matrix for Parent-Child Relationships Using Beta Methods This function constructs an adjacency matrix for parent-child relationships using a method in beta testing. It identifies parent-child pairs based on the specified component of relatedness..adjBeta
Construct Adjacency Matrix for Parent-Child Relationships Using Direct Method.adjDirect
Construct Adjacency Matrix for Parent-Child Relationships Using Indexed Method.adjIndexed
Assign parent values based on component type.assignParentValue
Compute the transpose multiplication for the relatedness matrix.computeTranspose
Load or compute the isChild matrix.loadOrComputeIsChild
Post-process GEDCOM Data Frame.postProcessGedcom.legacy
Create a properly formatted parent row for the pedigreeaddParentRow
addPersonToPedaddPersonToPed
Add addRowlessParentsaddRowlessParents
Align Phenotype Vector to Matrix Format for OpenMxalignPhenToMatrix
Apply Tag Mappings to a LineapplyTagMappings
Process Generation ConnectionsbuildBtwnGenerations
Build family group modelsbuildFamilyGroups
Build one family group modelbuildOneFamilyGroup
Create an mxModel for a pedigreebuildPedigreeModelCovariance
Build Pedigree mxModelbuildPedigreeMx
Process Generations for Pedigree SimulationbuildWithinGenerations
calcAllGens A function to calculate the number of individuals in each generation. This is a supporting function for 'simulatePedigree'.allGens calcAllGens
calcFamilySize A function to calculate the total number of individuals in a pedigree given parameters. This is a supporting function for function 'simulatePedigree'calcFamilySize famSizeCal
calcFamilySizeByGen An internal supporting function for 'simulatePedigree'.calcFamilySizeByGen sizeAllGens
Confidence Intervals for Correlations with Optional Design-Effect AdjustmentcalculateCIs
Falconer's FormulacalculateH
Calculate Relatedness CoefficientcalculateRelatedness related_coef
Validates and Optionally Repairs Unique IDs in a Pedigree DataframecheckIDs
Check for duplicated individual IDscheckIDuniqueness
Validates and Optionally Repairs Parent IDs in a Pedigree DataframecheckParentIDs
Check Parental Role Sex ConsistencycheckParentSex
Validate Pedigree Network StructurecheckPedigreeNetwork
Validates and Optionally Repairs Sex Coding in a Pedigree DataframecheckSex
Check for within-row duplicates (self-parents, same mom/dad)checkWithinRowDuplicates
collapse NamescollapseNames
Convert Sparse Relationship Matrices to Kinship Linkscom2links
comp2vech Turn a variance component relatedness matrix into its half-vectorizationcomp2vech
Compute Parent Adjacency Matrix with Multiple ApproachescomputeParentAdjacency
Condense Matrix Slots in an OpenMx ModelcondenseMatrixSlots
Count GEDCOM Pattern RowscountPatternRows
Create Data Frame for GenerationcreateGenDataFrame createGenDataFrame_beta
Determine Sex of OffspringdetermineSex determineSex_beta
Drop Identical Duplicate IDs from Pedigree Data FramedropIdenticalDuplicateIDs
dropLinkdropLink
Function to find the biggest families in a pedigree This function finds the biggest families in a pedigree. It is supposed to be used internally by the 'summarize_pedigree' function.findBiggest findbiggest
Find Leaf Nodes in a PedigreefindLeaves
Function to find the oldest individuals in a pedigree This function finds the oldest families in a pedigree. It is supposed to be used internally by the 'summarize_pedigree' function.findOldest findoldest
fitComponentModel Fit the estimated variance components of a model to covariance datafitComponentModel
Fit an OpenMx pedigree model to observed datafitPedigreeModel
Fuse MZ twin pairs in a pedigree dataset for path tracing This function identifies MZ twin pairs in the pedigree dataset and merges their IDs for path tracing purposes. The second twin in each pair is made a founder (with NA parents), and all children of the second twin are redirected to the first twin. This allows for correct relatedness calculations without diagonal or downstream artifacts.fuseTwins
Compute the generational distance between two individualsgetGenDist
Simulated pedigree with two extended families and an age-related hazardhazard
identifyComponentModel Determine if a variance components model is identifiedidentifyComponentModel
Artificial pedigree data on eight families with inbreedinginbreeding
Initialize an Empty Individual RecordinitializeRecord
evenInsert A function to insert m elements evenly into a length n vector.evenInsert insertEven
makeInbreedingmakeInbreeding
makeTwinsmakeTwins
Create a Mapping from Family IDs to Parent IDsmapFAMS2parents
Mark and Assign childrenmarkPotentialChildren markPotentialChildren_beta
Parse Name LineparseNameLine
Take a pedigree and turn it into an additive genetics relatedness matrixped2add
Add a focal-person additive relatedness column to a pedigreeped2addFocal
Take a pedigree and turn it into an extended environmental relatedness matrixped2ce
Take a pedigree and turn it into a common nuclear environmental matrixped2cn
Add a focal-person common nuclear relatedness column to a pedigreeped2cnFocal
Take a pedigree and turn it into a relatedness matrixped2com
Segment Pedigree into Extended Familiesped2fam
Compute relatedness between all individuals and a focal personped2focal
Take a pedigree and turn it into a generation relatedness matrix. It computes the rank of the generation matrix, which is the number of generations separating two individualsped2gen
Compute a full pairwise generational distance matrixped2genDist
Compute generational distances from a focal individual to all othersped2genDistFocal
Add a focal-person generation relatedness column to a pedigree. It computes the rank of the generation matrix, which is the number of generations separating two individualsped2genFocal
Turn a pedigree into a graphped2graph
Add a maternal line ID variable to a pedigreeped2maternal
Take a pedigree and turn it into a mitochondrial relatedness matrixped2mit ped2mt
Add a focal-person mitochondrial relatedness column to a pedigreeped2mitFocal ped2mtFocal
Add a paternal line ID variable to a pedigreeped2paternal
Post-process GEDCOM Data FramepostProcessGedcom
Fictional pedigree data on a wizarding familypotter
Function to prepare the pedigree for summarization This function prepares the pedigree for summarization by ensuring that the necessary IDs are present and that the pedigree is built correctly.prepSummarizePedigrees
Process Event Lines (Birth or Death)processEventLine
Process Parents Information from GEDCOM DataprocessParents
Read a GEDCOM FilereadGed readGedcom readgedcom
Read Wiki Family TreereadWikifamilytree
Recodes Sex Variable in a Pedigree DataframerecodeSex
Repair Missing IDsrepairIDs
Repair Parent IDsrepairParentIDs
Repairs Sex Coding in a Pedigree DataframerepairSex
Restore Original Column Names in a Pedigree DataframerestorePedColnames
Royal pedigree data from 1992royal92
Simulate Pedigrees This function simulates "balanced" pedigrees based on a group of parameters: 1) k - Kids per couple; 2) G - Number of generations; 3) p - Proportion of males in offspring; 4) r - Mating rate.SimPed simulatePedigree
Simulate Multiple PedigreessimulatePedigrees
sliceFamiliessliceFamilies
Summarize the families in a pedigreesummariseFamilies summarisefamilies summarizeFamilies summarizefamilies
Summarize the maternal lines in a pedigreesummariseMatrilines summarisematrilines summarizeMatrilines summarizematrilines
Summarize the paternal lines in a pedigreesummarisePatrilines summarisepatrilines summarizePatrilines summarizepatrilines
Summarize Pedigree DatasummarisePedigrees summarisepedigrees summarizePedigrees summarizepedigrees
Trace paths between individuals in a family tree gridtraceTreePaths
Iteratively Trim Leaf Nodes from a PedigreetrimPedigree
validate_and_convert_matrixvalidate_and_convert_matrix
vech Create the half-vectorization of a matrixvech