| Title: | Correspondence Analysis Biplots and Diagnostic Reports |
|---|---|
| Description: | 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. |
| Authors: | Prakash Kumar [aut, cre], Himadri Sekhar Roy [aut], Ranjit Kumar Paul [aut], Md. Yeasin [aut], Sunil Kumar Yadav [aut], Amrit Kumar Paul [aut] |
| Maintainer: | Prakash Kumar <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-09-24 19:26:37 UTC |
| Source: | https://github.com/cran/CAbiplot |
Symmetric CA biplot (rows and columns)
ca_biplot(res.ca, axes = c(1, 2), col.row = "#1F4E79", col.col = "#B22222", ...)ca_biplot(res.ca, axes = c(1, 2), col.row = "#1F4E79", col.col = "#B22222", ...)
res.ca |
|
axes |
Length-2 integer vector of the dimensions to plot. Defaults
to |
col.row |
Color for row points/labels. Defaults to |
col.col |
Color for column points/labels. Defaults to
|
... |
Additional arguments passed to
|
A ggplot object.
CA column-only plot
ca_col_plot(res.ca, axes = c(1, 2), col.col = "#B22222", ...)ca_col_plot(res.ca, axes = c(1, 2), col.col = "#B22222", ...)
res.ca |
|
axes |
Length-2 integer vector of the dimensions to plot. Defaults
to |
col.col |
Color for column points/labels. Defaults to
|
... |
Additional arguments passed to
|
A ggplot object.
Row or column contribution plot
ca_contrib_plot(res.ca, choice = c("row", "col"), axes = 1, top = NULL, ...)ca_contrib_plot(res.ca, choice = c("row", "col"), axes = 1, top = NULL, ...)
res.ca |
|
choice |
Either |
axes |
Integer vector of dimension(s) to sum contributions over.
Defaults to |
top |
Number of rows/columns to display. Defaults to all of them. |
... |
Additional arguments passed to
|
A ggplot object.
Row or column cos2 (quality of representation) plot
ca_cos2_plot(res.ca, choice = c("row", "col"), axes = 1:2, top = NULL, ...)ca_cos2_plot(res.ca, choice = c("row", "col"), axes = 1:2, top = NULL, ...)
res.ca |
|
choice |
Either |
axes |
Integer vector of dimension(s) to sum cos2 over. Defaults to
|
top |
Number of rows/columns to display. Defaults to all of them. |
... |
Additional arguments passed to
|
A ggplot object.
End-to-end pipeline that runs Correspondence Analysis on data and
produces the full battery of diagnostic plots used in the package
vignette: a scree plot, a symmetric biplot, row-only and column-only
plots, row and column contribution plots (dimensions 1 and 2), row and
column cos2 plots, and a combined summary figure. Optionally saves every
plot as a high-resolution JPEG and prints formatted result tables to the
console, mirroring a typical CA reporting workflow.
ca_report(data, output_dir = ".", prefix = "CA", save_plots = TRUE, dpi = 600, verbose = TRUE)ca_report(data, output_dir = ".", prefix = "CA", save_plots = TRUE, dpi = 600, verbose = TRUE)
data |
A numeric matrix, numeric |
output_dir |
Directory where plots are saved when
|
prefix |
File name prefix used for saved plots. Defaults to
|
save_plots |
Logical; save each plot as a JPEG in
|
dpi |
Resolution (dots per inch) used when saving plots. Defaults
to |
verbose |
Logical; print formatted result tables (eigenvalues,
coordinates, contributions, cos2) to the console? Defaults to
|
Invisibly, a list with elements:
The fitted "CA" object.
Eigenvalue/inertia table from
get_eigenvalue.
A named list of the individual ggplot objects
(scree, biplot, row, col,
contrib_row_dim1, contrib_row_dim2,
contrib_col_dim1, contrib_col_dim2,
cos2_row, cos2_col) plus combined, a
gridExtra arrangement of the scree plot, biplot, and the
two dimension-1 contribution plots.
geno <- get_genotype_traits() report <- ca_report(geno, save_plots = FALSE, verbose = FALSE) report$plots$biplotgeno <- get_genotype_traits() report <- ca_report(geno, save_plots = FALSE, verbose = FALSE) report$plots$biplot
CA row-only plot
ca_row_plot(res.ca, axes = c(1, 2), col.row = "#1F4E79", ...)ca_row_plot(res.ca, axes = c(1, 2), col.row = "#1F4E79", ...)
res.ca |
|
axes |
Length-2 integer vector of the dimensions to plot. Defaults
to |
col.row |
Color for row points/labels. Defaults to |
... |
Additional arguments passed to
|
A ggplot object.
Scree plot of CA eigenvalues
ca_scree_plot(res.ca, ...)ca_scree_plot(res.ca, ...)
res.ca |
|
... |
Additional arguments passed to
|
A ggplot object.
Loads the example data set shipped with the package: a table of plant genotypes (rows) evaluated across six morphological/agronomic traits (columns). This is the same data used in the package vignette and examples.
get_genotype_traits()get_genotype_traits()
A numeric data.frame with genotypes as row names and traits as
columns.
geno <- get_genotype_traits() head(geno)geno <- get_genotype_traits() head(geno)
Reads a delimited text file into a numeric data.frame suitable for
CA. The first column is used as row names, and
every remaining column is coerced to numeric.
read_ca_data(file, sep = ",", header = TRUE, row.names = 1, check.names = FALSE)read_ca_data(file, sep = ",", header = TRUE, row.names = 1, check.names = FALSE)
file |
Path to a delimited text file (e.g. CSV). |
sep |
Field separator passed to |
header |
Logical; does the file have a header row? Defaults to
|
row.names |
Column to use as row names, passed to
|
check.names |
Logical; passed to |
A numeric data.frame with row names taken from the input file.
file <- system.file("extdata", "genotype_traits.csv", package = "CAbiplot") data <- read_ca_data(file) head(data)file <- system.file("extdata", "genotype_traits.csv", package = "CAbiplot") data <- read_ca_data(file) head(data)
Thin, validating wrapper around CA. Accepts
either a numeric matrix/data.frame already in memory, or a path to a
delimited text file, which is read with read_ca_data.
run_ca(data, ...)run_ca(data, ...)
data |
A numeric matrix, numeric |
... |
Additional arguments passed on to |
An object of class "CA" as returned by
CA, computed with graph = FALSE.
geno <- get_genotype_traits() res.ca <- run_ca(geno) summary(res.ca)geno <- get_genotype_traits() res.ca <- run_ca(geno) summary(res.ca)