Package 'specieschrom'

Title: The Species Chromatogram
Description: A simple method to display and characterise the multidimensional ecological niche of a species. The method also estimates the optimums and amplitudes along each niche dimension. Give also an estimation of the degree of niche overlapping between species. See Kleparski and Beaugrand (2022) <doi:10.1002/ece3.8830> for further details.
Authors: Loick Kleparski [aut, cre] , Gregory Beaugrand [aut] , Universite Littoral Cote d'Opale (ULCO) [cph]
Maintainer: Loick Kleparski <[email protected]>
License: GPL-3
Version: 1.0.0
Built: 2025-02-11 04:12:08 UTC
Source: https://github.com/loick-klpr/specieschrom

Help Index


Display the multidimensional ecological niche of a species with a species chromatogram.

Description

Display the multidimensional ecological niche of a species as an array of coloured cells (alpha categories by p environmental variables).

Usage

chromato_env16(z, y, alpha, m, k, order_smth)

Arguments

z

a matrix with n samples by p environmental variables (i.e. the value of each environmental variable in each sample)

y

a vector with the abundance of a species in the n samples

alpha

an integer corresponding to the number of category along each environmental variable

m

an integer corresponding to the lowest number of samples needed in a category in order to have an estimation of the mean abundance

k

an integer corresponding to the percentage of samples with the highest abundance use to estimate the mean abundance of a species in a given category

order_smth

an integer corresponding the order of the simple moving average applied along each niche dimension

Value

chr2 a matrix corresponding to the species chromatogram (alpha categories by p environmental variables)

Examples

# Load the example datasets
data("data_abundance")
data("environment")
# Characterise and display the ecological niche of a pseudo-species
# `alpha`=50 categories, `m`=1 sample, `k`=5 and `order_smth`=2
sp_chrom_PS1<-chromato_env16(environment,data_abundance[,1],50,1,5,2)

Estimate the degree of niche overlapping among species from their chromatograms.

Description

Function that returns the lowest degree of niche overlapping (index D) among all the species when 1 to p environmental variables are considered. Also return the degree of niche overlapping (index D) among each couple of species when all the environmental variables are considered simultaneously and the lowest degree of niche overlapping (index D) when each environmental variable is considered alone.

Usage

combina_niche3(sp_chr, Thres_T)

Arguments

sp_chr

a matrix with the species chromatograms (alpha categories by p-environmental variables by species). Outputs of 'chromato_env16.R'

Thres_T

an integer corresponding to the threshold of minimal abundance in a category for niche breadth estimation

Value

Return a list composed of three matrices:

combi_dim, which contains the mean degree of niche overlapping. In combi_dim, the first column displays the number of dimensions considered simultaneously and the last column displays the index D associated with the combination of dimensions. Columns between the first and the last display the combinations of dimensions considered.

sp_by_sp, a matrix with the degree of niche overlapping (index D) species by species when all the dimensions are considered.

dim_alone, a vector with the mean degree of niche overlapping (index D) when each dimension is considered alone.

D=0 when species niches are fully different and D=100 when species niches are identical; the higher the number of dimensions, the lower the value of index D.

Examples

# Load the example datasets
data("data_abundance")
data("environment")
# Characterise and display the ecological niche of 2 pseudo-species
# `alpha`=50 categories, `m`=1 sample, `k`=5 and `order_smth`=2
sp_chrom_PS3<-chromato_env16(environment,data_abundance[,3],50,1,5,2)
sp_chrom_PS8<-chromato_env16(environment,data_abundance[,8],50,1,5,2)
# Combine the species chromatograms along a third dimension with `abind`
library(abind)
test_PS<-abind::abind(sp_chrom_PS3,sp_chrom_PS8,along=3)
# Apply the function `combina_niche3.R` on the matrix `test_PS` with `Thres_T`=0
Index_D_PS<-combina_niche3(test_PS,0)

Abundance of 14 pseudo-species. A dataset containing the abundance values of 14 pseudo-species in 100 samples. The environmental conditions associated with each samples are described in the environment dataset. Pseudo-species v1 and v2, v3 and v4, v5 and v6, v7 and v8, v9 and v10, v11 and v12, v13 and v14 have the same niche.

Description

Abundance of 14 pseudo-species. A dataset containing the abundance values of 14 pseudo-species in 100 samples. The environmental conditions associated with each samples are described in the environment dataset. Pseudo-species v1 and v2, v3 and v4, v5 and v6, v7 and v8, v9 and v10, v11 and v12, v13 and v14 have the same niche.

Usage

data(data_abundance)

Format

A data frame with 100 rows and 14 variables:

PS1

Abundance of pseudo-species 1

PS2

Abundance of pseudo-species 2

PS3

Abundance of pseudo-species 3

PS4

Abundance of pseudo-species 4

PS5

Abundance of pseudo-species 5

PS6

Abundance of pseudo-species 6

PS7

Abundance of pseudo-species 7

PS8

Abundance of pseudo-species 8

PS9

Abundance of pseudo-species 9

PS10

Abundance of pseudo-species 10

PS11

Abundance of pseudo-species 11

PS12

Abundance of pseudo-species 12

PS13

Abundance of pseudo-species 13

PS14

Abundance of pseudo-species 14

...

Author(s)

Loïck Kléparski [email protected]


Three fictive environmental variables A dataset containing the values of three fictive envionemental variables in 100 samples. The corresponding pseudo-species abundance in each sample are available in the data_abundance dataset.

Description

Three fictive environmental variables A dataset containing the values of three fictive envionemental variables in 100 samples. The corresponding pseudo-species abundance in each sample are available in the data_abundance dataset.

Usage

data(environment)

Format

A data frame with 100 rows and 3 variables:

x1

an environmental gradient from 0 to 25

x2

an environmental gradient from 0 to 40

x3

an environmental gradient from 1 to 0

...

Author(s)

Loïck Kléparski [email protected]


m order simple moving average.

Description

Apply a m order simple moving average on each column of a matrix.

Usage

moymob1(x, m)

Arguments

x

a matrix with in line the observations and in column the variables

m

an integer corresponding to the window size (2m+1)

Value

smoothed matrix


Mean of the n highest values of a vector.

Description

Estimates the mean of the n% highest values in vector x.

Usage

nanmean4(x, n)

Arguments

x

a vector with the values to average

n

an integer corresponding to the percentage of values to use

Value

mean of the n% highest values in vector x


Nested function for niche overlapping estimation with 'combina_niche3.R'.

Description

Select the couple of species for niche overlapping (index D) estimation.

Usage

niche_difer_sp(sp_chr, Thres_T)

Arguments

sp_chr

a three dimensional matrix with the species chromatograms (alpha category by p environmental variables by species)

Thres_T

an integer corresponding to the threshold of minimal abundance in a category for the niche breadth estimation

Value

index D


Nested function for niche overlapping estimation with 'combina_niche3.R' and 'niche_differ_sp.R'.

Description

Estimate the niche overlapping (index D) between two species. Assume that the niche is rectangular. Columns (i.e. environmental variables) in 'spe_chr1' and 'sp_chr2' have to be the same.

Usage

niche_difer2(sp_chr1, sp_chr2, Thres_T)

Arguments

sp_chr1

a matrix (niche categories by environmental variables) for species 1

sp_chr2

a matrix (niche categories by environmental variables) for species 2

Thres_T

an integer corresponding to the threshold of minimal abundance in a category for the niche breadth estimation

Value

index D


Optimums and amplitudes estimations along each niche dimension.

Description

Function that estimates niche optimums and amplitudes along each environmental variable and for each species.

Usage

opti_eury_niche2(sp_chr, Thres_T, z, y, k)

Arguments

sp_chr

a matrix with the species chromatograms (categories by environmental variables by species). Outputs of 'chromato_env16.R'

Thres_T

an integer corresponding to the min abundance threshold for niche amplitudes estimations

z

a matrix with n samples by p environmental variables (i.e. the value of each environmental variable in each sample). Same matrix as in 'chromato_env16.R'.

y

a matrix with the species abundance in the n samples

k

an integer corresponding to the percentage of samples with the highest abundance values to use to estimate the mean abundance in a given category. Should have the same value as in 'chromato_env16.R'

Value

Three matrices are returned:

amplitudes, a matrix with the degree of euryoecie (niche breadth) of each species (in column) along each environmental dimension (in line)

mean_amplitudes, a matrix with the mean degree of euryoecie of each species

optimums, a matrix with the niche optimum values of each species (in column) along each environmental dimension (in line)

Examples

# Load the example datasets
data("data_abundance")
data("environment")
# Characterise and display the ecological niche of 2 pseudo-species
# `alpha`=50 categories, `m`=1 sample, `k`=5 and `order_smth`=2
sp_chrom_PS3<-chromato_env16(environment,data_abundance[,3],50,1,5,2)
sp_chrom_PS8<-chromato_env16(environment,data_abundance[,8],50,1,5,2)
# Combine the species chromatograms along a third dimension with `abind`
library(abind)
test_PS<-abind::abind(sp_chrom_PS3,sp_chrom_PS8,along=3)
# `opti_eury_niche2.R` can then be applied, with `Thres_T`=0 and `k`=5
opti_ampli_niche<-opti_eury_niche2(test_PS,0,environment,data_abundance[,c(3,8)],5)