Angular Separation Between Nutritional Optima

Fits response surfaces (ordinary least squares, generalized linear models with any family including quasi-families, or linear mixed-effects models) to trait data collected under the Geometric Framework for Nutrition and computes the angular separation (theta) between the nutritional optima of two traits, with percentile bootstrap confidence intervals that propagate surface-estimation uncertainty (case or stratified resampling; paired or unpaired). Provides a design-matched coverage check that simulates validation configurations on the user's own design and at the signal-to-noise ratio of the fitted surfaces, an equivalence test for alignment of optima, local Gaussian and mean curvature, and a surface-area ratio. Includes the Drosophila lifespan and fecundity dataset of Lee et al. (2008) "Lifespan and reproduction in Drosophila: new insights from nutritional geometry" as a worked example. The angular approach was introduced in Morimoto (2023) "Nutrigonometry I: using right-angle triangles to quantify nutritional trade-offs in performance landscapes" .


nutrigon nutrigon logo

License: MIT

Overview

nutrigon fits quadratic response surfaces to trait data collected under the Geometric Framework for Nutrition (GFN) and computes the angular separation (theta) between the nutritional optima of two traits, with percentile bootstrap confidence intervals that refit the surfaces in every replicate. Theta measures the difference in nutrient balance (direction) between optima; it does not measure their radial distance (total intake) or the fitness cost of a trade-off, so report it with the locations of the optima.

The package also provides a design-matched coverage check (nutrigon_build_grid() + nutrigon_check()), which simulates validation configurations on your own design and at the signal-to-noise ratio of your fitted surfaces, and an equivalence test for alignment of optima (nutrigon_equivalence()), since the unsigned interval cannot by itself show that two optima coincide.

Installation

# from a local source tarball
install.packages("path/to/nutrigon", repos = NULL, type = "source")

Core workflow

library(nutrigon)
data(lee_drosophila)

fit1 <- nutrigon_fit(lee_drosophila, "protein_eaten", "carb_eaten",
                      "lifespan", design_id_col = "treatment")
fit2 <- nutrigon_fit(lee_drosophila, "protein_eaten", "carb_eaten",
                      "dailyeggs", design_id_col = "treatment")

result <- nutrigon_compare(
  lee_drosophila, "protein_eaten", "carb_eaten", "lifespan",
  lee_drosophila, "protein_eaten", "carb_eaten", "dailyeggs",
  paired = TRUE, B = 500, seed = 1        # case resampling (validated)
)
print(result)

# Design-matched coverage check (slow: build once, then saveRDS())
grid <- nutrigon_build_grid(
  design = lee_drosophila, x_col = "protein_eaten", y_col = "carb_eaten",
  design_id_col = "treatment",
  snr = c(nutrigon_snr(fit1), nutrigon_snr(fit2)), seed = 99
)
nutrigon_check(result,
               elong1 = nutrigon_elongation(fit1),
               elong2 = nutrigon_elongation(fit2),
               validation_grid = grid)

# Are two optima aligned within 10 degrees?
nutrigon_equivalence(result, delta = 10)

See vignette("getting-started") for the full walkthrough, and vignette("zanco-tradeoff-matrix") for the N x N trade-off matrix, clustering, and overlay-plot example built on Zanco et al. (2025).

Example data

  • lee_drosophila -- Lee et al. (2008) Drosophila lifespan/fecundity data.
  • zanco_survival, zanco_wingsize -- Zanco et al. (2025) viability and wing size data.
  • nutrigon_validation_grid -- a generic pre-built validation grid (seed = 2025, 5-rail design) for trying nutrigon_check(); build a design-matched grid for applied results.
  • zanco_tradeoff_matrix -- the pre-computed 12x12 pairwise angular trade-off matrix for the Zanco example.

Citation

Morimoto, J. (in review). Bootstrap inference for angular separation between nutritional optima in the Geometric Framework for Nutrition. Methods in Ecology and Evolution.

And the original Nutrigonometry paper:

Morimoto, J. et al. (2023). Nutrigonometry I: using right-angle triangles to quantify nutritional trade-offs in performance landscapes. The American Naturalist, 201(5), 725-740.

License

MIT

Author

Juliano Morimoto (ORCID: 0000-0003-3561-1920)

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("nutrigon")

0.1.0 by Juliano Morimoto, 11 hours ago


https://github.com/jmor2753/nutrigon


Report a bug at https://github.com/jmor2753/nutrigon/issues


Browse source code at https://github.com/cran/nutrigon


Authors: Juliano Morimoto [aut, cre] (ORCID:


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports stats, grDevices, withr

Suggests ggplot2, ggdendro, ggrepel, patchwork, knitr, rmarkdown, testthat, lme4, lmerTest, pracma


See at CRAN