View source: R/flex_ld_decay.R
flex_LD_decay | R Documentation |
This function generates a linkage disequilibrium (LD) decay plot based on input LD data. It supports both static and interactive visualization with customizable aesthetics, themes, and optional smoothing curves.
flex_LD_decay(
ld_data,
interactive = TRUE,
user_colors = NULL,
user_title = "LD Decay Plot",
user_x_title = "Distance (Mb)",
user_y_title = "R-squared (LD)",
user_legend_title = "Chromosome",
user_plot_theme = theme_minimal(),
user_plot_theme_specs = theme(legend.title = element_text(size = 10), legend.text =
element_text(size = 10), title = element_text(size = 15), axis.text.x =
element_text(size = 10), axis.title.x = element_text(size = 10), axis.text.y =
element_text(size = 10), axis.title.y = element_text(size = 10)),
user_base = 1e+06,
user_smoothing = "loess",
add_smoothing = FALSE,
add_smoothing_per_chromosome = FALSE,
...
)
ld_data |
Data frame containing LD information. |
interactive |
Logical. If |
user_colors |
Character vector of colors for chromosomes. If |
user_title |
Character. Title of the plot. Default is |
user_x_title |
Character. X-axis label. Default is |
user_y_title |
Character. Y-axis label. Default is |
user_legend_title |
Character. Legend title. Default is |
user_plot_theme |
A ggplot2 theme object. Default is |
user_plot_theme_specs |
Additional theme specifications applied to the plot. Default is a theme object with custom font sizes. |
user_base |
Numeric. Scaling factor for distance (e.g., 1e6 for Mb). Default is |
user_smoothing |
Character. Smoothing method to use in |
add_smoothing |
Logical. If |
add_smoothing_per_chromosome |
Logical. If |
... |
Additional arguments passed to |
A ggplot object (static plot) or a plotly object (interactive plot),
depending on the value of interactive
.
library(ggplot2)
library(plotly)
library(dplyr)
library(nortest)
library(ggforce)
library(reshape2)
library(gridExtra)
library(grid)
library(cowplot)
# Load example data
snp_ld_data <- example_data7
# Basic plot
flex_LD_decay(snp_ld_data)
# Add a general smoothing curve
flex_LD_decay(snp_ld_data, add_smoothing = TRUE)
# Add smoothing per chromosome
flex_LD_decay(snp_ld_data, add_smoothing = TRUE, add_smoothing_per_chromosome = TRUE)
# Customize smoothing parameters
flex_LD_decay(snp_ld_data, add_smoothing = TRUE, span = 0.5, se = FALSE)
# Use generalized additive model (GAM) for smoothing
flex_LD_decay(snp_ld_data, user_smoothing = "gam", add_smoothing = TRUE,
add_smoothing_per_chromosome = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.