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 |
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.
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")
.
Luke Jostins <[email protected]>
data(exampleORs) data(famped) tree <- initialiseTree() tree$addPed(famped,exampleORs) sam <- tree$getPrevs(exampleORs,K=0.02) plotNaivePrev(famped,0.02) plot(sam)
data(exampleORs) data(famped) tree <- initialiseTree() tree$addPed(famped,exampleORs) sam <- tree$getPrevs(exampleORs,K=0.02) plotNaivePrev(famped,0.02) plot(sam)
These functions calculate the variance explained on the liability scale by the genetic risk variants described by a MangroveORs
object.
getVarExp(ORs, K) getVarExpSim(ORs,K,iter=1000)
getVarExp(ORs, K) getVarExpSim(ORs,K,iter=1000)
ORs |
An object of class |
K |
The prevalence of the disease. |
iter |
The number of individuals sampled for variance estimation. |
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.
The proportion of variance explained, as a single numeric value.
data(exampleORs) getVarExp(exampleORs,0.02) getVarExpSim(exampleORs,0.02)
data(exampleORs) getVarExp(exampleORs,0.02) getVarExpSim(exampleORs,0.02)
Functions to read in and use MangroveBetas objects
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, ...)
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, ...)
betafile |
The location of a beta file to read in |
header |
Logical. Indicates whether the betafile above has a header. |
x |
A |
object |
A |
... |
Additional arguments to be passed to downstream methods. |
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.
An object of class MangroveBetas
for readBetas
. Nothing is returned for the methods.
MangroveContPreds
for performing quantitative trait prediction using this object.
data(exampleBetas) summary(exampleBetas) plot(exampleBetas)
data(exampleBetas) summary(exampleBetas) plot(exampleBetas)
Methods to generate, summarise and apply MangroveContPreds objects
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, ...)
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, ...)
ped |
A |
betas |
A |
contpred |
A |
object |
A |
x |
A |
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. |
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.
calcBetas
returns a MangroveContPreds
object, applyBetas
returns a numeric vector containing posterior probabilities. The methods do not return anything.
MangroveRiskPreds
for doing risk prediction for binary traits.
data(contped) data(exampleBetas) predbetas <- calcBetas(contped,exampleBetas) summary(predbetas) plot(predbetas) contpreds <- applyBetas(predbetas,162,6.4)
data(contped) data(exampleBetas) predbetas <- calcBetas(contped,exampleBetas) summary(predbetas) plot(predbetas) contpreds <- applyBetas(predbetas,162,6.4)
Examples of the MangroveORs
, MangroveBetas
and MangrovePed
classes from the Mangrove
package. To be used in combination with the Mangrove vignette.
data(ccped) data(famped) data(exampleORs) data(contped) data(exampleBetas)
data(ccped) data(famped) data(exampleORs) data(contped) data(exampleBetas)
See vignette("Mangrove") for details on these example objects.
data(ccped) summary(ccped) data(contped) summary(contped) data(famped) summary(famped) data(exampleORs) summary(exampleORs) data(exampleBetas) summary(exampleBetas)
data(ccped) summary(ccped) data(contped) summary(contped) data(famped) summary(famped) data(exampleORs) summary(exampleORs) data(exampleBetas) summary(exampleBetas)
Functions to read in and use MangroveORs objects
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, ...)
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, ...)
ORfile |
The location of an odds ratio file to read in |
header |
Logical. Indicates whether the ORfile above has a header. |
x |
A |
object |
A |
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. |
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.
An object of class MangroveORs
for readORs
. Nothing is returned for the methods.
MangroveRiskPreds
for performing risk prediction using this object, and getVarExp
for more on assessing variance explained.
data(exampleORs) summary(exampleORs) plot(exampleORs)
data(exampleORs) summary(exampleORs) plot(exampleORs)
Functions to read in and summarise MangrovePed objects
readPed(prefix) ## S3 method for class 'MangrovePed' summary(object, ...) ## S3 method for class 'MangrovePed' print(x, ...) ## S3 method for class 'MangrovePed' plot(x, ...)
readPed(prefix) ## S3 method for class 'MangrovePed' summary(object, ...) ## S3 method for class 'MangrovePed' print(x, ...) ## S3 method for class 'MangrovePed' plot(x, ...)
prefix |
The prefix for the file locations of a pair pedigree and map files, such as produced by the program |
x |
An object of class |
object |
An object of class |
... |
Arguments to be passed on to other methods. |
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.
For readPed
, an object of class MangrovePed
. For methods, nothing is returned.
data(famped) summary(famped) print(famped)
data(famped) summary(famped) print(famped)
Methods to generate, summarise and apply MangroveRiskPreds objects
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, ...)
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, ...)
ped |
A |
ORs |
A |
riskpred |
A |
object |
A |
x |
A |
K |
The prevalence of the disease being predicted. |
... |
Arguments to be passed on to downstream methods. |
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.
calcORs
returns a MangroveRiskPreds
object, applyORs
returns a numeric vector containing posterior probabilities. The methods do not return anything.
MangroveTree
for doing risk prediction for a whole family. MangroveContPreds
for doing quantitative trait prediction.
data(ccped) data(exampleORs) ccors <- calcORs(ccped,exampleORs) summary(ccors) plot(ccors) ccposts <- applyORs(ccors,0.02)
data(ccped) data(exampleORs) ccors <- calcORs(ccped,exampleORs) summary(ccors) plot(ccors) ccposts <- applyORs(ccors,0.02)
Functions for manipulating MangroveSample objects
## S3 method for class 'MangroveSample' print(x,...) ## S3 method for class 'MangroveSample' summary(object, ...) ## S3 method for class 'MangroveSample' plot(x,...)
## S3 method for class 'MangroveSample' print(x,...) ## S3 method for class 'MangroveSample' summary(object, ...) ## S3 method for class 'MangroveSample' plot(x,...)
x |
A |
object |
A |
... |
Further arguments to be passed on to downstream methods. |
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")
None of the methods return anything.
MangroveTree
to generate MangroveSample
objects. plotSampledPrev
for more on plotting expected distributions.
data(famped) data(exampleORs) tree <- initialiseTree() tree$addPed(famped,exampleORs) sam <- tree$getPrevs(exampleORs,0.02) summary(sam) plot(sam)
data(famped) data(exampleORs) tree <- initialiseTree() tree$addPed(famped,exampleORs) sam <- tree$getPrevs(exampleORs,0.02) summary(sam) plot(sam)
Functions to create, populate, summarise and utilise MangroveTree objects.
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,...)
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,...)
tree |
An object of class |
x |
An object of class |
object |
An object of class |
ped |
An object of class \codeMangrovePed |
ORs |
An object of class |
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. |
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")
.
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.
MangrovePed
, MangroveORs
, MangroveSample
data(famped) data(exampleORs) tree <- initialiseTree() tree$addPed(famped,exampleORs) print(tree) summary(tree) sam <- tree$getPrevs(exampleORs,K=0.02) summary(sam)
data(famped) data(exampleORs) tree <- initialiseTree() tree$addPed(famped,exampleORs) print(tree) summary(tree) sam <- tree$getPrevs(exampleORs,K=0.02) summary(sam)
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
).
plotNaivePrev(ped,K,maxN = NULL,...) plotSampledPrev(samples, obs_prev, exp_prev, maxN = NULL, ...)
plotNaivePrev(ped,K,maxN = NULL,...) plotSampledPrev(samples, obs_prev, exp_prev, maxN = NULL, ...)
ped |
A |
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 |
... |
Additional arguments to |
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.
Neither function returns anything.
data(famped) plotNaivePrev(famped,0.02) # is this unexpected for a 2% disease? plotNaivePrev(famped,0.04) # how about for a 4% disease?
data(famped) plotNaivePrev(famped,0.02) # is this unexpected for a 2% disease? plotNaivePrev(famped,0.04) # how about for a 4% disease?