Version: 1.0.2
Date: 2019-07-06
Title: Modeling Non-Continuous Linear Responses of Ecological Data
Author: Danilo C Vieira <vieiradc@yahoo.com.br>, Gustavo Fonseca <gfonseca.unifesp@gmail.com>, and Fabio Cop Ferreira <fabiocferreira.unifesp@gmail.com>, with contributions from Marco Colossi Brustolin.
Maintainer: Danilo C Vieira <vieiradc@yahoo.com.br>
Description: Tools for modeling non-continuous linear responses of ecological communities to environmental data. The package is straightforward through three steps: (1) data ordering (function OrdData()), (2) split-moving-window analysis (function SMW()) and (3) piecewise redundancy analysis (function pwRDA()). Relevant references include Cornelius and Reynolds (1991) <doi:10.2307/1941559> and Legendre and Legendre (2012, ISBN: 9780444538697).
Depends: R (≥ 2.15), vegan (≥ 2.4)
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.1.1
Suggests: knitr, rmarkdown, testthat
VignetteBuilder: knitr
URL: https://github.com/DaniloCVieira/segRDA
BugReports: https://github.com/DaniloCVieira/segRDA/issues
License: MIT + file LICENSE
NeedsCompilation: no
Packaged: 2019-07-26 20:06:34 UTC; Danilo
Repository: CRAN
Date/Publication: 2019-07-31 07:30:02 UTC

segRDA: Modeling Non-Continuous Linear Responses of Ecological Data

Description

Tools for modeling non-continuous linear responses of ecological communities to environmental data. The package is straightforward through three steps: (1) data ordering (function OrdData()), (2) split-moving-window analysis (function SMW()) and (3) piecewise redundancy analysis (function pwRDA()). Relevant references include Cornelius and Reynolds (1991) <doi:10.2307/1941559> and Legendre and Legendre (2012, ISBN: 9780444538697).

See Also

Useful links:


Data ordering

Description

Ordinates both community and explanatory matrices based on the first RDA score.

Usage

OrdData(x, y, axis = 1, method = NA, ...)

Arguments

x

explanatory matrix;

y

community matrix;

axis

the RDA axis in which the ordering should be based. Defaults to axis=1

method

standardization method (described in decostand) to be applied on y before the RDA analysis. If NA (default), no transformation is performed.

...

furhter parameters passed to decostand and vegan::rda;

Value

An object of class "ord", which is a list consisting of:

  1. xo: the ordered explanatory matrix

  2. yo: the ordered community matrix (non-transformed)

  3. x: the original explanatory matrix

  4. y: the original community matrix

Author(s)

Danilo Candido Vieira

Examples

data(sim1)
sim1.o<-OrdData(x=sim1$envi, y=sim1$comm)
sim1.o<-OrdData(x=sim1$envi, y=sim1$comm, method="hellinger")

Split moving window analysis

Description

Function SMW performs split moving window analysis (SMW) with randomizations tests. It may compute dissimilarities for a single window size or for several windows sizes.

Usage

SMW(yo, ws, dist = "bray", rand = c("shift", "plot"), n.rand = 99)

Arguments

yo

The ordered community matrix.

ws

The window sizes to be analyzed. Either a single value or a vector of values.

dist

The dissimilarity index used in vegan::vegdist. Defaults to 'bray'.

rand

The type of randomization for significance computation (Erdös et.al, 2014):

  • "shift": restricted randomization in which data belonging to the same species are randomly shifted along the data series ("Random shift");

  • "plot": unrestricted randomization: each sample is randomly repositioned along the data series ("Random plot").

n.rand

The number of randomizations.

Value

A two-level list object (class smw) describing the SMW results for each window w analyzed. The smw object is of length ws, and each of the w slots is a list of SMW results:

Available methods for class "smw" are print, extract and plot.

Author(s)

Danilo Candido Vieira

References

See Also

plot.smw, extract.

Examples

data(sim1)
sim1o<-OrdData(sim1$envi,sim1$comm)


ws20<-SMW(yo=sim1o$yo,ws=20)
pool<-SMW(yo=sim1o$yo,ws=c(20,30,40))


Extract results and breakpoints from a smw object

Description

Functions to extract results and breakpoints from a smw object

Usage

## S3 method for class 'smw'
extract(smw, w = NULL, index = "dp", sig = "z",
  z = 1.85, BPs = "max", seq.sig = 3)

## S3 method for class 'dp'
bp(dp)

Arguments

smw

An object of class smw resulted from the SMW analysis.

w

Numeric. A "target" window size from which results will be extracted (see Details). Only effective if the smw object contains results from multiple window sizes.

index

The result to be extracted:

  • "dp": The dissimilarity profile (DP) table containing significant discontinuities and suggested breakpoints. The returned DP has class "dp", with an own generic print method. The print command prints and returns invisibly the DP.

  • "rdp": data frame containing the randomized DP;

  • "md": mean dissimilarity of the randomized DP;

  • "sd": standard deviation for each sample position;

  • "oem": overall expected mean dissimilarity;

  • "osd": average standard deviation for the dissimilarities;

  • "params": list with input arguments

sig

Significance test for detecting dissimilarity values that differs significantly from those appearing in a random pattern. The following tests are considered with default to sig.test="z":

  • "dp" consider normalized dissimilarity (z-scores) discontinuities that exceed a "z" critical value;

  • "sd" consider dissimilarity discontinuities that exceed mean plus one standard deviation;

  • "SD2" consider dissimilarity discontinuities that exceed mean plus two standard deviation;

  • "tail1" Consider dissimilarity discontinuities that exceed 95 percent confidence limits.

z

The critical value for the significance of z-values. Defaults to 'z=1.85' (Erdös et.al, 2014).

BPs

Defines if the breakpoints should be chosen as those sample positions corresponding to the maximum dissimilarity in a sequence of significant values ("max") or as those sample positions corresponding to the median position of the sequence ("median"). Defaults to BPs="max". If NULL the breakpoints are not computed.

seq.sig

The maximum length of consecutive, significant values of dissimilarity that will be considered in defining the community breakpoints. Defaults to seq.sig=3;

dp

An object of class dp (see Details).

Details

If the smw object contains results from multiple window sizes, the DP table will be based on the average Z-score over the set of analysed window sizes. Available methods for class "dp" are print, bp and plot.

The argument w is optional. If the smw object is length 1, w is ignored. If length(smw)>1 and w is NULL, the function will extract the dissimilarity profile averaged over the set of window sizes.

Value

See Also

plot.smw.

Examples

data(sim1)
sim1o<-OrdData(sim1$envi,sim1$comm)


ws50<-SMW(yo=sim1o$yo,ws=50)
ws50_dp<-extract(ws50)
head(ws50_dp)


Nematodes data from Araca Bay, Sao Sebastiao, Brazil.

Description

A total of 37 sites arranged in an irregular grid were surveyed during four sampling campaigns at the Araçá Bay, southeastern Brazil. A total of 141 samples were collected for analyzing changes in nematodes assemblages along the environmental gradient of the bay.

Usage

data(nema)

Format

nema is a list with the following components:

envi

a matrix with 141 sites and 9 environmental variables: chlorophyll a (mg.m-2), bathymetry (meters), percentage of total organic carbon, percentage of coarse sands (as the sum of pebbles, very coarse, coarse, and medium grains), percentage of fine sand, percentage of very fine sand, mean grain size, and sorting coefficient.

comm

matrix with 141 sites of 194 nematodes species

References


Plot the dissimilarity profiles

Description

Plot results from smw and dp objects. The command is a shortcut for extracting and plotting SMW resuts. Auxiliary arguments from extract (i.e. sig, z, BPs and seq.sig) can be passed to plot.smw. The auxilary method bgDP is available for the returned dp object when the argument bg is not NULL (see Details).

Usage

## S3 method for class 'smw'
plot(x, w = NULL, sig = "z", z = 1.85, BPs = "max",
  seq.sig = 3, w.effect = F, values = c("zscore", "diss"),
  pchs = c(16, 16, 17), cols = c("black", "red", "blue"), bg = NULL,
  bg_alpha = 0.1, wcols = "rainbow", legend = TRUE, ...)

## S3 method for class 'dp'
bgDP(dp)

Arguments

x

An object of class "smw" resulted from the function SMW.

w

The window size from which results will be plotted. Only effective if length(smw)>1.

sig

Significance test for detecting dissimilarity values that differs significantly from those appearing in a random pattern. If NULL the significance test is ommited from the plot.The following tests are considered with default to sig.test="z":

  • 'z' consider normalized dissimilarity (z-scores) discontinuities that exceed a "z" critical value;

  • 'sd' consider dissimilarity discontinuities that exceed mean plus one standard deviation;

  • 'SD2' consider dissimilarity discontinuities that exceed mean plus two standard deviation;

  • 'tail1' Consider dissimilarity discontinuities that exceed 95 percent confidence limits.

z

The critical value for the significance of z-values. Defaults to 'z=1.85' (Erdös et.al, 2014).

BPs

Defines if the breakpoints should be chosen as those sample positions corresponding to the maximum dissimilarity in a sequence of significant values ("max") or as those sample positions corresponding to the median position of the sequence ("median"). Defaults to BPs="max". If NULL the breakpoints are not computed.

seq.sig

The maximum length of consecutive, significant values of dissimilarity that will be considered in defining the community breakpoints. Defaults to seq.sig=3;

w.effect

Logical, if TRUE draws a dissimilarity profile using different windows sizes and returns an invisible data.frame with the breakpoint frequencies. Only effective if length(smw)>1. The function uses extract with defaults parameters to define the breakpoint positions for each of the evaluated window sizes.

values

Character. "zscore" for plotting z-scores, "diss" for plotting dissimilarity values.

pchs

A numerical vector of the form c(d,s,b) which modifies the default symbols of the plot. The default pch = c(16,16,17) describes respectively the dissimilarity values, significant dissimilarity values and breakpoints.

cols

Vector of length 3 specifying the colors of the plot in the same way as the pch argument. Defaults to colors=c("black","red","blue").

bg

Optional. Sets background colors according to the breakpoints. It can be expressed either by a vector of colors or by the name of a pallet function (e.g. "rainbow").

bg_alpha

Factor modifying the opacity alpha of the backgroud [0,1].

wcols

Sets the colors for the window sizes (lines) when w.effect=TRUE. It can be expressed by a vector of colors or by the name of a pallet function. Defaults to wcol="rainbow" which uses the colour palette rainbow from R stats.

legend

Logical. Should a default legend appear?

...

Further graphical parameters.

dp

An object of class dp.

Details

If bg is not NULL, the attribute params$bg is added to the returned dp. This attribute contains the sample colors used by the argument bg. The auxilary method bgDP can be used for accessing this color vector.

Value

The function returns invisibly an object of class "dp" (see Details).

Author(s)

Danilo Candido Vieira

See Also

SMW, extract.

Examples

data(sim1)
sim1o<-OrdData(sim1$envi,sim1$comm)


ws20<-SMW(yo=sim1o$yo,ws=20)
pool<-SMW(yo=sim1o$yo,ws=c(20,30,40))
plot(ws20)
plot(pool, w.effect=TRUE)


Piecewise redundancy analysis (pwRDA)

Description

Perform a pwRDA using the specified breakpoints

Usage

pwRDA(x.ord, y.ord, BPs, n.rand = 99)

Arguments

x.ord

ordered explanatory matrix

y.ord

ordered community matrix

BPs

community breakpoints

n.rand

The number of randomizations for significance computation

Value

Returns an invisible list of length 4:

  1. ..$summ: summary statistics of the pwRDA analysis;

  2. ..$rda.0: full model cca object, which is described separately in vegan::cca.object

  3. ..$rda.pw: pw model cca object, which is described separately in vegan::cca.object

Author(s)

Danilo Candido Vieira

Examples

data(sim1)
sim1o<-OrdData(sim1$envi,sim1$comm)


w50<-SMW(sim1o$yo, ws=50)
sim1.pw<-pwRDA(sim1o$xo,sim1o$yo, BPs=bp(extract(w50)))


Simulated datasets

Description

Simulated datasets for testing segRDA package

Usage

data(sim1)

data(sim2)

data(sim3)

Format

Each data set is a list with the following components:

envi

environmental matrix

comm

community matrix