| Title: | Multi-Trait Density and Boxplot Visualization |
|---|---|
| Description: | Reads wide-format phenotypic data (one row per genotype or sample, one column per trait) from CSV or 'Excel' files, reshapes it to long format, and produces faceted figures that combine a mirrored density curve with a boxplot for each trait. Density curves can be drawn on the left, right, or both sides of the box, and figures can be saved automatically at publication resolution. |
| Authors: | Prakash Kumar [aut, cre], Himadri Sekhar Roy [aut], Ranjit Kumar Paul [aut], Md. Yeasin [aut], Paritosh Kumar ICAR-NIASM [aut], Amrit Kumar Paul [aut] |
| Maintainer: | Prakash Kumar <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-10-08 16:46:33 UTC |
| Source: | https://github.com/cran/BoxDensityPlot |
Returns the file path to a small example CSV bundled with the package,
containing genotype-level values for six traits. Useful for examples,
tests, and trying out plot_trait_density_box.
example_trait_data()example_trait_data()
A file path (character string).
f <- example_trait_data() dat <- read_trait_data(f) head(dat)f <- example_trait_data() dat <- read_trait_data(f) head(dat)
Creates a faceted ggplot2 figure that overlays a mirrored density
curve (violin-style) with a boxplot for each trait found in
long_data. This is the low-level plot builder used internally by
plot_trait_density_box; call it directly if you already have
data prepared in the expected long format.
make_density_boxplot( long_data, density_data, ncol_plot, density_position = c("both", "left", "right"), density_colour = "#4DBBD5", plot_title = NULL, density_width = 0.45, density_alpha = 0.3, boxplot_width = 0.25, box_colour = "#006D6F", mean_colour = "#E31A1C" )make_density_boxplot( long_data, density_data, ncol_plot, density_position = c("both", "left", "right"), density_colour = "#4DBBD5", plot_title = NULL, density_width = 0.45, density_alpha = 0.3, boxplot_width = 0.25, box_colour = "#006D6F", mean_colour = "#E31A1C" )
long_data |
Long-format data frame with (at least) columns
|
density_data |
Long-format data frame with columns |
ncol_plot |
Number of facet columns. |
density_position |
One of |
density_colour |
Fill colour for the density ribbon. |
plot_title |
Title shown above the figure. Use |
density_width |
Numeric half-width of the density curve. |
density_alpha |
Fill transparency (0-1) of the density ribbon. |
boxplot_width |
Numeric width of the boxplot. |
box_colour |
Fill colour of the boxplot. |
mean_colour |
Fill colour of the mean point marker. |
A ggplot object.
High-level, one-call wrapper that reads a wide-format CSV or Excel file of
multi-trait data (one row per genotype/sample, one column per trait),
reshapes it, builds one or more density + boxplot figures (see
make_density_boxplot), and optionally saves each one to
disk at publication resolution.
plot_trait_density_box( file, genotype_col = "Genotype", density_position = c("both", "left", "right"), save = FALSE, out_dir = NULL, prefix = "Multiple_Traits_Boxplot_Density", format = "jpg", dpi = 600, width = NULL, height = NULL, ... )plot_trait_density_box( file, genotype_col = "Genotype", density_position = c("both", "left", "right"), save = FALSE, out_dir = NULL, prefix = "Multiple_Traits_Boxplot_Density", format = "jpg", dpi = 600, width = NULL, height = NULL, ... )
file |
Path to a |
genotype_col |
Name of the identifier column (e.g. |
density_position |
Which figure(s) to build: any combination of
|
save |
Logical; if |
out_dir |
Directory to save figures into. Must be supplied explicitly when
|
prefix |
File name prefix for saved figures. |
format |
Image format passed to |
dpi |
Resolution (dots per inch) for saved figures. |
width, height
|
Figure size in inches. If |
... |
Additional styling arguments forwarded to
|
A named list of ggplot objects (one per requested
density_position), returned invisibly.
f <- example_trait_data() plots <- plot_trait_density_box(f, save = FALSE) plots$bothf <- example_trait_data() plots <- plot_trait_density_box(f, save = FALSE) plots$both
Reads a wide-format data set (one row per genotype/sample, one column per
trait) from a .csv, .xls, or .xlsx file.
read_trait_data(file, sheet = 1, genotype_col = "Genotype")read_trait_data(file, sheet = 1, genotype_col = "Genotype")
file |
Path to the input file. The file extension ( |
sheet |
Sheet name or index to read when |
genotype_col |
Name of the identifier column (genotype, sample,
accession, etc.). Defaults to |
A data frame in wide format with the identifier column plus one column per trait.
f <- example_trait_data() dat <- read_trait_data(f) head(dat)f <- example_trait_data() dat <- read_trait_data(f) head(dat)