Skip to contents

Cz metrics

Usage

contribution(cluster_object, comat, indices = c("contribution", "Cz"))

Arguments

cluster_object

a bioregion.clusters object or a data.frame or a list of data.frame containing multiple partitions. At least two partitions are required. If a list of data.frame is provided, they should all have the same number of rows (i.e., same items in the clustering for all partitions).

comat

a co-occurrence matrix with sites as rows and species as columns.

indices

a character specifying the contribution metric to compute. Available options are contribution.

Value

A list of data.frames if multiples indices are selected or a single data.frame with three columns if one index is selected. Each data.frame has three columns: the species, the bioregion, and the contribution statistics.

Details

The contribution metric is derived from Lenormand2019bioregion. Its formula is the following: \((n_ij - ((n_i n_j)/n))/(sqrt(((n - n_j)/(n-1)) (1-(n_j/n)) ((n_i n_j)/n)))\)

with n the number of sites, n_i the number of sites in which species i is present, n_j the number of sites belonging to the bioregion j, n_ij the number of occurrences of species i in sites belonging to the bioregion j.

Author

Pierre Denelle (pierre.denelle@gmail.com), Boris Leroy (leroy.boris@gmail.com) and Maxime Lenormand (maxime.lenormand@inrae.fr)

Examples

comat <- matrix(sample(1000, 50), 5, 10)
rownames(comat) <- paste0("Site", 1:5)
colnames(comat) <- paste0("Species", 1:10)

comat <- matrix(sample(0:1000, size = 500, replace = TRUE, prob = 1/1:1001),
                20, 25)
rownames(comat) <- paste0("Site",1:20)
colnames(comat) <- paste0("Species",1:25)

dissim <- dissimilarity(comat, metric = "Simpson")
clust1 <- nhclu_kmeans(dissim, n_clust = 3, index = "Simpson")

net <- similarity(comat, metric = "Simpson")
com <- netclu_greedy(net)

contribution(cluster_object = clust1, comat = comat,
indices = "contribution")
#>    Bioregion   Species Contribution
#> 1          3  Species1   284.576918
#> 2          3  Species2   575.060866
#> 3          3  Species3   142.939866
#> 4          3  Species4   316.926207
#> 5          3  Species5   387.651413
#> 6          3  Species6    29.890169
#> 7          3  Species7   301.104887
#> 8          3  Species8   725.161499
#> 9          3  Species9   273.157667
#> 10         3 Species10   447.522116
#> 11         3 Species11   297.695183
#> 12         3 Species12   957.225608
#> 13         3 Species13    22.085088
#> 14         3 Species14   306.209657
#> 15         3 Species15    39.520684
#> 16         3 Species16   685.280300
#> 17         3 Species17   430.368633
#> 18         3 Species18   610.480204
#> 19         3 Species19   232.490956
#> 20         3 Species20   823.755985
#> 21         3 Species21   146.723541
#> 22         3 Species22   473.961828
#> 23         3 Species23    24.596748
#> 24         3 Species24   682.672807
#> 25         3 Species25   478.765960
#> 26         1  Species1   258.797258
#> 27         1  Species2   248.043519
#> 28         1  Species3   871.910599
#> 29         1  Species4  1022.976664
#> 30         1  Species5   758.280607
#> 31         1  Species6  1321.535603
#> 32         1  Species7  1509.768523
#> 33         1  Species8   426.565646
#> 34         1  Species9   943.981980
#> 35         1 Species10  1158.314698
#> 36         1 Species11  1701.451243
#> 37         1 Species12   198.860582
#> 38         1 Species13   910.218094
#> 39         1 Species14  1238.131362
#> 40         1 Species15  2651.871882
#> 41         1 Species16  2605.726102
#> 42         1 Species17   993.709741
#> 43         1 Species18  1524.597799
#> 44         1 Species19  1728.500335
#> 45         1 Species20   855.888441
#> 46         1 Species21  1503.836813
#> 47         1 Species22  1053.466022
#> 48         1 Species23  1441.643622
#> 49         1 Species24   473.531759
#> 50         1 Species25  1234.685466
#> 51         2  Species1    61.912326
#> 52         2  Species2   761.348990
#> 53         2  Species3    97.982006
#> 54         2  Species4   418.245653
#> 55         2  Species5   311.157381
#> 56         2  Species6   727.300717
#> 57         2  Species7    13.468471
#> 58         2  Species8    -1.776432
#> 59         2  Species9   379.347190
#> 60         2 Species10    30.914678
#> 61         2 Species11   643.338009
#> 62         2 Species12   238.175608
#> 63         2 Species13    48.328700
#> 64         2 Species14  1118.373582
#> 65         2 Species15   418.407372
#> 66         2 Species16   269.079187
#> 67         2 Species17    61.620001
#> 68         2 Species18   589.193279
#> 69         2 Species19    17.655561
#> 70         2 Species20   576.941317
#> 71         2 Species21   215.146616
#> 72         2 Species22    65.551970
#> 73         2 Species23    19.799718
#> 74         2 Species24   197.802591
#> 75         2 Species25    25.331892

contribution(cluster_object = com, comat = comat,
indices = "contribution")
#>    Bioregion   Species  Contribution
#> 1          1  Species1  4257.7266049
#> 2          1  Species2 11089.0000000
#> 3          1  Species3  6892.1348567
#> 4          1  Species4 11757.3994949
#> 5          1  Species5  9565.8988077
#> 6          1  Species6 13549.0000000
#> 7          1  Species7 11954.3472427
#> 8          1  Species8  8274.0000000
#> 9          1  Species9 10621.3228931
#> 10         1 Species10 10818.2623476
#> 11         1 Species11 12957.1712333
#> 12         1 Species12 10243.1488323
#> 13         1 Species13  6184.9640258
#> 14         1 Species14 17786.8351333
#> 15         1 Species15 19878.6443200
#> 16         1 Species16 23638.7678023
#> 17         1 Species17  8993.9268522
#> 18         1 Species18 13882.3917328
#> 19         1 Species19 12817.0175158
#> 20         1 Species20 14585.3648828
#> 21         1 Species21  7989.8352229
#> 22         1 Species22 10791.4225970
#> 23         1 Species23  8905.6893731
#> 24         1 Species24  9459.1163259
#> 25         1 Species25  8159.5408504
#> 26         2  Species1    -1.0000000
#> 27         2  Species2    12.8472811
#> 28         2  Species3    94.7574548
#> 29         2  Species4     2.3925840
#> 30         2  Species5    77.9743548
#> 31         2  Species6    -0.9176629
#> 32         2  Species7    12.0043852
#> 33         2  Species8     1.3764944
#> 34         2  Species9    10.2597835
#> 35         2 Species10    45.5301455
#> 36         2 Species11  1031.6315789
#> 37         2 Species12    -0.9733285
#> 38         2 Species13    22.5715237
#> 39         2 Species14    -0.9459053
#> 40         2 Species15    25.6494588
#> 41         2 Species16     4.2631579
#> 42         2 Species17   241.2773270
#> 43         2 Species18  1029.6734337
#> 44         2 Species19    18.4932420
#> 45         2 Species20   250.5536223
#> 46         2 Species21   952.8886277
#> 47         2 Species22    -0.8885233
#> 48         2 Species23   133.7368421
#> 49         2 Species24    32.2830138
#> 50         2 Species25   813.3782055