| Title: | Predicting Invasion Probabilities from Phylogenetic Data and Species Traits |
|---|---|
| Description: | A phylogenetic modelling approach for predicting species invasion risk, out of a given pool of local species where a subset is known to be invasive elsewhere. The package uses phylogenetic signal estimation and phylogenetic linear and logistic models to estimate probabilities of being invasive based on phylogeny and any set of additional predictors. A ranking method is implemented to evaluate prioritisation strategies. A manuscript describing these methods, by Shahar Dubiner and Tamar Guy-Haim, is in preparation. |
| Authors: | Shahar Dubiner [aut, cre] (ORCID: <https://orcid.org/0000-0003-1771-0087>) |
| Maintainer: | Shahar Dubiner <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1.0 |
| Built: | 2026-07-22 09:56:27 UTC |
| Source: | https://github.com/cran/invasible |
A few fish species and their binary invasiveness status
fish_beginning_with_Efish_beginning_with_E
A data frame with 2 variables:
Character species name
0/1 indicator of invasiveness
a simulated predictor
another simulated predictor
Example data.
This function must be run before all prediction/evaluation steps.
invasion_signal(prepared)invasion_signal(prepared)
prepared |
Output of prepare_invasible() #' |
Computes Fritz & Purvis D statistic
Fits phylogenetic logistic regression
Extracts phylogenetic dependence parameter (alpha)
Returns an "invasible_signal" object for prediction functions
An object of class invasible_signal, a list containing:
,
species_list <- fish_beginning_with_E prep <- prepare_invasible(species_list) signal <- invasion_signal(prep) signal$D signal$p_randomspecies_list <- fish_beginning_with_E prep <- prepare_invasible(species_list) signal <- invasion_signal(prep) signal$D signal$p_random
Evaluates the probability of :
Detecting at least one invasion within n given species, under ranked monitoring, i.e. the highest-probability n species, vs a random selection.
Given an invasion, detecting it within the n species, under ranked monitoring, i.e. the highest-probability n species, vs a random selection.
monitor_species(pred_out, plot = FALSE, max_n = 25)monitor_species(pred_out, plot = FALSE, max_n = 25)
pred_out |
Output from |
plot |
Logical. If TRUE, returns ggplot objects. |
max_n |
Integer. Highest n value to be plotted (n=25 as default). |
a list containing:
simulation results for each value of n
1st plot of results for each value until max_n
2nd plot of results for each value until max_n
dev
species_list <- fish_beginning_with_E prep <- prepare_invasible(species_list,rho=1, predictors=c("Fake_continuous_trait")) signal <- invasion_signal(prep) pred <- predict_invasible(signal) set.seed(10) probs <- monitor_species(pred,plot=TRUE,max_n=16) probs$plot1 probs$plot2species_list <- fish_beginning_with_E prep <- prepare_invasible(species_list,rho=1, predictors=c("Fake_continuous_trait")) signal <- invasion_signal(prep) pred <- predict_invasible(signal) set.seed(10) probs <- monitor_species(pred,plot=TRUE,max_n=16) probs$plot1 probs$plot2
Fits a phylogenetic generalized linear mixed model (PGLMM) from the
output of invasion_signal()
Calculates the probability of being invasive for all species,
based on the phylogeny (and optionally species traits) given to the
original prepare_invasible() function
Computes predictive performance metrics such as ROC AUC
Plots the predicted values for observed invasive species (1) vs non-invading species (0) (optional)
predict_invasible(signal, vcv_alpha = NULL, plot = FALSE)predict_invasible(signal, vcv_alpha = NULL, plot = FALSE)
signal |
Output of |
vcv_alpha |
Numeric, optional: set a value of alpha for OU model which is
different to the value inherited from the |
plot |
Logical. If TRUE, returns diagnostic plot of observed vs predicted |
An object of class pred_output, a list containing:
Fitted PGLMM model object.
Data frame with observed and predicted values for all species.
Candidate invasives ordered by decreasing probability.
ROC object
Numeric AUC (area under the curve) value.
ggplot object (if requested; run pred_output$plot to show).
species_list <- fish_beginning_with_E prep <- prepare_invasible(species_list,rho=1, predictors=c("Fake_continuous_trait")) signal <- invasion_signal(prep) pred <- predict_invasible(signal,plot=TRUE) pred$ranked_predictions pred$auc pred$plotspecies_list <- fish_beginning_with_E prep <- prepare_invasible(species_list,rho=1, predictors=c("Fake_continuous_trait")) signal <- invasion_signal(prep) pred <- predict_invasible(signal,plot=TRUE) pred$ranked_predictions pred$auc pred$plot
Aligns species-level invasion data with a phylogeny and stores predictor information for downstream analyses.
prepare_invasible( df, tree = NULL, predictors = NULL, species_col = "Species", rho = 0.5, plot = FALSE )prepare_invasible( df, tree = NULL, predictors = NULL, species_col = "Species", rho = 0.5, plot = FALSE )
df |
Data frame containing at least a |
tree |
Optional object of class |
predictors |
Optional character vector of column names (additional predictors beyond phylogeny; if NULL, models will be based on the tree alone). |
species_col |
Name of species column (default "Species" is recommended). |
rho |
Grafen branch length scaling parameter (default 0.5). |
plot |
Logical. If TRUE, visualizes the phylogeny in |
If no phylogeny is supplied, a tree is retrieved from the Open Tree of Life using rotl; Grafen branch lengths are added if branch lengths are absent. We recommend providing a high-quality tree if available, and also recommend fully matching the species in the data and phylogeny.
An object of class "invasible_prepared".
species_list <- fish_beginning_with_E prep <- prepare_invasible(species_list,rho=1,plot=TRUE, predictors= c("Fake_categorical_trait","Fake_continuous_trait")) prep$treespecies_list <- fish_beginning_with_E prep <- prepare_invasible(species_list,rho=1,plot=TRUE, predictors= c("Fake_categorical_trait","Fake_continuous_trait")) prep$tree