Package 'GABB'

Title: Facilitation of Data Preparation and Plotting Procedures for RDA and PCA Analyses
Description: Help to the occasional R user for synthesis and enhanced graphical visualization of redundancy analysis (RDA) and principal component analysis (PCA) methods and objects. Inputs are : data frame, RDA (package 'vegan') and PCA (package 'FactoMineR') objects. Outputs are : synthesized results of RDA, displayed in console and saved in tables ; displayed and saved objects of PCA graphic visualization of individuals and variables projections with multiple graphic parameters.
Authors: Gregoire Bianchetti [aut, cre]
Maintainer: Gregoire Bianchetti <[email protected]>
License: MIT + file LICENSE
Version: 0.3.8
Built: 2024-10-31 20:28:50 UTC
Source: CRAN

Help Index


check_data_for_RDA function

Description

This function check if the factor variables used for RDA fit the required conditions. Results are grouped and conclusions go / no go are displayed in the console and saved in a table. This function is mainly derived from the explanations of Maxime Herve https://www.maximeherve.com/r-et-statistiques

Usage

check_data_for_RDA(data_quant, initial_data, factor_names)

Arguments

data_quant

Data frame of numeric values, generally transformed and scalled

initial_data

Initial data frame, including both numeric and factor columns

factor_names

Character vector of considered factor variables/columns : c("Variable1", "Variable2")

Value

Outputs are saved in a data frame and conclusions are displayed in console.

Examples

check_data_for_RDA(mtcars[,1:7], mtcars, c("gear","carb"))

PCA_RDA_graphics function This function facilitate the user creation of PCA (! from FactoMineR package !) enhanced graphics with multiple options. Individuals and variables graphics are possible. With or without variable cor, cos, contrib.. correlation to dimensions. RDA outputs are displayable as table under graphics.

Description

PCA_RDA_graphics function This function facilitate the user creation of PCA (! from FactoMineR package !) enhanced graphics with multiple options. Individuals and variables graphics are possible. With or without variable cor, cos, contrib.. correlation to dimensions. RDA outputs are displayable as table under graphics.

Usage

PCA_RDA_graphics(
  complete.data.set,
  factor.names,
  sample.column,
  PCA.object,
  Var.quanti.supp,
  Display.quanti.supp,
  Dim.a,
  Dim.b,
  Barycenter,
  Segments,
  Barycenter.min.size,
  Ind.min.size,
  Segment.line.type,
  Segment.line.size,
  Segment.line.col,
  Ellipse.IC,
  IC.x,
  Ellipse.sd,
  sd.x,
  Ellipse.transparency,
  Barycenter.Ellipse.Fac1,
  Barycenter.Ellipse.Fac2,
  Barycenter.Ellipse.Fac3,
  factor.colors,
  color.palette,
  factor.shapes,
  factor.sizes,
  Barycenter.factor.col,
  Barycenter.factor.size,
  Barycenter.factor.shape,
  factor.col.border.ellipse,
  ellipse.line.type,
  Var.circle,
  Var.circle.size,
  Var.selected,
  Var.label.size,
  Var.label.repel,
  col.arrow.var.PCA,
  col.text.var.PCA,
  col.arrow.var.supp.PCA,
  col.circle.var.PCA,
  Biplot.PCA,
  width.PCA.ind.graph,
  width.PCA.var.graph,
  width.heat.map.graph,
  Spacing.HM.circle,
  Heat.map.graph,
  Type.heat.map.graph,
  var.parameter.heat.map,
  Dims.heat.map,
  Display.cell.values.heat.map,
  Top.var.heat.map.Dim.a,
  Top.var.heat.map.Dim.b,
  Multi.dim.combination,
  width.cell.heat.map,
  height.cell.heat.map,
  Cluster.col.heat.map,
  Cluster.row.heat.map,
  RDA.object,
  nbperms,
  RDA.table.graph,
  RDA.table.graph.height,
  Size.RDA.table.graph,
  Get.generated.data.frame
)

Arguments

complete.data.set

Original complete data set used for the PCA, with quantitative and qualitative/factor columns.

factor.names

Character vector regrouping names of considered factor variables of PCA.

sample.column

Numeric or name (character) of the individual sample column. Default is data frame row names.

PCA.object

The PCA object, built from package FactoMineR. PCA.object <- FactoMineR::PCA(mtcars_quant, scale.unit = T, ncp = 5, graph = F).

Var.quanti.supp

Character vector of column name of supplementary quantitative variables for PCA.

Display.quanti.supp

TRUE or FALSE. Display supplementary quantitative variable on PCA var and Heat map graphs.

Dim.a

Numeric value (1 ; 2 ...) of the first PCA dimension selected for graphic outputs.

Dim.b

Numeric value (1 ; 2 ...) of the first PCA dimension selected for graphic outputs.

Barycenter

TRUE or FALSE. TRUE : Calculate and Display the barycenter of individuals for Barycenter.Ellipse.Fac1 and/or .2 and/or .3.

Segments

TRUE or FALSE. TRUE : Display the linking segments between individuals and barycenters.

Barycenter.min.size

Numeric. Minimum size of barycenter point projections. Ignore if Barycenter = FALSE.

Ind.min.size

Numeric. Minimum size of individuals point projections.

Segment.line.type

Numeric. Type of segment lines (see ggplot2 line type). Ignore if Segments = FALSE.

Segment.line.size

Numeric. Minimum size of segment lines. Ignore if Segments = FALSE.

Segment.line.col

Character. Set the color of segments. Default = azure4.

Ellipse.IC

TRUE or FALSE. TRUE : Calculate and Display Ellipse of mean confidence interval of individuals for Barycenter.Ellipse.Fac1 and/or .2 and/or .3. Default is 95% mean confidence interval.

IC.x

0 to 100. Set the value of mean confidence interval of Ellipse.IC parameter. Default is 95.

Ellipse.sd

TRUE or FALSE. TRUE : Calculate and Display Ellipse of mean standard deviation of individuals for Barycenter.Ellipse.Fac1 and/or .2 and/or .3. Default is 95% mean confidence interval.

sd.x

Numeric. Set the value of the multiplication factor of sd (x*sd) for Ellipse.sd parameter. Default is 1.

Ellipse.transparency

Set the transparency level of the ellipse, ranging from 0 to 1. Default is 0.1.

Barycenter.Ellipse.Fac1

Character. Name of 1st factor/data frame column for Barycenter / Ellipses calculation.

Barycenter.Ellipse.Fac2

Character. Name of 2nd factor/data frame column for Barycenter / Ellipses calculation.

Barycenter.Ellipse.Fac3

Character. Name of 3rd factor/data frame column for Barycenter / Ellipses calculation.

factor.colors

Character. Name of the factor/column considered for individuals colors.

color.palette

Vector of characters of desired colors.

factor.shapes

Character. Name of the factor/column considered for individual and barycenter shapes.

factor.sizes

Character. Name of the factor/column considered for individual and barycenter colors.

Barycenter.factor.col

Character. Name of the factor/column considered for barycenter colors.

Barycenter.factor.size

Character. Name of the factor/column considered for barycenter size.

Barycenter.factor.shape

Character. Name of the factor/column considered for barycenter shape.

factor.col.border.ellipse

Character. Name of the factor/column considered for ellipse border colors.

ellipse.line.type

Numeric. R line type for ellipse borders.

Var.circle

TRUE or FALSE. TRUE = Display the PCA variable circle projection.

Var.circle.size

Numeric. Value for increasing the size of Var.circle graphic.

Var.selected

Character vector of selected variables for the PCA plot. Default = all variables.

Var.label.size

Numeric. Value for increasing the size of Var.circle graphic labels.

Var.label.repel

TRUE or FALSE. For PCA variables graphic, force variable labels to repel.

col.arrow.var.PCA

Character. Set the color of arrows for PCA variable plot. Default = gray20.

col.text.var.PCA

Character. Set the color of text for PCA variable plot. Default = gray20.

col.arrow.var.supp.PCA

Character. Set the color of arrows and text for PCA supplementary variable plot. Default = cadetblue.

col.circle.var.PCA

Character. Set the color of the PCA variable circle. Default = gray20.

Biplot.PCA

TRUE or FALSE. TRUE = Biplot of PCA individuals and variables graphics. Default is set to FALSE.

width.PCA.ind.graph

Numeric. Width ratio for PCA individuals graphic.

width.PCA.var.graph

Numeric. Width ratio for PCA variables graphic.

width.heat.map.graph

Numeric. Width ratio for Heat map variables graphic.

Spacing.HM.circle

Numeric. Width ratio for spacing x axis of circle heat map variables graphic. Default is 0.06.

Heat.map.graph

TRUE or FALSE. TRUE = Display the heat map of variable X parameter correlation to dimension.

Type.heat.map.graph

Character. Define the type of heat map to display : "square" or "circle". Default = "square".

var.parameter.heat.map

Character. Parameter selected for the heat map correlation of Variable parameter to dimensions. values : "cor", "cos2", "coor","contrib". Default = "cor".

Dims.heat.map

Numeric. Numeric vector c(1,2) of dimensions considered for the variable parameter correlation.

Display.cell.values.heat.map

TRUE or FALSE. TRUE = Display the rounded value of correlations within heat map cells.

Top.var.heat.map.Dim.a

Numeric. Number of variables to plot in heat maps and PCA variable projection for Dim a. Default = all.

Top.var.heat.map.Dim.b

Numeric. Number of variables to plot in heat maps and PCA variable projection for Dim b. Default = all.

Multi.dim.combination

TRUE or FALSE. TRUE = display 10 plots of PCA ind and variables dims combination (1,2 ; 1,3...).

width.cell.heat.map

Numeric. Width for Heat map cells. Default set to default pheat.map.

height.cell.heat.map

Numeric. Width for Heat map cells. Default set to default pheat.map.

Cluster.col.heat.map

TRUE or FALSE. TRUE = cluster heat.map columns / dimensions.

Cluster.row.heat.map

TRUE or FALSE. TRUE = cluster heat.map rows / quantitative variables.

RDA.object

The RDA object, built from package vegan. RDA.object <- vegan::rda(mtcars_quant, scale.unit = T, ncp = 5, graph = F).

nbperms

Numeric number of permutations used by the RDA.anova function. Default is 1000.

RDA.table.graph

TRUE or FALSE. TRUE = Display the RDA outputs table under PCA graphics.

RDA.table.graph.height

Numeric. Set the ratio of RDA table graphic height. Default is set to 1.

Size.RDA.table.graph

Numeric. Set the ratio of RDA table graphic size. Default is set to 7.

Get.generated.data.frame

TRUE or FALSE. TRUE = save the generated data frames for graphic constructions. Default = FALSE.

Value

Several graphics

Examples

library(FactoMineR)
my.PCA <- FactoMineR::PCA(mtcars[,1:7], scale.unit = FALSE, ncp = 5, graph = FALSE)
PCA_RDA_graphics(complete.data.set = mtcars, factor.names = c("vs", "gear"), PCA.object = my.PCA)

prep_data function

Description

This function helps user to transform and scale quantitative defined data (columns identitified from a given dataset) for better PCA and RDA outputs.

Usage

prep_data(data, quantitative_columns, transform_data_method, scale_data)

Arguments

data

A data frame with at least one numeric column

quantitative_columns

Numeric vector of numeric columns position : c(1,2,4)

transform_data_method

Method of quantitative data transformation : "log", "sqrt4", "clr", "none"

scale_data

TRUE or FALSE. TRUE => scaling of quantitative columns

Value

The transformed/scaled quantitative data frame

Examples

prep_data(mtcars, c(1:7), "log", TRUE)

RDA_outputs_synthesis function

Description

This function facilitate output analysis of vegan package RDA.

Usage

RDA_outputs_synthesis(RDA, RDA.synth, RDA.anova, nbperms, RDA.Table)

Arguments

RDA

The RDA object : RDA <- vegan::rda(mtcars_quant~gear+carb,data=mtcars)

RDA.synth

TRUE or FALSE. If TRUE, displays the RDA model's global variance partitioning. Default is TRUE.

RDA.anova

TRUE or FALSE. If TRUE, prints the results of the vegan function anova.cca, displaying the variance partitioning by terms in the RDA model. Default is TRUE.

nbperms

Numeric number of permutations used by the RDA.anova function. Default is 1000.

RDA.Table

TRUE or FALSE. TRUE : calculate and display the variance percentage of considered factor / total unconstrained variance. Default : TRUE.

Value

Results can be displayed in the console. Outputs are saved in data frame.

Examples

library(vegan)
my.RDA <- vegan::rda(mtcars[,1:7]~vs+am+gear, data=mtcars)
RDA_outputs_synthesis(RDA = my.RDA, RDA.synth = TRUE, RDA.anova = FALSE, RDA.Table = TRUE)