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] |
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 |
Display the multidimensional ecological niche of a species as an array of coloured cells (alpha categories by p environmental variables).
chromato_env16(z, y, alpha, m, k, order_smth)
chromato_env16(z, y, alpha, m, k, order_smth)
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 |
chr2 a matrix corresponding to the species chromatogram (alpha categories by p environmental variables)
# 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)
# 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)
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.
combina_niche3(sp_chr, Thres_T)
combina_niche3(sp_chr, Thres_T)
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 |
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.
# 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)
# 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.
data(data_abundance)
data(data_abundance)
A data frame with 100 rows and 14 variables:
Abundance of pseudo-species 1
Abundance of pseudo-species 2
Abundance of pseudo-species 3
Abundance of pseudo-species 4
Abundance of pseudo-species 5
Abundance of pseudo-species 6
Abundance of pseudo-species 7
Abundance of pseudo-species 8
Abundance of pseudo-species 9
Abundance of pseudo-species 10
Abundance of pseudo-species 11
Abundance of pseudo-species 12
Abundance of pseudo-species 13
Abundance of pseudo-species 14
...
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.
data(environment)
data(environment)
A data frame with 100 rows and 3 variables:
an environmental gradient from 0 to 25
an environmental gradient from 0 to 40
an environmental gradient from 1 to 0
...
Loïck Kléparski [email protected]
Apply a m order simple moving average on each column of a matrix.
moymob1(x, m)
moymob1(x, m)
x |
a matrix with in line the observations and in column the variables |
m |
an integer corresponding to the window size (2m+1) |
smoothed matrix
Estimates the mean of the n% highest values in vector x.
nanmean4(x, n)
nanmean4(x, n)
x |
a vector with the values to average |
n |
an integer corresponding to the percentage of values to use |
mean of the n% highest values in vector x
Select the couple of species for niche overlapping (index D) estimation.
niche_difer_sp(sp_chr, Thres_T)
niche_difer_sp(sp_chr, Thres_T)
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 |
index D
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.
niche_difer2(sp_chr1, sp_chr2, Thres_T)
niche_difer2(sp_chr1, sp_chr2, Thres_T)
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 |
index D
Function that estimates niche optimums and amplitudes along each environmental variable and for each species.
opti_eury_niche2(sp_chr, Thres_T, z, y, k)
opti_eury_niche2(sp_chr, Thres_T, z, y, k)
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' |
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)
# 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)
# 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)