query_relationship: Query Relationship Coefficients from a Pedigree Matrix

query_relationshipR Documentation

Query Relationship Coefficients from a Pedigree Matrix

Description

Retrieves relationship coefficients between individuals from a pedmat object. For compact matrices, automatically handles lookup of merged full-siblings.

Usage

query_relationship(x, id1, id2 = NULL)

Arguments

x

A pedmat object created by pedmat.

id1

Character, first individual ID.

id2

Character, second individual ID. If NULL, returns the entire row of relationships for id1.

Details

For compact matrices (compact = TRUE), this function automatically maps individuals to their family representatives. For methods A, D, and AA, it can compute the correct relationship even between merged full-siblings using the formula:

  • A: a_{ij} = 0.5 * (a_{is} + a_{id}) where s, d are parents

  • D: d_{ij} = a_{ij}^2 (for full-sibs in same family)

  • AA: aa_{ij} = a_{ij}^2

Value

  • If id2 is provided: numeric value (relationship coefficient)

  • If id2 is NULL: named numeric vector (id1's row)

  • Returns NA if individual not found

Note

Inverse matrices (Ainv, Dinv, AAinv) are not supported because inverse matrix elements do not represent meaningful relationship coefficients.

See Also

pedmat, expand_pedmat

Examples

tped <- tidyped(small_ped)
A <- pedmat(tped, method = "A", compact = TRUE)

# Query specific pair
query_relationship(A, "A", "B")

# Query merged full-siblings (works with compact)
query_relationship(A, "Z1", "Z2")

# Get all relationships for one individual
query_relationship(A, "A")


visPedigree documentation built on March 30, 2026, 9:07 a.m.