Plots (optionally log-transformed) means vs dispersions for one dataset, with an optional second dataset overlaid. Points from the first dataset are drawn in black; the optional overlay is drawn in red.
Usage
plot_BCV(
estimates_X,
estimates_Y = NULL,
method = c("mle", "map"),
log = TRUE,
ancestry_X = "Dataset X",
ancestry_Y = "Dataset Y",
title = NULL,
x_label = NULL,
y_label = NULL,
point_size = 1
)
Arguments
- estimates_X
A list with components `means` and `disps`. Each of these should be a list keyed by method (e.g., `list(mle = <num>, map = <num>)`), where each entry is a numeric vector of the same length.
- estimates_Y
Optional overlay in the same structure as `estimates_X` (i.e., a list with `means` and `disps`, each a list keyed by `method`).
- method
Character; which estimate to plot. One of `"mle"` or `"map"`.
- log
Logical; if `TRUE`, apply `log2()` to means and dispersions **before** plotting (recommended if values span orders of magnitude).
- ancestry_X
Character label for the primary dataset (used in legend/title/labels).
- ancestry_Y
Character label for the overlay dataset (used in legend/title/labels).
- title
Optional plot title. If `NULL`, a sensible default is created, mentioning the ancestry labels and colors (black/red).
- x_label
Optional x-axis label. If `NULL`, a dynamic default is constructed: `"Log2 MLE means (Dataset X)"` (or similar), depending on `log`, `method`, and whether an overlay is present.
- y_label
Optional y-axis label. If `NULL`, a dynamic default is constructed: `"Log2 MLE dispersions (Dataset X)"` (or similar), depending on `log`, `method`, and whether an overlay is present.
- point_size
Numeric; point size passed to `geom_point()`. Default `1`.
Details
If `log = TRUE`, values are transformed with `log2()` **before** plotting, so the axes in ggplot are linear (no log scales). Non-finite points created by the transform (e.g., non-positive inputs) are dropped.
Examples
if (FALSE) { # \dontrun{
# Suppose you have lists like:
# estimates_X <- list(
# means = list(mle = runif(100, 1, 100), map = runif(100, 1, 100)),
# disps = list(mle = runif(100, 1, 10), map = runif(100, 1, 10))
# )
# estimates_Y <- similar structure...
# Single dataset (black), pre-log2:
plot_BCV(estimates_X, method = "mle", log = TRUE, ancestry_X = "EUR")
# With overlay (EUR black vs AFR red), no log transform:
plot_BCV(
estimates_X, estimates_Y,
method = "map", log = FALSE,
ancestry_X = "EUR", ancestry_Y = "AFR"
)
} # }