An R6 class that stores family data and a kinship matrix.

Details

Methods of this class can be used to fit regression models such as polygenic mixed models. The class currently supports only family data with one observation per subject and will check that this requirement is met.

Note that the private data member of the instance (returned by the FamData$get_data() method) will always be sorted by ascending family_id and ascending indiv_id within family_id regardless of the sort order of the input data set. Also, pedigree columns in the input data set will be renamed in the data member; this mapping can be returned using the FamData$get_var_map() method.

Methods

Public methods


Method new()

Constructs a new instance of this class.

Usage

FamData$new(data, ...)

Arguments

data

A data.frame or data.table containing all phenotypes and genetic variables of interest.

...

The arguments required for a particular method signature; see below for detailed descriptions.

family_id

Character string containing the name of a numeric or character column in data containing a family identifier.

indiv_id

Character string containing the name of a numeric or character column in data containing a individual identifier.

proband

Character string containing the name of a numeric column in data containing 1 for probands and 0 otherwise. NA is not permitted.

sex

Character string containing the name of a numeric column in data containing the individual's sex (1 = "male", 2 = "female") or NA if unknown.

maternal_id

Character string containing the name of a column in data of the same type as indiv_id containing the indiv_id of the individual's mother or 0 (numeric), "" (character), or NA if a founder. See documentation for kinship2::pedigree.

paternal_id

Character string containing the name of a column in data of the same type as indiv_id containing the indiv_id of the individual's father or or 0 (numeric), "" (character), or NA if a founder. See documentation for kinship2::pedigree.

mzgrp

Character string containing the name of a numeric, character, or factor column in data containing the same value for all members of a monozygotic twin group. NA should be used for all individuals who are not monozygotic twins.

dzgrp

Character string containing the name of a numeric, character, or factor column in data containing the same value for all members of a dizygotic twin group. NA should be used for all individuals who are not dizygotic twins.

phi

A matrix coercible to a Matrix::dsCMatrix containing the pairwise kinship coefficients for individuals. Note that phi[i, j] must contain the kinship coefficient between the individuals in data[i, ] and data[j, ].

Details

All constructor arguments other than data must be named. There are two possible constructor signatures:

FamData$new(data, family_id, indiv_id, proband, sex,
            maternal_id, paternal_id, mzgrp, dzgrp)

FamData$new(data, family_id, indiv_id, proband, phi)


Method get_data()

Returns a copy of data member (to prevent accidental modification of data member data.table by reference).

Usage

FamData$get_data()


Method get_data_name()

Returns name of input data.frame or data.table.

Usage

FamData$get_data_name()


Method get_consang()

Returns vector containing family IDs in which consanguinity was found (based on individual self-kinship coefficient greater than 0.5).

Usage

FamData$get_consang()


Method get_phi()

Returns kinship matrix member.

Usage

FamData$get_phi()


Method get_var_map()

Returns list mapping variable names in input data set in data argument to those in data member.

Usage

FamData$get_var_map()


Method print()

Prints information about contents of FamData objects with nice formatting.

Usage

FamData$print()


Method lmm()

Fits a linear mixed model to ascertained families

Usage

FamData$lmm(formula, ...)

Arguments

formula

A Formula::Formula() object describing the model for a phenotype. The formula is of the form y ~ mean | group, where y (required) is the outcome, mean (optional) specifies the mean model that includes an intercept by default, and | group (optional) specifies a factor term that can be used assign families to homogeneous groups with different variance components. Multiple variables can be combined into a single factor using :.

...

Additional parameters to pass to the control list for optim() with method = "L-BGFS-B". Note that parscale and fnscale cannot be modified.

Details

See vignette("linear_mixed_models") for background, implementation details, and references.

Returns

Returns a FamLMMFit object.


Method plot_pedigree()

For objects initialized with pedigree data, allows plotting of individual pedigrees using kinship2::plot.pedigree.

Usage

FamData$plot_pedigree(famid)

Arguments

famid

Argument matching the value of a single family in the family_id column used in the constructor.


Method clone()

The objects of this class are cloneable with this method.

Usage

FamData$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.