Invasion fitness synthesis
Install and load invasimapr and other core packages
Section titled “Install and load invasimapr and other core packages”Install from GitHub (recommended for development) or CRAN (if available) as before.
Synthesising invasion-fitness insights
Section titled “Synthesising invasion-fitness insights”This section condenses the high-dimensional output into system-level distributions, top/bottom ranks, trait correlates, and key-invader maps. The goal is a compact dashboard for reporting and decision-support.
:hourglass_flowing_sand: Step-by-step in this section:
- Summarise the distribution of
, - Identify top/bottom invaders and sites by mean fitness,
- Link invader traits to fitness via correlations/means, and
- Visualise spatial patterns for the most and least concerning invaders.
Distribution of invasion fitness values
Section titled “Distribution of invasion fitness values”The histogram of all
:bulb: Interpretation: Right-skew suggests many marginal combinations but a meaningful tail of high-opportunity cases; left-skew suggests strong overall resistance.
:warning: Checks/tips: Inspect tails; compare across specification options (A-E) to test robustness.
ggplot2::ggplot(fitness_df, ggplot2::aes(x = lambda_mean, fill = ggplot2::after_stat(x))) + ggplot2::geom_histogram(bins = 40, color = "grey30") + ggplot2::scale_fill_viridis_c(option = "magma", guide = "none") + ggplot2::labs(title = "Distribution of invasion fitness values (all invader × site)", x = expression("Invasion fitness " * lambda[i*s]), y = "Frequency") + ggplot2::theme_minimal(base_size = 12)
:chart_with_upwards_trend: Figure 29: The histogram shows the distribution of invasion fitness values (
ᵢₛ) across all invader—site combinations. Most values fall between −3 and 0, with a strong concentration around −2, indicating that the majority of potential invasions are constrained by either abiotic conditions or biotic resistance. Only a small fraction of cases approach or exceed > 0 (to the right of the origin), highlighting that successful establishment opportunities are relatively rare. The long left tail (< −4) represents invader—site pairings where conditions are strongly unfavorable.
:bar_chart: Overall, the figure emphasizes that the invasion landscape is dominated by resistance rather than opportunity, but with occasional site—invader matches that may permit establishment. This pattern is consistent with theoretical expectations of community assembly, where most introductions fail but a minority may find niches that allow them to persist.
Top and bottom invaders and sites
Section titled “Top and bottom invaders and sites”Ranking by mean
:bulb: Interpretation: Top invaders are candidates for vigilant monitoring; top sites are hotspots for surveillance or preventative management.
:warning: Checks/tips: Report uncertainty (e.g., bootstrapped means) when used for policy.
#> ==== Top 3 Invaders by Mean Invasion Fitness ====#> 2. inv7: -0.435#> 3. inv5: -0.864#>#> ==== Bottom 3 Invaders by Mean Invasion Fitness ====#> 1. inv1: -1.078#> 2. inv4: -1.216#> 3. inv8: -1.387#>#> ==== Top 3 Sites by Mean Invasion Fitness ====#> 1. 401: 1.485#> 2. 884: 1.396#> 3. 695: 1.136#>#> ==== Bottom 3 Sites by Mean Invasion Fitness ====#> 1. 417: -3.474#> 2. 428: -3.523#> 3. 558: -4.419Functional correlates of invasion success
Section titled “Functional correlates of invasion success”We relate invader traits to mean
:bulb: Interpretation: Strong positive (or negative) correlations for continuous traits, and high/low trait-level means for categorical traits, suggest mechanistic drivers worth testing experimentally.
:warning: Checks/tips: Standardise continuous traits; ensure categorical levels are well populated; treat results as exploratory unless validated.
#> ==== Top 3 Continuous Traits by Correlation with Mean Invasion Fitness ====#> trait_cont2: 0.551#> trait_cont1: 0.113#>#> ==== Bottom 3 Continuous Traits by Correlation with Mean Invasion Fitness ====#> trait_cont8: -0.427#> trait_cont4: -0.435#> trait_cont5: -0.449#> ==== Categorical Traits: Top Value per Trait by Mean Invasion Fitness ====#> trait_cat11: grassland (-0.82)#> trait_cat12: nocturnal (-0.90)#> trait_cat13: bivoltine (-0.88)#> trait_cat14: nectarivore (-0.71)#> trait_cat15: migratory (-0.92)Faceted maps for key invaders
Section titled “Faceted maps for key invaders”We visualise spatial patterns for the top and bottom invaders identified above to link traits, environments, and community context.
:bulb: Interpretation: Hotspots for top invaders mark priority regions; uniformly low values for bottom invaders highlight robust sites or mismatched niches.
:warning: Checks/tips: Use a centred colour scale; show boundaries for orientation; keep facet order consistent with ranks.
:hourglass_flowing_sand: Step-by-step in this section: 1. select invaders ➔ 2. compute z-MAD standardized fitness ➔ 3. build facet labels ordered by mean
Select key invaders (top & bottom)
Section titled “Select key invaders (top & bottom)”# Objects assumed: df_inv (site, invader, x, y, lambda), rsa (sf boundary)# Also assumed: top3_inv, bottom3_inv with columns 'invader'
# Select key invaderskey_invaders = c(top3_inv$invader, bottom3_inv$invader) |> unique()
lambda_key = df_inv |> dplyr::filter(invader %in% key_invaders) |> dplyr::mutate(invader = factor(invader, levels = key_invaders))dim(lambda_key)#> [1] 2490 11Compute z-MAD standardization of ( )
Section titled “Compute z-MAD standardization of ()”# z-MAD for lambda (avoid divide-by-zero)med = median(lambda_key$lambda, na.rm = TRUE)mad_ = mad(lambda_key$lambda, na.rm = TRUE)if (!is.finite(mad_) || mad_ == 0) mad_ = sd(lambda_key$lambda, na.rm = TRUE)
lambda_key = lambda_key |> dplyr::mutate(lambda_zmad = (lambda - med) / mad_)dim(lambda_key)#> [1] 2490 12Order facets by mean ( ) and build labels
Section titled “Order facets by mean () and build labels”# Order facets by mean lambda and create labelslab_means = lambda_key |> dplyr::group_by(.data$invader) |> dplyr::summarise(mu = mean(.data$lambda, na.rm = TRUE), .groups = "drop") |> dplyr::arrange(dplyr::desc(.data$mu)) |> dplyr::mutate(label = sprintf("%s (mean \u03BB = %.2f)", .data$invader, .data$mu))
lab_levels = lab_means$label
lambda_key2 <- lambda_key |> dplyr::left_join(lab_means |> dplyr::select(invader, label), by = "invader", suffix = c(".x", ".y")) |> dplyr::mutate(label = dplyr::coalesce(label.y, label.x)) |> # prefer joined label dplyr::select(-label.x, -label.y) |> dplyr::mutate(label = factor(label, levels = lab_levels))names(lambda_key2)#> [1] "site" "invader" "val" "lambda"#> [5] "mode" "x" "y" "val_f"#> [9] "site_cluster" "invader_cluster" "lambda_zmad" "label"Ordered faceted maps (centered palette)
Section titled “Ordered faceted maps (centered palette)”# Load the national boundarylibrary(ggplot2)rsa = sf::st_read(system.file("extdata", "rsa.shp", package = "invasimapr"))#> Reading layer `rsa' from data source#> `/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library/invasimapr/extdata/rsa.shp'#> using driver `ESRI Shapefile'#> Simple feature collection with 11 features and 8 fields#> Geometry type: MULTIPOLYGON#> Dimension: XY#> Bounding box: xmin: 16.45189 ymin: -34.83417 xmax: 32.94498 ymax: -22.12503#> Geodetic CRS: WGS 84
# Diverging palette + clearer midpointggplot2::ggplot(lambda_key2, ggplot2::aes(x, y, fill = lambda_zmad)) + ggplot2::geom_tile() + ggplot2::geom_sf(data = rsa, inherit.aes = FALSE, fill = NA, color = "black", linewidth = 0.5) + ggplot2::facet_wrap(~ label, ncol = 3) + scico::scale_fill_scico( palette = "vik", limits = c(-4, 4), oob = scales::squish, name = "Lambda (z-MAD)", midpoint = 0 ) + ggplot2::labs(title = "Spatial invasion fitness (facets ordered by mean \u03BB)", x = "Longitude", y = "Latitude") + theme_minimal(12) + theme(panel.grid = ggplot2::element_blank())
:chart_with_upwards_trend: Figure 30: This figure compares the spatial distribution of invasion fitness (
, expressed as z-MAD) for the three highest- and three lowest-ranked invaders, ordered by their meanvalues. Across invaders, spatial variation is structured by a common underlying pattern: inland and northeastern regions generally exhibit higher-than-expected invasion fitness (warm tones), whereas coastal and southwestern areas are consistently characterized by lower fitness (cool tones). The top-ranked invaders (inv5, inv9, inv10) show broader and more contiguous zones of positive , indicating relatively favourable conditions across multiple regions. In contrast, the bottom-ranked invaders (inv8, inv2, inv1) display more extensive and spatially consistent negative values, with only small and fragmented pockets of opportunity.
Alternative gradient (viridis/magma)
Section titled “Alternative gradient (viridis/magma)”ggplot2::ggplot(lambda_key, ggplot2::aes(x = x, y = y, fill = lambda_zmad)) + ggplot2::geom_tile() + ggplot2::geom_sf(data = rsa, inherit.aes = FALSE, fill = NA, color = "black", linewidth = 0.5) + ggplot2::facet_wrap(~ invader, ncol = 3) + ggplot2::scale_fill_gradientn( colours = viridisLite::magma(256, direction = -1), rescaler = function(x, ...) scales::rescale_mid(x, mid = 0), limits = c(-4, 4), oob = scales::squish, name = "Lambda (z-MAD)" ) + labs(title = "Spatial invasion fitness for top- and bottom-ranked invaders", x = "Longitude", y = "Latitude") + theme_minimal(12) + theme(panel.grid = ggplot2::element_blank())
:chart_with_upwards_trend: Figure 31: Same maps with an alternative diverging look using
magmacentered at 0.
Invader advantage relative to site mean
Section titled “Invader advantage relative to site mean”# Emphasize invader-specific advantage relative to the same sitessite_means = df_inv |> dplyr::group_by(site) |> dplyr::summarise(site_mean = mean(lambda, na.rm = TRUE), .groups = "drop")
lambda_rel = lambda_key |> dplyr::left_join(site_means, by = "site") |> dplyr::mutate(delta_lambda = lambda - site_mean)
ggplot2::ggplot(lambda_rel, aes(x, y, fill = delta_lambda)) + ggplot2::geom_tile() + ggplot2::geom_sf(data = rsa, inherit.aes = FALSE, fill = NA, color = "black", linewidth = 0.5) + ggplot2::facet_wrap(~ invader, ncol = 3) + ggplot2::scale_fill_gradient2( name = expression(Delta * lambda), low = "#3b4cc0", mid = "white", high = "#b40426", midpoint = 0 ) + labs(title = "Invader advantage relative to site mean (\u0394\u03BB)", x = "Longitude", y = "Latitude") + theme_minimal(12) + theme(panel.grid = ggplot2::element_blank())
:chart_with_upwards_trend: Figure 32: Deviations from each site’s mean (
) (positive = invader outperforms the typical invader at that site).
:bar_chart: Together, these contrasts highlight that invader performance is shaped by both shared environmental templates and invader-specific deviations, with higher-ranked invaders better aligned with spatial hotspots of opportunity.
:sparkles: Overall importance: This compact set---distribution, ranks, trait links, and maps---forms a practical reporting dashboard for stakeholders.
:bulb: Summary. You now have system-level summaries, interpretable ranks, functional signals, and spatial views---ready for communication and action.
:warning: Checks/tips:
- Use a centered color scale so zero is visually neutral.
- Keep facet order consistent (use the
labelfactor). - If thresholds should be invader-specific, compute per-invader
thr_iand draw contours per group (loop orgroup_split()), sincebreakscan’t vary within a singlegeom_contour()call. - For publication, export figures with fixed dimensions and fonts (e.g.,
ggsave(..., width=7, height=6, dpi=300)).
Session information
Section titled “Session information”sessionInfo()#> R version 4.5.3 (2026-03-11)#> Platform: aarch64-apple-darwin20#> Running under: macOS Tahoe 26.6.2#>#> Matrix products: default#> BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib#> LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.1#>#> locale:#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8#>#> time zone: Europe/Brussels#> tzcode source: internal#>#> attached base packages:#> [1] stats graphics grDevices utils datasets methods base#>#> other attached packages:#> [1] frictionless_2.0.1 virtualspecies_1.6 geodata_0.6-9#> [4] terra_1.9-50 ggExtra_0.11.0 tidyterra_0.7.2#> [7] dplyr_1.2.1 sf_1.1-3 gcube_1.4.4#> [10] ggplot2_4.0.3 invasimapr_0.2.1 here_1.0.2#> [13] purrr_1.2.2 yaml_2.3.12#>#> loaded via a namespace (and not attached):#> [1] fs_2.1.0 matrixStats_1.5.0 lubridate_1.9.5#> [4] httr_1.4.9 RColorBrewer_1.1-3 insight_1.5.1#> [7] numDeriv_2016.8-1.1 tools_4.5.3 backports_1.5.1#> [10] utf8_1.2.6 R6_2.6.1 vegan_2.7-6#> [13] mgcv_1.9-4 permute_0.10-0 withr_3.0.3#> [16] clValid_0.7 sp_2.2-1 gridExtra_2.3.1#> [19] cli_3.6.6 performance_0.17.0 factoextra_2.2.0#> [22] sandwich_3.1-1 labeling_0.4.3 entropy_1.3.2#> [25] mvtnorm_1.4-2 S7_0.2.2 readr_2.2.0#> [28] proxy_0.4-29 pbapply_1.7-5 R.utils_2.13.0#> [31] stringdist_0.9.15 dichromat_2.0-0.1 scico_1.5.0#> [34] parallelly_1.50.0 maps_3.4.4 rstudioapi_0.17.1#> [37] FNN_1.1.4.1 shape_1.4.6.1 generics_0.1.4#> [40] b3doc_0.3.0.9000 car_3.1-5 dendextend_1.19.1#> [43] scam_1.2-23 Matrix_1.7-5 abind_1.4-8#> [46] R.methodsS3_1.8.2 lifecycle_1.0.5 dissmapr_0.2.2#> [49] multcomp_1.4-30 carData_3.0-6 recipes_1.4.0#> [52] grid_4.5.3 promises_1.5.0 miniUI_0.1.2#> [55] lattice_0.22-9 chromote_0.5.1 magick_2.9.1#> [58] pillar_1.11.1 knitr_1.52 boot_1.3-32#> [61] spacetime_1.3-3 estimability_2.0.0 pak_0.10.0#> [64] future.apply_1.21.0 codetools_0.2-20 wk_0.9.5#> [67] glue_1.8.1 data.table_1.18.6.1 vctrs_0.7.3#> [70] spam_2.11-4 Rdpack_2.6.6 gtable_0.3.6#> [73] assertthat_0.2.1 gower_1.0.2 xfun_0.62#> [76] rbibutils_2.4.1 mime_0.13 prodlim_2026.03.11#> [79] rnaturalearth_1.0.1 coda_0.19-4.1 reformulas_0.4.4#> [82] survival_3.8-6 timeDate_4052.112 pheatmap_1.0.13#> [85] iterators_1.0.14 hardhat_1.4.3 units_1.0-1#> [88] lava_1.10 fields_18.0 TH.data_1.1-3#> [91] ipred_0.9-16 nlme_3.1-169 xts_0.14.2#> [94] zetadiv_1.3.0 rprojroot_2.1.1 TMB_1.9.17#> [97] KernSmooth_2.23-26 otel_0.3.0 rpart_4.1.24#> [100] DBI_1.3.0 raster_3.6-32 nnet_7.3-20#> [103] ade4_1.7-24 mnormt_2.1.2 tidyselect_1.2.1#> [106] processx_3.9.0 emmeans_2.0.4 compiler_4.5.3#> [109] curl_8.1.0 glmnet_5.0 rvest_1.0.4#> [112] gstat_2.1-6 xml2_1.6.0 scales_1.4.0#> [115] classInt_0.4-11 fuzzyjoin_0.1.8 callr_3.8.0#> [118] rappdirs_0.3.4 stringr_1.6.0 digest_0.6.39#> [121] minqa_1.2.8 rmarkdown_2.32 htmltools_0.5.9#> [124] pkgconfig_2.0.3 lme4_2.1-0 fastmap_1.2.0#> [127] rlang_1.3.0 shiny_1.11.1 farver_2.1.2#> [130] zoo_1.9-1 jsonlite_2.0.0 mclust_6.1.3#> [133] ModelMetrics_1.2.2.2 R.oo_1.27.1 magrittr_2.0.5#> [136] Formula_1.2-6 s2_1.1.13 dotCall64_1.2#> [139] NbClust_3.0.1 patchwork_1.3.2 geosphere_1.6-8#> [142] Rcpp_1.1.2 viridis_0.6.5 stringi_1.8.9#> [145] pROC_1.19.1 MASS_7.3-66 plyr_1.8.9#> [148] parallel_4.5.3 listenv_1.1.0 ggrepel_0.9.8#> [151] forcats_1.0.1 splines_4.5.3 hms_1.1.4#> [154] ps_1.9.3 ggpubr_1.0.0 ggsignif_0.6.4#> [157] reshape2_1.4.5 stats4_4.5.3 evaluate_1.0.5#> [160] nloptr_2.2.1 tzdb_0.5.0 selectr_0.5-1#> [163] foreach_1.5.2 httpuv_1.6.17 tidyr_1.3.2#> [166] future_1.82.0 broom_1.0.13 xtable_1.8-8#> [169] ClustGeo_2.1 e1071_1.7-17 rstatix_1.1.0#> [172] later_1.4.8 viridisLite_0.4.3 class_7.3-23#> [175] intervals_0.15.5 tibble_3.3.1 websocket_1.4.4#> [178] glmmTMB_1.1.14 cluster_2.1.8.2 corrplot_0.95#> [181] timechange_0.4.0 globals_0.20.0 caret_7.0-1