| Title: | Niche Climate Exposure |
|---|---|
| Description: | Assesses niche climate exposure by interpreting projected climate change relative to the climate conditions a species currently occupies. Using occurrence records, range data, continuous species distribution model suitability maps, current environmental rasters and future projections, the package separates Climatic Displacement, Niche Distance Shift, Climatic Reconfiguration and Niche Boundary Exceedance. |
| Authors: | Bohao He [aut, cre] |
| Maintainer: | Bohao He <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.2.0 |
| Built: | 2026-06-02 10:22:11 UTC |
| Source: | https://github.com/bohao0813/climniche |
Niche Boundary Exceedance
boundary_exceedance( psi_future, boundary_value, scale = c("radial", "potential") )boundary_exceedance( psi_future, boundary_value, scale = c("radial", "potential") )
psi_future |
Future niche potential. |
boundary_value |
Empirical boundary of the current realised niche in potential units. |
scale |
|
Numeric vector.
Build data for a niche climate exposure diagram
climniche_diagram_data( x, scope = c("current", "all"), max_arrows = 350L, seed = 1L )climniche_diagram_data( x, scope = c("current", "all"), max_arrows = 350L, seed = 1L )
x |
A fitted climniche object. |
scope |
|
max_arrows |
Maximum number of current to future arrows to keep. |
seed |
Random seed used when subsampling arrows. |
A list of data frames used by plot_climniche_diagram().
Build a climniche report
climniche_report( x, species = NULL, scope = c("current", "all"), top_variables = 5 )climniche_report( x, species = NULL, scope = c("current", "all"), top_variables = 5 )
x |
A fitted |
species |
Optional species name used in printed reports. |
scope |
|
top_variables |
Number of variable contributions to show. |
An object of class climniche_report.
Build data for the climniche summary figure
climniche_showcase_data( x, scope = c("current", "all"), max_points = 6000L, seed = 1L, plane_bins = 45L, boundary_probs = seq(0.5, 0.99, 0.01), top_variables = 6L )climniche_showcase_data( x, scope = c("current", "all"), max_points = 6000L, seed = 1L, plane_bins = 45L, boundary_probs = seq(0.5, 0.99, 0.01), top_variables = 6L )
x |
A fitted climniche object. |
scope |
|
max_points |
Maximum number of cells to keep for the exposure plane. |
seed |
Random seed used when subsampling cells. |
plane_bins |
Number of fixed bins used to summarize the exposure plane. |
boundary_probs |
Boundary quantiles used for the sensitivity curve. |
top_variables |
Number of variables to show. |
A list of data frames used by plot_climniche_showcase().
Summarise climniche results
climniche_summary(x, scope = c("current", "all"))climniche_summary(x, scope = c("current", "all"))
x |
A fitted |
scope |
|
A one-row data frame with metric summaries and the effective classification settings.
Extract a tidy climniche table
climniche_table(x, scope = c("current", "all"))climniche_table(x, scope = c("current", "all"))
x |
A fitted |
scope |
|
A data frame with one row per evaluated cell, including
occupied_weight, the four primary metrics and the old metric aliases.
Fit niche climate exposure
fit_climniche( current, future, occupied = NULL, occupied_threshold = NULL, cnfa = NULL, center = NULL, sensitivity = NULL, A = NULL, metric = c("diag", "factor"), boundary = 0.95, scale = TRUE, global_mean = NULL, global_sd = NULL, tolerance = NULL, tolerance_quantile = 0.1, stable_climate_change = NULL, stable_quantile = 0.25, stable_reconfiguration = NULL, stable_reconfiguration_quantile = 0.25, boundary_exceedance_tolerance = 0, conflict_ratio = 0.25 )fit_climniche( current, future, occupied = NULL, occupied_threshold = NULL, cnfa = NULL, center = NULL, sensitivity = NULL, A = NULL, metric = c("diag", "factor"), boundary = 0.95, scale = TRUE, global_mean = NULL, global_sd = NULL, tolerance = NULL, tolerance_quantile = 0.1, stable_climate_change = NULL, stable_quantile = 0.25, stable_reconfiguration = NULL, stable_reconfiguration_quantile = 0.25, boundary_exceedance_tolerance = 0, conflict_ratio = 0.25 )
current |
Numeric matrix or data frame of current environmental values. |
future |
Numeric matrix or data frame of future environmental values. |
occupied |
NULL, logical vector, row indices, or a numeric vector with one value per row identifying current occurrence, range, or continuous SDM suitability weights. |
occupied_threshold |
Threshold used when |
cnfa |
Optional CENFA model object. |
center |
Optional realised niche centre in standardised climate space. |
sensitivity |
Optional environmental sensitivity weights. |
A |
Optional niche metric matrix. |
metric |
Metric construction when |
boundary |
User-set quantile defining the empirical realised niche
boundary. The default is |
scale |
Logical. If TRUE, standardise current and future values. |
global_mean |
Optional means used for standardisation. |
global_sd |
Optional standard deviations used for standardisation. |
tolerance |
Optional user-set Niche Distance Shift tolerance. If |
tolerance_quantile |
Quantile of absolute Niche Distance Shift used
when |
stable_climate_change |
Optional user-set threshold for limited
Climatic Displacement. If |
stable_quantile |
Quantile of Climatic Displacement used when
|
stable_reconfiguration |
Optional user-set threshold for low Climatic
Reconfiguration. If |
stable_reconfiguration_quantile |
Quantile of Climatic Reconfiguration
used when |
boundary_exceedance_tolerance |
User-set tolerance for deciding whether future climate exceeds the empirical niche boundary. |
conflict_ratio |
Minimum minority sign contribution share used to mark mixed variable responses. Set to NULL to disable this flag. |
The fitted object stores four primary metrics as snake_case fields:
Climatic Displacement (climate_change_amount), Niche Distance Shift
(niche_distance_change), Climatic Reconfiguration
(climate_reconfiguration) and Niche Boundary Exceedance
(niche_boundary_exceedance).
Let current and future climatic conditions at cell be and
. Let be the centre of the current realised climatic niche,
and let be the sensitivity weighted distance under weighting
matrix . The four metrics are
where is the -th weighted quantile of current reference cell
distances from the realised niche centre. Positive Niche Boundary Exceedance
is therefore an excess distance beyond this empirical radial boundary.
All classification-related thresholds are user-settable. If a direct
threshold argument is NULL, climniche calculates the effective threshold
from the corresponding quantile argument. The fitted object stores the
effective values actually used in classification_settings.
An object of class climniche_fit.
boundary: quantile used to define the empirical realised niche boundary.
tolerance: direct Niche Distance Shift tolerance; otherwise
tolerance_quantile.
stable_climate_change: direct Climatic Displacement threshold for the
limited-change class; otherwise stable_quantile.
stable_reconfiguration: direct Climatic Reconfiguration threshold for
the limited-change class; otherwise stable_reconfiguration_quantile.
boundary_exceedance_tolerance: direct tolerance for Niche Boundary
Exceedance.
conflict_ratio: minority-sign contribution share used by the mixed
variable-response diagnostic.
Fit climniche to raster data
fit_climniche_raster( current, future, occupied = NULL, occupied_threshold = NULL, domain = NULL, domain_threshold = 0, ... )fit_climniche_raster( current, future, occupied = NULL, occupied_threshold = NULL, domain = NULL, domain_threshold = 0, ... )
current |
Raster* object of current environmental layers. |
future |
Raster* object of future environmental layers. |
occupied |
Optional RasterLayer with binary or continuous occurrence, range, or SDM suitability values. |
occupied_threshold |
Values at or below this threshold receive zero reference weight. Values above it keep their original value. |
domain |
Optional RasterLayer limiting cells where exposure is analysed. |
domain_threshold |
Values greater than this threshold define the domain. |
... |
Additional arguments passed to |
An object of class climniche_fit with raster outputs.
Fit climniche to terra raster data
fit_climniche_terra( current, future, occupied = NULL, occupied_threshold = NULL, domain = NULL, domain_threshold = 0, ... )fit_climniche_terra( current, future, occupied = NULL, occupied_threshold = NULL, domain = NULL, domain_threshold = 0, ... )
current |
terra SpatRaster of current environmental layers. |
future |
terra SpatRaster of future environmental layers. |
occupied |
Optional one layer SpatRaster with binary or continuous occurrence, range, or SDM suitability values. |
occupied_threshold |
Values at or below this threshold receive zero reference weight. Values above it keep their original value. |
domain |
Optional one layer SpatRaster limiting cells where exposure is analysed. |
domain_threshold |
Values greater than this threshold define the domain. |
... |
Additional arguments passed to |
An object of class climniche_fit with raster outputs.
Build a sensitivity weighted niche metric
niche_metric(sensitivity = NULL, cnfa = NULL, type = c("diag", "factor"))niche_metric(sensitivity = NULL, cnfa = NULL, type = c("diag", "factor"))
sensitivity |
Numeric vector of climate variable sensitivity weights. |
cnfa |
Optional CENFA |
type |
Metric type. |
A positive semi-definite matrix.
Niche percentile shift
niche_percentile(psi_current, psi_future, occupied)niche_percentile(psi_current, psi_future, occupied)
psi_current |
Current niche potential for all cells. |
psi_future |
Future niche potential for all cells. |
occupied |
Current reference weights or indices used to define the reference CDF. |
Data frame with current, future, and delta percentiles.
Niche potential
niche_potential(x, center, A)niche_potential(x, center, A)
x |
Standardised climate matrix. |
center |
Realised niche centre. |
A |
Niche metric matrix. |
Numeric vector of quadratic niche displacement values.
Niche radius
niche_radius(psi)niche_radius(psi)
psi |
Numeric niche-potential values. |
Numeric vector in sensitivity weighted climate distance units.
Plot climniche class proportions
plot_climniche_class_summary(x, scope = c("current", "all"), title = NULL)plot_climniche_class_summary(x, scope = c("current", "all"), title = NULL)
x |
A fitted climniche object. |
scope |
|
title |
Optional plot title. |
A ggplot object.
Plot climniche classes
plot_climniche_classes( x, occupied = NULL, occupied_only = FALSE, occupied_threshold = NULL, title = NULL )plot_climniche_classes( x, occupied = NULL, occupied_only = FALSE, occupied_threshold = NULL, title = NULL )
x |
A fitted climniche object with raster outputs. |
occupied |
Optional current reference RasterLayer to overlay. |
occupied_only |
If TRUE, mask the plotted classes to current occurrence cells. |
occupied_threshold |
Threshold used when |
title |
Optional plot title. Use |
A ggplot object.
Plot a niche climate exposure diagram
plot_climniche_diagram( x, scope = c("current", "all"), type = c("summary", "sample"), summary_layout = c("metrics", "ordination"), max_arrows = 350L, seed = 1L, show_reference = FALSE, show_hulls = TRUE, boundary_shape = c("hull", "circle", "none"), show_boundary_label = TRUE, show_points = NULL, show_startpoints = FALSE, show_endpoints = FALSE, show_center = TRUE, show_variables = FALSE, variable_labels = NULL, title = NULL )plot_climniche_diagram( x, scope = c("current", "all"), type = c("summary", "sample"), summary_layout = c("metrics", "ordination"), max_arrows = 350L, seed = 1L, show_reference = FALSE, show_hulls = TRUE, boundary_shape = c("hull", "circle", "none"), show_boundary_label = TRUE, show_points = NULL, show_startpoints = FALSE, show_endpoints = FALSE, show_center = TRUE, show_variables = FALSE, variable_labels = NULL, title = NULL )
x |
A fitted climniche object or data returned by
|
scope |
|
type |
|
summary_layout |
Layout used when |
max_arrows |
Maximum number of current to future arrows to draw when
|
seed |
Random seed used when subsampling arrows. |
show_reference |
Logical; draw the full analysed climate-space domain. |
show_hulls |
Logical; draw current and future climate-space envelopes. |
boundary_shape |
Boundary display. |
show_boundary_label |
Logical; add envelope explanations below the exposure-class legend. |
show_points |
Logical; draw future points when |
show_startpoints |
Logical; draw class mean current positions when
|
show_endpoints |
Logical; draw class mean future positions when
|
show_center |
Logical; mark the realised niche centre. |
show_variables |
Logical; draw environmental variable directions. |
variable_labels |
Optional named vector replacing variable labels. |
title |
Optional plot title. |
A ggplot object.
Plot a climniche metric distribution
plot_climniche_distribution( x, metric = c("niche_distance_change", "climate_change_amount", "niche_boundary_exceedance", "climate_reconfiguration", "outside_niche_exceedance", "composition_change"), scope = c("current", "all"), title = NULL )plot_climniche_distribution( x, metric = c("niche_distance_change", "climate_change_amount", "niche_boundary_exceedance", "climate_reconfiguration", "outside_niche_exceedance", "composition_change"), scope = c("current", "all"), title = NULL )
x |
A fitted climniche object. |
metric |
Metric to plot. |
scope |
|
title |
Optional plot title. |
A ggplot object.
Plot the climniche exposure plane
plot_climniche_exposure( x, scope = c("current", "all"), max_points = 6000, seed = 1, title = NULL )plot_climniche_exposure( x, scope = c("current", "all"), max_points = 6000, seed = 1, title = NULL )
x |
A fitted climniche object. |
scope |
|
max_points |
Maximum number of points to draw. |
seed |
Random seed used when subsampling. |
title |
Optional plot title. |
A ggplot object.
Plot a climniche map
plot_climniche_map( x, metric = c("niche_distance_change", "niche_boundary_exceedance", "climate_change_amount", "climate_reconfiguration", "change_alignment", "outside_niche_exceedance", "composition_change"), occupied = NULL, occupied_only = FALSE, occupied_threshold = NULL, title = NULL, midpoint = 0 )plot_climniche_map( x, metric = c("niche_distance_change", "niche_boundary_exceedance", "climate_change_amount", "climate_reconfiguration", "change_alignment", "outside_niche_exceedance", "composition_change"), occupied = NULL, occupied_only = FALSE, occupied_threshold = NULL, title = NULL, midpoint = 0 )
x |
A fitted climniche object with raster outputs, or a RasterLayer. |
metric |
Metric to plot. |
occupied |
Optional current reference RasterLayer to overlay. |
occupied_only |
If TRUE, mask the plotted raster to current occurrence cells. |
occupied_threshold |
Threshold used when |
title |
Optional plot title. Use |
midpoint |
Midpoint for the Niche Distance Shift colour scale. |
A ggplot object.
Plot a climniche report figure
plot_climniche_report(x, scope = c("current", "all"))plot_climniche_report(x, scope = c("current", "all"))
x |
A fitted climniche object. |
scope |
|
A patchwork object when patchwork is installed, otherwise a named
list of ggplot objects.
Plot the climniche summary figure
plot_climniche_showcase( x, scope = c("current", "all"), max_points = 6000L, seed = 1L, plane_bins = 45L, boundary_probs = seq(0.5, 0.99, 0.01), top_variables = 6L, variable_labels = NULL, title = NULL )plot_climniche_showcase( x, scope = c("current", "all"), max_points = 6000L, seed = 1L, plane_bins = 45L, boundary_probs = seq(0.5, 0.99, 0.01), top_variables = 6L, variable_labels = NULL, title = NULL )
x |
A fitted climniche object or data returned by
|
scope |
|
max_points |
Maximum number of cells to draw in the exposure plane. |
seed |
Random seed used when subsampling cells. |
plane_bins |
Number of fixed bins used to summarize the exposure plane. |
boundary_probs |
Boundary quantiles used for the sensitivity curve. |
top_variables |
Number of variables to show. |
variable_labels |
Optional named vector replacing variable labels. |
title |
Optional overall title when |
A patchwork object when patchwork is installed, otherwise a named
list of ggplot objects.
Plot mean variable contribution
plot_climniche_variable_contribution( x, occupied_only = TRUE, variable_labels = NULL, title = NULL )plot_climniche_variable_contribution( x, occupied_only = TRUE, variable_labels = NULL, title = NULL )
x |
A |
occupied_only |
If TRUE, summarize occupied cells only. |
variable_labels |
Optional named vector replacing variable labels. |
title |
Optional plot title. Use |
A ggplot object.
Plot mean variable contribution
plot_variable_contribution( x, occupied_only = TRUE, variable_labels = NULL, title = NULL )plot_variable_contribution( x, occupied_only = TRUE, variable_labels = NULL, title = NULL )
x |
A |
occupied_only |
If TRUE, summarize occupied cells only. |
variable_labels |
Optional named vector replacing variable labels. |
title |
Optional plot title. Use |
A ggplot object.
Simulate a minimal climate niche change experiment
simulate_climniche( n = 2000, p = 2, seed = 1, rho = 0, prevalence = 0.3, shift = 0.4 )simulate_climniche( n = 2000, p = 2, seed = 1, rho = 0, prevalence = 0.3, shift = 0.4 )
n |
Number of climate cells. |
p |
Number of climate variables. |
seed |
Random seed. |
rho |
Pairwise correlation among simulated climate variables. |
prevalence |
Proportion of background cells treated as true current occurrence locations under the virtual niche. |
shift |
Climatic Displacement imposed in the closer to niche and farther from niche scenarios. |
A list with current, future_toward, future_away, occupied, center, sensitivity and A.
Variable contribution to change in niche potential
variable_contribution(current, future, center, A)variable_contribution(current, future, center, A)
current |
Current standardized climate matrix. |
future |
Future standardized climate matrix. |
center |
Realised niche centre. |
A |
Niche metric matrix. |
Matrix whose rows sum to the change in niche potential.
Write a climniche report to Markdown
write_climniche_report(report, file)write_climniche_report(report, file)
report |
An object returned by |
file |
Output Markdown file. |
Invisibly returns file.