Skip to content

feat(r): add balance indices#192

Merged
Neclow merged 4 commits intosbhattlab:mainfrom
Neclow:feat/balance-indices-R
Feb 13, 2026
Merged

feat(r): add balance indices#192
Neclow merged 4 commits intosbhattlab:mainfrom
Neclow:feat/balance-indices-R

Conversation

@Neclow
Copy link
Collaborator

@Neclow Neclow commented Feb 13, 2026

  • Expose sackin, leaf_depth_variance, and b2 balance index functions in the R package via extendr bindings
  • Add tests: manual values from Rust test suite + comparisons against treestats package
  • Document treestats CRAN install step in development guide (not on conda-forge)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR exposes three tree balance index functions (sackin, leaf_depth_variance, and b2) from the Rust phylo2vec library to the R package through extendr bindings. These indices are statistical measures used to characterize tree topology shape and balance, with sackin and leaf_depth_variance measuring imbalance (higher = more imbalanced) and b2 measuring balance (higher = more balanced).

Changes:

  • Added R bindings for sackin, leaf_depth_variance, and b2 balance indices
  • Comprehensive test coverage with manual test cases from Rust suite and cross-validation against treestats package
  • Documentation update to development guide about installing treestats from CRAN

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
r-phylo2vec/src/rust/src/lib.rs Added extendr wrapper functions and exports for the three balance indices (sackin, leaf_depth_variance, b2)
r-phylo2vec/R/extendr-wrappers.R Added R function wrappers with roxygen2 documentation for the three balance indices; added default parameter for cophenetic_distances
r-phylo2vec/tests/testthat/test_stats.R Added comprehensive tests including manual test cases with known values and comparison tests against treestats package
r-phylo2vec/man/sackin.Rd Generated documentation for sackin function
r-phylo2vec/man/leaf_depth_variance.Rd Generated documentation for leaf_depth_variance function
r-phylo2vec/man/b2.Rd Generated documentation for b2 function
r-phylo2vec/man/get_common_ancestor.Rd Updated parameter documentation (removed duplicate vector param, fixed tree param)
r-phylo2vec/man/cophenetic_distances.Rd Cleaned up duplicate documentation and standardized parameter descriptions
r-phylo2vec/R/stats.R Removed duplicate cophenetic_distances function definition
r-phylo2vec/NAMESPACE Added exports for the three new balance index functions
docs/development.md Documented manual installation of treestats package from CRAN for R testing

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Neclow Neclow merged commit d753d21 into sbhattlab:main Feb 13, 2026
9 checks passed
@Neclow Neclow deleted the feat/balance-indices-R branch February 13, 2026 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments