A convenience wrapper around 'FactoMineR' and 'factoextra' for running Correspondence Analysis (CA) on a numeric data table (e.g. a genotype-by-trait or contingency-style matrix) and producing a full set of publication-ready diagnostic plots: scree plot, symmetric biplot, row-only and column-only plots, row/column contribution plots, and row/column cos2 (quality-of-representation) plots. A single top-level function runs the whole pipeline, prints formatted result tables, and optionally saves every plot as a high-resolution image, mirroring a typical CA reporting workflow used in agronomy and plant-breeding studies. An example genotype-by-trait data set is included.
CAbiplot is an R package that wraps
FactoMineR and
factoextra into a single,
reusable pipeline for Correspondence Analysis (CA). It reproduces (as
package functions) the full set of diagnostic plots from a typical CA
reporting script: a scree plot, a symmetric biplot, row-only and
column-only plots, row/column contribution plots, and row/column cos2
plots — plus a combined summary figure.
An example genotype-by-trait data set (19 genotypes x 6 traits) is bundled with the package.
Install the required dependencies, then install the package from source:
install.packages(c("FactoMineR", "factoextra", "ggplot2", "gridExtra"))
# From a local source tree / tarball:
install.packages("path/to/CAbiplot", repos = NULL, type = "source")
# Or, with devtools, from the unpacked package directory:
# devtools::install("path/to/CAbiplot")
library(CAbiplot)
# Load the bundled example data (or use your own numeric matrix / data.frame
# / path to a CSV file with row names in the first column)
geno <- get_genotype_traits()
# Run the whole pipeline: fits CA, builds every plot, prints result tables,
# and saves each plot as a high-resolution JPEG in the given directory
report <- ca_report(geno, output_dir = "ca_output", prefix = "CA")
# Everything is also returned for interactive use:
report$res.ca # the fitted FactoMineR::CA object
report$eig # eigenvalue / inertia table
report$plots$biplot # the symmetric biplot (ggplot object)
report$plots$combined # the combined summary figure
Prefer to build plots one at a time, or on a CA object you already
computed yourself?
res.ca <- run_ca(geno)
ca_scree_plot(res.ca)
ca_biplot(res.ca)
ca_row_plot(res.ca)
ca_col_plot(res.ca)
ca_contrib_plot(res.ca, choice = "row", axes = 1)
ca_contrib_plot(res.ca, choice = "col", axes = 2)
ca_cos2_plot(res.ca, choice = "row")
ca_cos2_plot(res.ca, choice = "col")
| Function | Description |
|---|---|
read_ca_data() |
Read a delimited file into a numeric CA-ready data.frame |
get_genotype_traits() |
Load the bundled example genotype-by-trait data set |
run_ca() |
Run FactoMineR::CA() on a matrix/data.frame/file path |
ca_scree_plot() |
Eigenvalue scree plot |
ca_biplot() |
Symmetric row + column biplot |
ca_row_plot() |
Row-only plot |
ca_col_plot() |
Column-only plot |
ca_contrib_plot() |
Row or column contribution plot for chosen dimension(s) |
ca_cos2_plot() |
Row or column cos2 (quality of representation) plot |
ca_report() |
Full pipeline: fit, plot everything, save, print tables |
Run the test suite with:
devtools::test()
# or
testthat::test_dir("tests/testthat")
MIT