Package: terradish 1.1.0

terradish: Fast Gradient-Based Optimization of Resistance Surfaces

Maximum likelihood estimation of landscape conductance surfaces from genetic data on raster graphs, using Newton and quasi-Newton optimization with analytic derivatives. Fits log-linear conductance models with optional joint estimation of Gaussian smoothing scales and spline response shapes, linked to pairwise genetic distances through maximum likelihood population effects models or to allele-frequency covariance through a Wishart likelihood on site contrasts, with the same pairwise distance and environment covariates available in both. Provides exact sparse and iterative solvers for large rasters, fixed-domain spatial cross-validation for comparing conductance formulas, and simulation tools for study design. Works with 'terra' objects. Fitting one parameterized conductance surface to genetic data, rather than regressing on separate resistance distances, follows Peterman and Pope (2021) <doi:10.1111/mec.15716>. Background on population-effects models and circuit-based covariance models is provided by Clarke, Rothery and Raybould (2002) <doi:10.1198/108571102320> and Hanks and Hooten (2013) <doi:10.1080/01621459.2012.724647>, respectively.

Authors:Bill Peterman [aut, cre], Nathaniel S. Pope [aut]

terradish_1.1.0.tar.gz
terradish_1.1.0.zip(r-4.7-x86_64)terradish_1.1.0.zip(r-4.7-arm64)terradish_1.1.0.zip(r-4.6-x86_64)terradish_1.1.0.zip(r-4.6-arm64)terradish_1.1.0.zip(r-4.5-x86_64)
terradish_1.1.0.tgz(r-4.6-x86_64)terradish_1.1.0.tgz(r-4.6-arm64)terradish_1.1.0.tgz(r-4.5-x86_64)terradish_1.1.0.tgz(r-4.5-arm64)
terradish_1.1.0.tar.gz(r-4.7-arm64)terradish_1.1.0.tar.gz(r-4.7-x86_64)terradish_1.1.0.tar.gz(r-4.6-arm64)terradish_1.1.0.tar.gz(r-4.6-x86_64)
terradish_1.1.0.tgz(r-4.6-emscripten)
manual.pdf |manual.html✨
DESCRIPTION |NEWS
card.svg |card.png
terradish/json (API)

# Install 'terradish' in R:
install.packages('terradish', repos = c('https://wpeterman.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/wpeterman/terradish/issues

Uses libs:
  • openblas– Optimized BLAS
  • c++– GNU Standard C++ Library v3
  • openmp– GCC OpenMP (GOMP) support library
Datasets:

On CRAN:

Conda:

openblascppopenmp

5.76 score 1 stars 53 scripts 50 exports 66 dependencies

Last updated from:960db5a5e4. Checks:15 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-arm64OK283
linux-devel-x86_64OK273
source / vignettesOK388
linux-release-arm64OK285
linux-release-x86_64OK265
macos-release-arm64OK315
macos-release-x86_64OK840
macos-oldrel-arm64OK324
macos-oldrel-x86_64OK737
windows-devel-arm64OK423
windows-devel-x86_64OK398
windows-release-arm64OK455
windows-release-x86_64OK292
windows-oldrel-x86_64OK421
wasm-releaseOK182

Exports:aic_tableArmijoControlcheck_distance_responseconductanceconductance_surfacecov_from_bialleliccov_from_genetic_datacovariance_response_powercrop_to_focal_bufferdist_from_biallelicdist_from_covfst_from_biallelicgaussian_scale_profilegaussian_scale_summarygaussian_smoothed_loglinear_conductancegeneralized_wishartHagerZhangControlleastsquaresloglinear_conductancelowermlpemlpe_covariatesmlpe_response_changeNewtonRaphsonControlpairwise_covariatespairwise_endpoint_covariatespca_distradishradish_algorithmradish_distanceradish_gridscale_covariatesscale_to_0_1simulate_covariance_responseslim_terradishsmooth_loglinear_conductanceterra_radish_scale_optimterradishterradish_algorithmterradish_assess_settingsterradish_cv_foldsterradish_distanceterradish_foldsterradish_gridterradish_ibe_ratioterradish_rescale_nuterradish_scale_optimterradish_solver_benchmarkwishart_covariancewishart_covariates

Dependencies:AICcmodavgclassclassIntclicowplotcpp11crayonDBIdotCall64dplyre1071exactextractrfarverfieldsgenericsggplot2gluegtableinsightisobandKernSmoothlabelinglandgraphlatticelifecyclemagrittrmapsMASSMatrixmultiScaleRnlmeoptimParallelpillarpkgconfigproxypsclR6rasterrbibutilsRColorBrewerRcppRcppArmadilloRcppEigenRdpackreformulasrlangs2S7scalessfspspamsurvivalterratibbletidyselectTMBunitsunmarkedutf8vctrsVGAMviridisLitewithrwkxtable

Categorical Landscape Covariates
What does a categorical coefficient mean? | Load a factor-valued raster | Specify the reference and contrasts | Generate a specified covariance example | Fit and interpret the class contrast | Plot a class contrast and its map | Verify what changing the reference does | Evaluate class and continuous candidates on the same folds | Smoothing land-cover classes | Quick reference: a categorical conductance workflow | Summary of key functions | See also

Last update: 2026-10-28
Started: 2026-10-28

Choosing and Checking a Genetic Covariance Response
What genetic quantity are you modeling? | Preserve sampling order and marker meaning | Check covariance and distance geometry | Inspect the response as a matrix | Separate marker count from assumed information | Adapt the construction to your data | Summary of key functions | See also

Last update: 2026-10-28
Started: 2026-05-05

Gaussian Scale Optimization
What question does a Gaussian scale answer? | Rebuild the shared response and graph | Set interpretable scale bounds and fit | Inspect scale uncertainty with a likelihood profile | View conductance at the fitted scale | Compare estimated and fixed context | Evaluate prediction in whole held-out ponds | What to take to your own study | Quick reference: estimate and validate one Gaussian context | Summary of key functions | See also

Last update: 2026-10-28
Started: 2026-04-09

Getting Started with terradish
What will you learn? | Choose your next question | Meet the forest-pond example | Load and inspect the data | Turn SNP dosage into a pond covariance | Build the conductance graph | Fit forest and uniform-conductance models | Check convergence, comparison, and adequacy | Follow forest from conductance to the genetic response | Construct the matched microsatellite response | Quick reference: a complete fixed-context SNP workflow | Summary of key functions | See also

Last update: 2026-10-28
Started: 2026-04-03

How the Salamander Example Data Were Generated
Two examples, three kinds of data | Prepare the real landscape | Generate the pond history in SLiM | Generate the terrestrial history in SLiM | Select animals before examining genotypes | Add ancestry and matched markers | From genotypes to the modeled response | Reproduce an analysis or regenerate a history | See also | Reference

Last update: 2026-10-28
Started: 2026-10-28

Individual genotypes and nonlinear landscape resistance
What you will learn | Load the matched example | The landscape, animals, and sampling | From individual genotypes to a covariance response | Why not use the biallelic helpers here? | Build a nonlinear drying model | Test prediction before calling this IBR recovery | A separate genomic assay with no parameter refitting | Keep IBE distinct from IBR | Scope of this dataset | Quick reference | Reference

Last update: 2026-10-28
Started: 2026-10-28

Isolation by Environment and Resistance
Three environmental hypotheses that should stay distinct | Prepare the graph, genotypes, and endpoint differences | Define the two measurement constructions | This kernel is not a Gaussian similarity kernel | Use the SLiM SNP response as a negative control | A separate positive example: generate a covariance component | Plot the environmental contribution | Validate an environmental extension within one family | Interpreting IBE in field data | Quick reference: SNP negative-control construction | Summary of key functions | See also

Last update: 2026-10-28
Started: 2026-04-01

Large Landscapes
When a landscape is "large" | Choosing a solver | Reusing Windows workers | Controlling the nuisance profile | Curvature for standard errors | Information and effective degrees of freedom | Cropping and coarse warm starts | Storing large fitted objects | Quick reference | Summary of key functions | See also

Last update: 2026-10-28
Started: 2026-06-15

Model Comparison and Selection in terradish
What evidence should choose a model? | Prepare one response and one landscape | Declare the biological candidates | Read information criteria with their assumptions | Use a likelihood-ratio test only for a nested question | Inspect conditional associations | Compare spatial prediction | Put the evidence together | Quick reference: a complete candidate comparison | Summary of key functions | See also

Last update: 2026-10-28
Started: 2026-04-03

Pairwise Genetic Distances with MLPE
When to use MLPE | Load and inspect the data | Build the conductance graph | Fit candidate models | Read the MLPE summary | Coefficients are conditional on the other terms | Check the fit and map conductance | Does the extra term predict new sites? | Quick reference | Summary of key functions | See also | Reference

Last update: 2026-10-28
Started: 2026-10-28

Simulating Covariance Data to Plan a Study
How many ponds would you sample? | Keep the landscape and specify a new response | Generate once and inspect recovery | Compare site designs without changing the question | Separate data information from assumed precision | What can you take to the field? | Summary of key functions | See also

Last update: 2026-10-28
Started: 2026-05-29

Spline Conductance Models
Shape and spatial context are different questions | Use the same genotypes and fixed context | See how basis functions build a curve | Fit linear and spline candidates with starting checks | Interpret the fitted association and its support | View the genetic-response curve | Ask whether flexibility earns its extra parameters | What to take to your own study | Quick reference: shape at a fixed context | Summary of key functions | See also

Last update: 2026-10-28
Started: 2026-05-12

Readme and manuals

Help Manual

Help pageTopics
Rank fitted terradish models by information criterionaic_table
Control settings for Armijo backtracking line searchArmijoControl
Check a generalized-Wishart distance responsecheck_distance_response
Estimate conductance from a fitted modelconductance conductance.terradish_graph
Create a parameterized conductance surfaceconductance_surface
Assess covariance-response parameter recovery by simulationcovariance_response_power
Crop rasters to a focal-site buffercrop_to_focal_buffer
Profile a Gaussian smoothing scalegaussian_scale_profile
Summarize fitted Gaussian smoothing scalesgaussian_scale_summary
Gaussian scale-aware log-linear conductance modelgaussian_smoothed_loglinear_conductance
Generalized Wishart distance regressiongeneralized_wishart
Control settings for Hager-Zhang line searchHagerZhangControl
Simulated Individual Salamander Genotypes and Resistance Analysesindividual_salamanders
Least-squares measurement modelleastsquares
Log-link conductance modelloglinear_conductance
Extract the strict lower triangle of a matrixlower
Melipona Example Datamelip melip.altitude melip.coords melip.forestcover melip.Fst
Maximum likelihood population effects (MLPE) measurement modelmlpe
MLPE measurement model with pairwise endpoint-difference covariatesmlpe_covariates
Response-scale change for MLPE pairwise covariatesmlpe_response_change
Control settings for Newton-like optimizersNewtonRaphsonControl
Simulated Ohio Forest-Pond Genetic Dataohio_ponds
Combine environmental and other pairwise covariatespairwise_covariates
Pairwise endpoint-difference covariatespairwise_endpoint_covariates
Pairwise genetic distances from PCA scorespca_dist
Plot methods for fitted terradish modelsplot.terradish
Print a covariance-response power assessmentprint.terradish_covariance_power
Print a terradish settings assessmentprint.terradish_setting_assessment
Scale raster covariates and retain original-scale metadatascale_covariates
Rescale values to the unit intervalscale_to_0_1
Simulate covariance responses from a conductance surfacesimulate_covariance_response
Reduce the storage size of a fitted terradish modelslim_terradish
Smooth log-link conductance modelsmooth_loglinear_conductance
Optimize a parameterized conductance surfaceterradish
Likelihood of parameterized conductance surfaceterradish_algorithm
Assess terradish speed settings for a data setterradish_assess_settings
Conductance model factoriesterradish_conductance_model_factory
Fixed-domain cross-validation for terradish modelsterradish_cv_folds
Resistance distances from a parameterized conductance surfaceterradish_distance
Construct reproducible cross-validation foldsterradish_folds
Evaluate likelihood of a parameterized conductance surfaceterradish_grid
Environmental effects in resistance-distance unitsterradish_ibe_ratio
Covariance and intervals for fitted conductance parametersconfint.terradish nobs.terradish terradish_inference vcov.terradish
Measurement modelsterradish_measurement_model
Methods for fitted terradish modelsAIC.terradish anova.terradish coef.terradish fitted.terradish logLik.terradish print.summary.terradish print.terradish residuals.terradish simulate.terradish summary.terradish terradish_methods
Rescale the effective information in a Wishart fitterradish_rescale_nu
Optimize raster smoothing scales around a terradish fitterradish_scale_optim
Benchmark linear solver settings for a terradish graphterradish_solver_benchmark
Wishart covariance measurement modelwishart_covariance
Wishart measurement models with site-level environmental covariance kernelswishart_covariates