Search code examples
rinext

How do I generate a sample completeness~diversity order plot in iNext?


I am trying to create a plot in the style of the sample completeness~diversity order plot shown below, but referencing a different dataset.

Sample Completeness ~ Diversity Order (Fig. 3a, from Chao et al. 2020

The plot shown above is Fig. 3a in Chao et al. 2020.

I want to create a plot in this style for the ciliate dataset included in the iNEXT package, using principally functions iNEXT::iNEXT() and iNEXT::ggiNEXT(). I see that sample completeness values are contained in the output of function iNEXT() as variable SC in multiple places (shown below).

> library(ggplot2)
> library(iNEXT)
> data("ciliates")
>
> #define output of function iNEXT as object c
> c <- iNEXT::iNEXT(ciliates, datatype = "incidence_raw", q=c(0,1,2), se=TRUE, nboot = 10) 
>
> head(c$iNextEst$size_based)
  Assemblage t      Method Order.q        qD    qD.LCL    qD.UCL        SC    SC.LCL    SC.UCL
1  EtoshaPan 1 Rarefaction       0  27.15789  25.46898  28.84681 0.1901378 0.1602758 0.2199998
2  EtoshaPan 2 Rarefaction       0  49.15205  46.46171  51.84239 0.3154101 0.2763704 0.3544499
3  EtoshaPan 3 Rarefaction       0  67.74407  64.36418  71.12395 0.4040033 0.3625663 0.4454402
4  EtoshaPan 4 Rarefaction       0  83.93008  80.01195  87.84822 0.4704869 0.4293215 0.5116523
5  EtoshaPan 5 Rarefaction       0  98.31054  93.93120 102.68989 0.5227274 0.4830091 0.5624458
6  EtoshaPan 6 Rarefaction       0 111.27226 106.47865 116.06587 0.5652248 0.5274311 0.6030185
>
> head(c$iNextEst$coverage_based)
  Assemblage        SC t      Method Order.q        qD    qD.LCL    qD.UCL
1  EtoshaPan 0.1901402 1 Rarefaction       0  27.15824  25.46933  28.84715
2  EtoshaPan 0.3154100 2 Rarefaction       0  49.15201  43.79056  54.51347
3  EtoshaPan 0.4040045 3 Rarefaction       0  67.74432  61.04684  74.44180
4  EtoshaPan 0.4704874 4 Rarefaction       0  83.93019  75.75317  92.10722
5  EtoshaPan 0.5227259 5 Rarefaction       0  98.31009  88.86377 107.75640
6  EtoshaPan 0.5652251 6 Rarefaction       0 111.27235 100.79007 121.75464
>
> c$DataInfo
           Assemblage  T   U S.obs     SC  Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 Q10
1           EtoshaPan 19 516   216 0.8017 107 44 26 14  6  5  4  3  2   2
2  CentralNamibDesert 17 379   130 0.8425  63 28 13  4  3  7  1  2  1   0
3 SouthernNamibDesert 15 358   150 0.7816  82 28 14  8  6  1  1  2  2   1

However, nowhere in object c do I see unique combinations of assemblage (EtoshaPan, CentralNamibDesert, SouthernNamibDesert), sample completeness value, and diversity order ("Order q" in plot above). Can a sample completeness~diversity order plot be created simply by setting the appropriate arguments in function ggiNEXT? If not, what steps must I take in order to create it?

Edit: I'm not the only one asking this question: link

Reference: Chao, Anne, et al. "Quantifying sample completeness and comparing diversities among assemblages." Ecological Research 35.2 (2020): 292-314.

Link to reference: link


Solution

  • This is done using the iNEXT.4steps package, downloadable from GitHub.

    > #install_github('AnneChao/iNEXT.4steps') #not currently on CRAN
    > library(iNEXT)
    > library(iNEXT)
    > library(iNEXT.4steps)
    > library(ggplot2)
    > data("ciliates")   #included in package iNEXT
    > 
    > i <- iNEXT4steps(ciliates, 
    +             diversity = "TD", 
    +             q = seq(0, 2, 0.2),
    +             datatype = "incidence_raw",
    +             nboot = 99)
    > i$figure   #automatically generate plots shown below
    > i
    $summary
    $summary$`STEP1. Sample completeness profiles`
               Assemblage q = 0 q = 1 q = 2
    1  CentralNamibDesert  0.66  0.84  0.98
    2           EtoshaPan  0.64  0.80  0.95
    3 SouthernNamibDesert  0.57  0.78  0.96
    
    $summary$`STEP2. Asymptotic analysis`
               Assemblage         Diversity Observed Estimator  s.e.    LCL    UCL
    1  CentralNamibDesert  Species richness   130.00    196.71 21.27 155.02 238.39
    2  CentralNamibDesert Shannon diversity    81.81    106.48  6.06  94.60 118.36
    3  CentralNamibDesert Simpson diversity    54.22     59.56  3.31  53.07  66.05
    4           EtoshaPan  Species richness   216.00    339.25 25.67 288.94 389.57
    5           EtoshaPan Shannon diversity   158.37    222.94 11.84 199.74 246.13
    6           EtoshaPan Simpson diversity   116.68    142.83  8.78 125.62 160.04
    7 SouthernNamibDesert  Species richness   150.00    262.07 26.45 210.23 313.90
    8 SouthernNamibDesert Shannon diversity   103.70    149.91  8.09 134.05 165.77
    9 SouthernNamibDesert Simpson diversity    72.33     84.60  4.48  75.82  93.37
    
    $summary$`STEP3. Non-asymptotic coverage-based rarefaction and extrapolation analysis`
             Cmax = 0.893  q = 0  q = 1  q = 2
    1  CentralNamibDesert 151.42  88.95  55.70
    2           EtoshaPan 272.81 185.79 126.43
    3 SouthernNamibDesert 207.21 127.10  77.98
    
    $summary$`STEP4. Evenness among species abundances`
                        Pielou J' q = 1 q = 2
    CentralNamibDesert       0.89  0.58  0.36
    EtoshaPan                0.93  0.68  0.46
    SouthernNamibDesert      0.91  0.61  0.37
    
    
    $figure
    $figure[[1]]
    
    $figure[[2]]
    
    $figure[[3]]
    
    $figure[[4]]
    
    $figure[[5]]
    
    $figure[[6]]
    

    ...