Package 'UpSetVP'

Title: An Alternative Visualization of VPA and HP in Canonical Analysis
Description: Using matrix layout to visualize the unique, common, or individual contribution of each predictor (or matrix of predictors) towards explained variation on canonical analysis. These contributions were derived from variance partitioning analysis (VPA) and hierarchical partitioning (HP), applying the algorithm of Lai J., Zou Y., Zhang J., Peres-Neto P. (2022) Generalizing hierarchical and variation partitioning in multiple regression and canonical analyses using the rdacca.hp R package.Methods in Ecology and Evolution, 13: 782-788 <doi:10.1111/2041-210X.13800>.
Authors: Yao Liu
Maintainer: Yao Liu <[email protected]>
License: GPL (>= 2)
Version: 1.0.0
Built: 2025-02-21 04:31:08 UTC
Source: https://github.com/liuxyh/upsetvp

Help Index


EcM Fungal Data with Environmental Variables

Description

Ectomycorrhizal (EcM) fungal community and environmental data were excerpted from Gong et al. (2022). Sampling was conducted along the elevation gradient (2,900 m to 4,500 m) in the eastern slope of Baima Snow Mountain during both dry (November 2017) and wet (August 2018) seasons after studying community compositions of the host plants of EcM fungi.

Usage

data(baima.fun)

data(baima.env)

Format

263 samples from the root tips were excerpted. There are two linked data sets: baima.fun, a data frame containing 3,099 amplicon sequence variants (ASVs) of root associated EcM fungi; baima.env, a data frame containing 14 environmental variables.

The fields in the environmental data are:

environmental_medium

Sample type

latitude

Latitude

lontitude

Lontitude

altitude

Elevation (m)

season

Season, a factor with levels dry and wet

em.GR

Richness of EcM plant at genus level

em.abun

The number of individuals of each EcM genus

sea.MT

Dry-season and wet-season mean temperature

pH

Soil pH

TP

Total phosphorus (g/kg)

TK

Total potassium (g/kg)

AN

Alkaline-hydrolysable nitrogen (mg/kg)

AP

Available phosphorus (mg/kg)

AK

Available potassium (mg/kg)

References

Gong S, Feng B, Jian S P, et al. Elevation Matters More than Season in Shaping the Heterogeneity of Soil and Root Associated Ectomycorrhizal Fungal Community. Microbiology spectrum, 2022, 10(1): e01950-21.

Examples

data(baima.fun)
data(baima.env)

Visualization of HP Using Column Diagram

Description

Visualization of individual effects in hierarchical partitioning (HP) using column diagram.

Usage

barplot_hp(
  x,
  order.var = TRUE,
  decreasing.var = TRUE,
  cutoff = -1,
  col.fill = "valid",
  col.color = NULL,
  col.width = 0.6,
  show.effect = TRUE,
  effect.cex = 2.7,
  title.cex = 10,
  axis.cex = 8
)

Arguments

x

A rdacca.hp object, which contains the output of HP from canonical analysis.

order.var

The predictors in the matrix layout should be ordered by. Default is TRUE, which orders the predictors by their effect values. IF FALSE, sort by the order of predictors in input data.

decreasing.var

If order.var=TRUE, how the predictors should be ordered. Default is TRUE, from greatest to least.

cutoff

Effect values below cutoff will not be displayed, default is -1. Note: Negative values due to adjustment of R-squared mean negligible contributions, but they are included in the computation of the total contribution of each predictor category.

col.fill

How the bars should be colored. Options include "valid" (according to the validity of effects) or "vars" (color by predictors), default is "valid".

col.color

Color of bars.

col.width

Width of bars, default is 0.6.

show.effect

Show the effect values above bars, default is TRUE.

effect.cex

Font size of the effect values, default is 2.7.

title.cex

Font size of axis titles, default is 10.

axis.cex

Font size of axis labels, default is 8.

Details

This function is used to visualize the object of rdacca.hp (Lai et al. 2022), which calculates the individual effects of predictor variables or groups of predictor variables in canonical analysis based on HP.

Value

Returns a ggplot2.

References

Lai J., Zou Y., Zhang J., Peres-Neto P. (2022) Generalizing hierarchical and variation partitioning in multiple regression and canonical analyses using the rdacca.hp R package. Methods in Ecology and Evolution, 13:782-788.

Examples

## A simple example of partial dbRDA
data(baima.fun)
data(baima.env)

# Bray-Curtis index was used to calculate community composition dissimilarity
baima.fun.bray <- vegan::vegdist(baima.fun, method = "bray")

# Quantify the individual effects of soil properties on EcM fungal community composition
soil <- baima.env[c("pH", "TP", "TK", "AN", "AP", "AK")]
baima.soil.vp <- rdacca.hp::rdacca.hp(baima.fun.bray, soil, method = "dbRDA", type = "adjR2")

# Plot individual effects
barplot_hp(baima.soil.vp, col.fill = "var", 
 col.color = c("#8DD3C7", "#FFFFB3", "#BEBADA", "#FB8072", "#80B1D3", "#FDB462", "#B3DE69"))

Visualization of VPA and HP Using UpSetVP Diagram

Description

Visualization of variance partitioning analysis (VPA) and hierarchical partitioning (HP) with unlimited number of predictor variables (or matrices of predictors) using UpSet matrix layout.

Usage

upset_vp(
  x,
  plot.hp = TRUE,
  order.part = "effect",
  decreasing.part = TRUE,
  order.var = TRUE,
  decreasing.var = TRUE,
  cutoff = -1,
  nVar = 30,
  col.width = 0.6,
  pch.size = 3,
  line.lwd = 0.5,
  show.effect = TRUE,
  effect.cex = 2.7,
  title.cex = 10,
  axis.cex = 8,
  height.ratio = c(2, 1),
  width.ratio = c(1, 3)
)

Arguments

x

A rdacca.hp object, which contains the output of VPA and HP from canonical analysis.

plot.hp

The default is TRUE, which plots the individual effect for each predictor on left column diagram. If FALSE, compute and plot the sum of unique effect and common effect for each predictor.

order.part

How the VPA components in matrix layout should be ordered. Options include "effect" (order the intersections by their effects) or "degree" (sort by the number of predictors involved in the intersection), default is "effect".

decreasing.part

How the intersections in order.part should be ordered. Default is TRUE, "effect" is decreasing (from greatest to least) or "degree" is increasing (from least to greatest).

order.var

The predictors in the matrix layout should be ordered by. Default is TRUE, which orders the predictors by their effects. IF FALSE, sort by the order of predictors in input data.

decreasing.var

If order.var=TRUE, how the predictors should be ordered. Default is TRUE, from greatest to least.

cutoff

Effects below cutoff will not be displayed, default is -1. Note: Negative effects due to adjustment of R-squared mean negligible contributions, but they are included in the computation of the total contribution of each predictor category.

nVar

Number of components in VPA to plot, default is 30.

col.width

Width of bars in column diagram, default is 0.6.

pch.size

Size of points in matrix diagram, default is 3.

line.lwd

Width of lines in matrix diagram, default is 0.5.

show.effect

Show the relative importance of predictors (unique, common, or individual effects) above bars, default is TRUE.

effect.cex

Font size of the effects, default is 2.7.

title.cex

Font size of axis titles, default is 10.

axis.cex

Font size of axis labels, default is 8.

height.ratio

Ratio between matrix and top column diagram, default is c(2, 1).

width.ratio

Ratio between matrix and left column diagram, default is c(1, 3).

Details

UpSetVP diagram is an extension of UpSet technique to canonical analysis and is used to visualize the object of rdacca.hp (Lai et al. 2022; Liu et al. 2023). The matrix layout enables the effective representation of relative importance of predictors, such as the unique effects and common effects in VPA, as well as additional summary statistics or individual effects in HP. UpSetVP diagram could, in principle, allow visualization of any number of predictor variables or groups of predictor variables. But considering the interpretability of data, we would like to recommend that the number of predictors (or groups of predictors) no more than 7.

Value

Returns a ggplot2.

References

Lai J., Zou Y., Zhang J., Peres-Neto P. (2022) Generalizing hierarchical and variation partitioning in multiple regression and canonical analyses using the rdacca.hp R package. Methods in Ecology and Evolution, 13:782-788.

Liu Y., Yu X., Yu Y., et al. (2023) Application of "rdacca. hp" R package in ecological data analysis: case and progress. Chinese Journal of Plant Ecology, 27:134-144.

Examples

## A simple example of partial dbRDA
data(baima.fun)
data(baima.env)

# Bray-Curtis index was used to calculate community composition dissimilarity
baima.fun.bray <- vegan::vegdist(baima.fun, method = "bray")

# The relative importance of individual soil properties on EcM fungal community compositionon
soil <- baima.env[c("pH", "TP", "TK", "AN", "AP", "AK")]
baima.soil.vp <- rdacca.hp::rdacca.hp(baima.fun.bray, soil,
  method = "dbRDA", var.part = TRUE, type = "adjR2")

# Plot unique, common, as well as individual effects
upset_vp(baima.soil.vp, plot.hp = TRUE)

## Example was referenced from Gong et al. (2022)
if(requireNamespace("adespatial", quietly = TRUE)) {
  
  # Distance-based Moran's eigenvector maps (dbMEM) was used to extract spatial relationships
  space.dbmem <- adespatial::dbmem(baima.env[c("latitude", "lontitude")])
  
  # The relative importance of groups of environmental factors on EcM fungal community composition
  env.list <- list(
    elevation = baima.env["altitude"],
    season = baima.env["season"],
    space = data.frame(space.dbmem)[1:2],
    host = baima.env[c("em.GR", "em.abun")],
    climate = baima.env["sea.MT"],
    soil = baima.env[c("pH", "TP", "TK", "AN", "AP", "AK")]
  )
  baima.env.vp <- rdacca.hp(baima.fun.bray, env.list,
    method = "dbRDA", var.part = TRUE, type = "adjR2")
  
  # Plot unique, common, as well as individual effects
  upset_vp(baima.env.vp, plot.hp = TRUE, order.part = "degree")
}