View source: R/plots_standardization.R
| plot_xy_with_ploidy_guides | R Documentation |
Creates a dot plot of allele counts 'X' (A-allele) vs 'Y' (B-allele) and overlays expected dosage guide lines for a given ploidy. You can either color all samples ('sample = "all"') or highlight a single sample while rendering the others in gray. Samples that have no plotted points (e.g., due to non-finite 'X'/'Y') are automatically omitted from the legend.
plot_xy_with_ploidy_guides(
df,
ploidy = 2,
sample = NULL,
highlight_color = "tomato",
other_color = "grey75"
)
df |
A 'data.frame' containing at least columns 'X' and 'Y'. If 'sample = "all"' or a specific sample is to be highlighted, 'df' should also contain a 'SampleName' column. |
ploidy |
Integer (>= 2). Ploidy used to compute and draw dosage guide lines. |
sample |
Character. Either '"all"' to color all samples by 'SampleName', or the name of a single sample to highlight. Default: '"all"'. |
highlight_color |
Color used for the highlighted sample when 'sample != "all"'. Default: '"tomato"'. |
other_color |
Color used for non-highlighted samples when 'sample != "all"'. Default: '"grey75"'. |
The function:
* Drops rows where 'X' or 'Y' are non-finite before plotting and builds the legend
from the remaining points.
* When 'sample = "all"', colors points by 'SampleName' (requires a 'SampleName' column).
* When 'sample' is a specific name, only that sample is colored with
'highlight_color'; all others use 'other_color'. If the requested sample has
no plotted points, it is omitted from the legend.
* Draws dosage guide lines for dosages 'd = 0, …, ploidy':
'd = 0' → horizontal line 'Y = 0'; 'd = ploidy' → vertical line 'X = 0';
intermediate dosages are lines through the origin with slope
(d/ploidy) / (1 - d/ploidy).
* Uses a fixed aspect ratio ('coord_fixed') so that one unit on the x- and y-axes
has the same length.
A **ggplot** object.
[plot_baf_with_ploidy_guides()] for plotting standardized BAF-based coordinates.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.