| LRpowerPlot | R Documentation |
Simulates genetic data under each of two pedigree hypotheses and calculates the LR comparing H1 against H2 for each simulation. The resulting log10 LR distributions are plotted together, illustrating how well the hypotheses can be distinguished. The plot also shows the density overlap and, if a threshold is given, the exceedance probabilities under each hypothesis.
LRpowerPlot(
numeratorPed = NULL,
denominatorPed = NULL,
ids = NULL,
markers = NULL,
nsim = 500,
seed = NULL,
threshold = 10000,
data = NULL,
returnData = FALSE,
title = NULL,
bw = NULL,
col = c("#E69F00", "#0072B2"),
verbose = TRUE
)
numeratorPed, denominatorPed |
Pedigrees describing H1 and H2. If |
ids |
Individuals to simulate. |
markers |
Marker names or indices to include, or a named list of frequency vectors defining new markers. By default all attached markers. |
nsim |
Number of simulations under each hypothesis. |
seed |
Integer seed for the random number generator. |
threshold |
An LR threshold. If given, the plot includes exceedance probabilities. Default: 10000. |
data |
Precomputed data, either output from |
returnData |
If TRUE, return the simulated log10 LRs instead of a plot. |
title |
Plot title. |
bw |
Density bandwidth on the log10 LR scale. By default it is estimated from the
pooled simulations. Increase |
col |
Two colours for the H1-true and H2-true distributions. |
verbose |
A logical. |
A ggplot object, or if returnData = TRUE, a data frame with columns
hypothesis, sim and log10LR.
LRpower()
if(requireNamespace("ggplot2", quietly = TRUE)) {
db = NorwegianFrequencies[1:5] # small example database
### Example 1: Sibs vs unrelated (increase nsim!)
ids = c("A", "B")
H1 = nuclearPed(children = ids)
LRpowerPlot(H1, ids = ids, markers = db, nsim = 10, seed = 123)
### Example 2: Full sibs vs half sibs
ids = c("A", "B")
H1 = nuclearPed(children = ids)
H2 = halfSibPed() |> relabel(old = 4:5, new = ids)
LRpowerPlot(H1, H2, ids = ids, markers = db, nsim = 10, seed = 123,
title = "H1: Full sibs, H2: Half sibs")
### Example 3: Full sibs vs half sibs, including shared parent
ids = c("A", "B", "C")
H1 = nuclearPed(fa = ids[1], children = ids[2:3])
H2 = halfSibPed() |> relabel(old = c(2,4:5), new = ids)
LRpowerPlot(H1, H2, ids = ids, markers = db, nsim = 10, seed = 123,
title = "Full vs. half sibs, when parent is available")
# Example 4: Paternity case (requires mutation modelling!)
H1 = nuclearPed() |>
setMarkers(locusAttributes = db) |>
setMutmod(model = "equal", rate = 0.01)
LRpowerPlot(H1, ids = c(1,3), nsim = 10, seed = 123)
# Alternative syntax: With returnData = TRUE
dat = LRpowerPlot(H1, ids = c(1,3), nsim = 10, returnData = TRUE)
LRpowerPlot(data = dat, threshold = 1e6, col = 2:3)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.