Package 'Mangrove'

Title: Risk Prediction on Trees
Description: Methods for performing genetic risk prediction from genotype data. You can use it to perform risk prediction for individuals, or for families with missing data.
Authors: Luke Jostins
Maintainer: Luke Jostins <[email protected]>
License: GPL (>= 2)
Version: 1.21
Built: 2025-01-19 05:15:54 UTC
Source: https://github.com/cran/Mangrove

Help Index


Mangrove: Risk prediction on trees

Description

Mangrove is an R package for performing genetic risk prediction from genotype data. You can use it to perform risk prediction for individuals, or for families with missing data.

Details

Package: Mangrove
Type: Package
Version: 1.21
Date: 2017-02-22
License: GPL (>= 2)
LazyLoad: yes

For a detailed example of how to use Mangrove, see vignette("Mangrove").

Author(s)

Luke Jostins <[email protected]>

Examples

data(exampleORs)
data(famped)
tree <- initialiseTree()
tree$addPed(famped,exampleORs)
sam <- tree$getPrevs(exampleORs,K=0.02)
plotNaivePrev(famped,0.02)
plot(sam)

Calculating liability-scale variance explained by genetic risk variants

Description

These functions calculate the variance explained on the liability scale by the genetic risk variants described by a MangroveORs object.

Usage

getVarExp(ORs, K)
getVarExpSim(ORs,K,iter=1000)

Arguments

ORs

An object of class MangroveORs

K

The prevalence of the disease.

iter

The number of individuals sampled for variance estimation.

Details

getVarExp calculates the variance explained analytically, by converting the odds ratios to liability-scale units, and combining them together additively. getVarExpSim simulates genotypes from the allele frequencies, performs risk prediction on them, converts the resulting posteriors to liabilities, and directly measures the variance of the sample.

Value

The proportion of variance explained, as a single numeric value.

Examples

data(exampleORs)
getVarExp(exampleORs,0.02)
getVarExpSim(exampleORs,0.02)

The MangroveBetas class

Description

Functions to read in and use MangroveBetas objects

Usage

readBetas(betafile,header=TRUE)

## S3 method for class 'MangroveBetas'
print(x, ...)
## S3 method for class 'MangroveBetas'
summary(object, ...)
## S3 method for class 'MangroveBetas'
plot(x, ...)

Arguments

betafile

The location of a beta file to read in

header

Logical. Indicates whether the betafile above has a header.

x

A MangroveBetas object

object

A MangroveBetas object

...

Additional arguments to be passed to downstream methods.

Details

A MangroveBetas object is used to hold the risk alleles, beta values and frequencies for a set of genetic variants used to predict a quantitative trait. You can read a beta file from disk using readBetas.

The format of the beta file is a text file with 4 columns. The first should be the variant ID, the second the risk allele, the third the additive beta value and the fourth the frequency.

The print method shows the data that the object holds. The summary method gives some measures of how predictive the variants are, including the variance explained by the variants in the object. The plot method show the cumulative variance explained as the variants are added in one-at-a-time (in order of most-to-least variance explained).

See vignette("Mangrove") for an example of a beta file, and usage of a beta object.

Value

An object of class MangroveBetas for readBetas. Nothing is returned for the methods.

See Also

MangroveContPreds for performing quantitative trait prediction using this object.

Examples

data(exampleBetas)
summary(exampleBetas)
plot(exampleBetas)

The MangroveContPreds class

Description

Methods to generate, summarise and apply MangroveContPreds objects

Usage

calcBetas(ped,betas)
applyBetas(contpred,mu,sigma)

## S3 method for class 'MangroveContPreds'
print(x, ...)
## S3 method for class 'MangroveContPreds'
summary(object, ...)
## S3 method for class 'MangroveContPreds'
plot(x, ...)

Arguments

ped

A MangrovePed object

betas

A MangroveBetas object

contpred

A MangroveContPreds object

object

A MangroveContPreds object

x

A MangroveContPreds object

mu

The population mean of the quantitative trait being predicted

sigma

The population standard deviation of the quantitative trait being predicted

...

Arguments to be passed on to downstream methods.

Details

MangroveContPreds objects are used to hold quantitative (or continuous) trait predictions for a number of individuals. This object contains the beta value for the trait (i.e. the person's value of the trait on a scale with the population mean being zero and the population standard deviation being one). You can generate per-individual beta values from a pedigree object and some per-variant beta values using calcBetas, and you can transform these to quantitative trait predictions given a population mean and standard deviation using applyBetas.

The print method writes the beta value for each individual to screen. The summary method gives some quantile information, and the plot method plots a histogram of predicted values, which should be approximately normal.

Value

calcBetas returns a MangroveContPreds object, applyBetas returns a numeric vector containing posterior probabilities. The methods do not return anything.

See Also

MangroveRiskPreds for doing risk prediction for binary traits.

Examples

data(contped)
data(exampleBetas)
predbetas <- calcBetas(contped,exampleBetas)

summary(predbetas)
plot(predbetas)

contpreds <- applyBetas(predbetas,162,6.4)

Example data for the Mangrove vignette

Description

Examples of the MangroveORs, MangroveBetas and MangrovePed classes from the Mangrove package. To be used in combination with the Mangrove vignette.

Usage

data(ccped)
data(famped)
data(exampleORs)
data(contped)
data(exampleBetas)

Details

See vignette("Mangrove") for details on these example objects.

Examples

data(ccped)
summary(ccped)

data(contped)
summary(contped)

data(famped)
summary(famped)

data(exampleORs)
summary(exampleORs)

data(exampleBetas)
summary(exampleBetas)

The MangroveORs class

Description

Functions to read in and use MangroveORs objects

Usage

readORs(ORfile,header=TRUE)

## S3 method for class 'MangroveORs'
print(x, ...)
## S3 method for class 'MangroveORs'
summary(object, K = NULL, ...)
## S3 method for class 'MangroveORs'
plot(x, K = NULL, ...)

Arguments

ORfile

The location of an odds ratio file to read in

header

Logical. Indicates whether the ORfile above has a header.

x

A MangroveORs object

object

A MangroveORs object

K

The prevalence of the disease that the odds ratios predict. If NULL, data is returned for a few example prevalences.

...

Additional arguments to be passed to downstream methods.

Details

A MangroveORs object is used to hold the risk alleles, odds ratios and frequencies for a set of genetic variants used to predict disease. You can read an odds ratio file from disk using readORs.

The format of the odds ratio file is a text file with 4 or 5 columns. If the file has 4 columns, the first should be the variant ID, the second the risk allele, the third the additive odds ratio and the fourth the frequency. If 5 columns exist, column three is the heterozygous odds ratio, column four is the homozygous risk odds ratio, and five is the allele frequency.

The print method shows the data that the object holds. The summary method gives some measures of how predictive the variants are, including the variance explained by the variants in the object on the liability scale. The plot method show the cumulative variance explained on the liability scale as the variants are added in one-at-a-time (in order of most-to-least variance explained).

See vignette("Mangrove") for an example of an odds ratio file, and usage of an odds ratio object.

Value

An object of class MangroveORs for readORs. Nothing is returned for the methods.

See Also

MangroveRiskPreds for performing risk prediction using this object, and getVarExp for more on assessing variance explained.

Examples

data(exampleORs)
summary(exampleORs)
plot(exampleORs)

The MangrovePed class

Description

Functions to read in and summarise MangrovePed objects

Usage

readPed(prefix)

## S3 method for class 'MangrovePed'
summary(object, ...)
## S3 method for class 'MangrovePed'
print(x, ...)
## S3 method for class 'MangrovePed'
plot(x, ...)

Arguments

prefix

The prefix for the file locations of a pair pedigree and map files, such as produced by the program Plink. Requires prefix.ped and prefix.map to both exist.

x

An object of class MangrovePed

object

An object of class MangrovePed

...

Arguments to be passed on to other methods.

Details

A MangrovePed object holds genotypes and family relationships for a number of individuals. You can read in such data from a Plink pedigree file using readPed.

You can show the raw pedigree data using the print method and get summary information (such as number of samples, cases and variants) using the summary method. The plot function produces an error.

Value

For readPed, an object of class MangrovePed. For methods, nothing is returned.

See Also

MangroveORs, MangroveTree.

Examples

data(famped)
summary(famped)
print(famped)

The MangroveRiskPreds class

Description

Methods to generate, summarise and apply MangroveRiskPreds objects

Usage

calcORs(ped,ORs)
applyORs(riskpred,K)

## S3 method for class 'MangroveRiskPreds'
print(x, ...)
## S3 method for class 'MangroveRiskPreds'
summary(object, ...)
## S3 method for class 'MangroveRiskPreds'
plot(x, ...)

Arguments

ped

A MangrovePed object

ORs

A MangroveORs object

riskpred

A MangroveRiskPreds object

object

A MangroveRiskPreds object

x

A MangroveRiskPreds object

K

The prevalence of the disease being predicted.

...

Arguments to be passed on to downstream methods.

Details

MangroveRiskPreds objects are used to hold risk predictions for a number of individuals. This object contains the odds ratio for each individual of developing the disease, relative to the population average. You can generate risk predictions from a pedigree object and some per-variant odds ratios using calcORs, and you can use these to calculate posterior probabilities of developing the disease given a prevalence using applyORs.

The print method writes the odds ratio for each individual to screen. The summary method gives some quantile information, and the plot method prints a histogram of log odds ratios, which should be approximately normal.

Value

calcORs returns a MangroveRiskPreds object, applyORs returns a numeric vector containing posterior probabilities. The methods do not return anything.

See Also

MangroveTree for doing risk prediction for a whole family. MangroveContPreds for doing quantitative trait prediction.

Examples

data(ccped)
data(exampleORs)
ccors <- calcORs(ccped,exampleORs)

summary(ccors)
plot(ccors)

ccposts <- applyORs(ccors,0.02)

The MangroveSample class

Description

Functions for manipulating MangroveSample objects

Usage

## S3 method for class 'MangroveSample'
print(x,...)
## S3 method for class 'MangroveSample'
summary(object, ...)
## S3 method for class 'MangroveSample'
plot(x,...)

Arguments

x

A MangroveSample object.

object

A MangroveSample object.

...

Further arguments to be passed on to downstream methods.

Details

MangroveSample objects are produced from a MangroveTree object via a call to tree$getPrevs. They contain samples from the posterior distribution of number of affecteds in a family conditional on that family's genotypes.

The print method writes all the samples to screen. You can plot the distribution of number of affecteds using the plot method (which calls plotSampledPrev), and perform a significance test for whether the observed number of affecteds is greater than would be expected using the summary method.

You can see a detailed example of how these methods are applied by calling vignette("Mangrove")

Value

None of the methods return anything.

See Also

MangroveTree to generate MangroveSample objects. plotSampledPrev for more on plotting expected distributions.

Examples

data(famped)
data(exampleORs)
tree <- initialiseTree()
tree$addPed(famped,exampleORs)
sam <- tree$getPrevs(exampleORs,0.02)

summary(sam)
plot(sam)

The MangroveTree class

Description

Functions to create, populate, summarise and utilise MangroveTree objects.

Usage

initialiseTree()

# Member functions: 
# tree$addPed(ped,ORs)
# tree$getPrevs(ORs = NULL,K = NULL,overwrite=FALSE,iter=1000)

## S3 method for class 'MangroveTree'
print(x,...)
## S3 method for class 'MangroveTree'
summary(object,...)
## S3 method for class 'MangroveTree'
plot(x,...)

Arguments

tree

An object of class MangroveTree

x

An object of class MangroveTree

object

An object of class MangroveTree

ped

An object of class \codeMangrovePed

ORs

An object of class MangroveORs

K

The prevalence of the disease (between 0 and 1, or NULL if not known)

overwrite

Logical. If set to FALSE, and sampling has already been performed, then existing samples will be used. If TRUE, sampling is performed again.

iter

Number of samples to draw from the posterior distribution of number of affecteds.

...

Arguments to be passed on to other methods.

Details

The MangroveTree class is used for holding family trees, and for performing risk prediction on them. The initialiseTree function creates an empty tree, and the tree$addPed populates it from genetic data. You can then sample from the posterior distribution of number of affecteds using the tree$getPrevs function.

The print method writes a text version of the tree to screen, and the summary method writes some basic information about what the tree contains, along with what calculations have and have not been performed on it. The plot method is not implemented, and throws an error message.

To see an example of the use of this class, use vignette("Mangrove").

Value

For initialiseTree, an empty object of class MangroveTree. For the tree$getPrevs class function, an object of class MangroveSample.

For all other functions, nothing is returned.

See Also

MangrovePed, MangroveORs, MangroveSample

Examples

data(famped)
data(exampleORs)

tree <- initialiseTree()
tree$addPed(famped,exampleORs)

print(tree)
summary(tree)

sam <- tree$getPrevs(exampleORs,K=0.02)
summary(sam)

Plotting expected

Description

Two functions for plotting the expected distribution of affecteds in a family, either assuming no genetic risk factors, or using sampled from a custom distribution of affecteds (such as produced by MangroveTree).

Usage

plotNaivePrev(ped,K,maxN = NULL,...)
plotSampledPrev(samples, obs_prev, exp_prev, maxN = NULL, ...)

Arguments

ped

A MangrovePed object.

K

The prevalence of the disease.

samples

Samples from the distribution of number of affecteds.

obs_prev

The number of affecteds actually observed.

exp_prev

The expected number of affecteds under a naive model.

maxN

The maximum number of affecteds to be shown on the graph. If NULL, an appropriate maximum is selected from the data.

...

Additional arguments to plot.

Details

These functions are used to assess how "unusual" a family is in terms of the number of affected individuals it contains. plotNaivePrev plots the distribution of affected individuals in the family assuming no genetic risk factors (i.e. under a binomial model). plotSampledPrev is more general, and takes in a set of samples from the expected distribution.

Note that plotSampledPrev is called by plot.MangroveSample to plot the results of a MangroveTree sampling. It will be easier to use the print.MangroveSample method rather than using plotSampledPrev under most circumstances.

Value

Neither function returns anything.

See Also

MangroveSample

Examples

data(famped)

plotNaivePrev(famped,0.02) # is this unexpected for a 2% disease?
plotNaivePrev(famped,0.04) # how about for a 4% disease?