Skip to contents

png_ants (in tidydiversity) records ground-foraging ants at nutrient baits at elevations from 200 to 2200 m on Mt Wilhelm, Papua New Guinea, in the dry and the wet season (Moses et al. 2023, doi:10.5281/zenodo.8191946). tidydiversity estimates diversity; tidymapr maps it.

Study sites

geo_example_sites() returns the published bait GPS of the survey (png_ants_sites; Mottl, Moses and Klimes 2023, doi:10.5281/zenodo.8191946), averaged to one point per elevation band.

sites <- geo_example_sites("wilhelm") |>
  filter(elevation <= 2200)
plot_sites(sites, lon, lat, colour = elevation_band, label = site, basemap = "coast") +
  labs(title = "Ant sampling sites on Mt Wilhelm")

Study sites along Mt Wilhelm coloured by elevation band

Diversity on a map

est <- div_estimate(png_ants, q = 0, nboot = 0, .by = season) |>
  left_join(sites[c("site", "lon", "lat")], by = "site")
plot_geo(filter(est, season == "wet"), estimate, lon, lat, label = site, basemap = "coast") +
  labs(title = "Observed richness, wet season", colour = "Species")
#> Ignoring unknown labels:
#> • colour : "Species"

Observed ant richness on a map, one panel per season

Distance decay

geo_decay() computes pairwise dissimilarity with tidydiversity::beta_pair() and joins geographic or elevational distance.

com <- left_join(png_ants, sites[c("site", "lon", "lat")], by = "site")
decay <- geo_decay(com, lon, lat, .by = season, method = "haversine")
autoplot(decay)

Ant dissimilarity against geographic distance by season

beta_decay_model(decay)
#> # A tibble: 2 × 10
#>   season model     component n_pairs     a       b half_distance pseudo_r2   aic
#>   <chr>  <chr>     <chr>       <int> <dbl>   <dbl>         <dbl>     <dbl> <dbl>
#> 1 dry    exponent… total          10 0.267 1.02e-4         6815.     0.150 -9.29
#> 2 wet    exponent… total          10 0.383 1.41e-4         4910.     0.334 -9.79
#> # ℹ 1 more variable: p.value <dbl>

Spatial autocorrelation

wet <- filter(est, season == "wet")
geo_moran(wet, estimate, lon, lat, nperm = 199, seed = 1)
#> # A tibble: 1 × 7
#>   statistic expectation variance p.value     n nperm method                     
#>       <dbl>       <dbl>    <dbl>   <dbl> <int> <dbl> <chr>                      
#> 1    -0.236       -0.25   0.0114    0.95     5   199 Moran's I (inverse-distanc…

Save the figure

geo_save() writes maps at journal sizes:

p <- plot_sites(sites, lon, lat, colour = elevation_band, label = site)
geo_save(p, "fig1-sites.pdf", width = 170, height = 120, units = "mm")