adjMatrix: Pedigree adjacency matrix

Description Usage Arguments Details Value Examples

View source: R/adjMatrix.R

Description

Construct adjacency matrices corresponding to pedigrees.

Usage

1
adjMatrix(adj, sex, validate = TRUE)

Arguments

adj

A square matrix, converted internally to be of "logical" type. If adj is a vector it is recycled and converted to matrix, using sex to deduce the dimensions. If missing, a matrix with all elements FALSE is returned.

sex

A gender vector, i.e. a vector where all elements are 1 (male) or 2 (female).

validate

A logical indicating if the validity of the created object should be checked.

Details

A pedigree can be thought of a a directed acyclic graph (DAG), with the pedigree members as nodes, and an edge from A to B if and only if A is a parent of B. Since no pedigree member have more than 2 parents, any node of the corresponding graphs has at most 2 incoming edges.

The adjacency matrix of a graph G is a square logical matrix with TRUE in entry (i,j) if and only if there is an edge from node i to node j.

Since gender is not encoded in the adjacency matrix itself, we add the vector of genders as an attribute sex.

Value

An object of class adjMatrix. This is a square logical matrix, with an attribute sex which is an integer vector of gender codes (1 = male; 2 = female).

Examples

1
2
3
4
5
6
# An adjacency matrix corresponding to a family trio
# Member order: Father - mother - son
adjMatrix(c(0,0,0,0,0,0,1,1,0), sex = c(1,2,1))

#' # An empty adjacency matrix for 3 male individuals
adjMatrix(sex = c(1,1,1))

magnusdv/pedbuildr documentation built on Oct. 9, 2019, 2:51 p.m.