| Type: | Package |
| Title: | Multi-Trait Density and Boxplot Visualization |
| Version: | 0.1.0 |
| 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. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| Depends: | R (≥ 4.1.0) |
| Imports: | ggplot2 (≥ 3.4.0), dplyr (≥ 1.1.0), tidyr (≥ 1.3.0), rlang, readxl, stats, utils, grid, tools |
| Suggests: | testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| RoxygenNote: | 7.3.1 |
| NeedsCompilation: | no |
| Packaged: | 2026-09-28 11:44:21 UTC; iasri |
| Author: | 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 <prakash289111@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-10-08 10:40:26 UTC |
Path to the bundled example trait data set
Description
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.
Usage
example_trait_data()
Value
A file path (character string).
Examples
f <- example_trait_data()
dat <- read_trait_data(f)
head(dat)
Build a density + boxplot figure for multiple traits
Description
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.
Usage
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"
)
Arguments
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. |
Value
A ggplot object.
Read trait data and generate density + boxplot figure(s)
Description
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.
Usage
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,
...
)
Arguments
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
|
Value
A named list of ggplot objects (one per requested
density_position), returned invisibly.
Examples
f <- example_trait_data()
plots <- plot_trait_density_box(f, save = FALSE)
plots$both
Read multi-trait phenotypic data from CSV or Excel
Description
Reads a wide-format data set (one row per genotype/sample, one column per
trait) from a .csv, .xls, or .xlsx file.
Usage
read_trait_data(file, sheet = 1, genotype_col = "Genotype")
Arguments
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 |
Value
A data frame in wide format with the identifier column plus one column per trait.
Examples
f <- example_trait_data()
dat <- read_trait_data(f)
head(dat)