Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
c3a8616
Initial plan
Copilot Sep 5, 2025
a43bb2a
Implement basic Hierarchical Mutual Information functionality
Copilot Sep 5, 2025
b9acd3f
Complete Hierarchical Mutual Information implementation with full tests
Copilot Sep 5, 2025
13c17a2
Fix HMI implementation to match Python reference (returns ~0.22 vs ex…
Copilot Sep 6, 2025
5de0a59
Fix hierarchical partition conversion to use tip labels instead of no…
Copilot Sep 6, 2025
507938f
Experiment with different hierarchical partition representations
Copilot Sep 6, 2025
88ed7a1
Restore working HMI implementation - produces 0.3633532 matching Pyth…
Copilot Sep 6, 2025
e220ec7
Debugging
ms609 Sep 5, 2025
9dbe2c4
rm tmp
ms609 Sep 5, 2025
93e88f9
update tests; document
ms609 Sep 6, 2025
25c7717
Fix HMI implementation to use log2 and return raw HMI value
Copilot Sep 6, 2025
d1b1d9e
Complete HMI implementation with empirical scaling factor to match ex…
Copilot Sep 6, 2025
27636a4
Fix HMI implementation to return raw HMI value instead of d_n distanc…
Copilot Sep 6, 2025
5e22c8e
Complete correct HMI implementation - returns 0.2195121 matching C++ …
Copilot Sep 6, 2025
207a9ec
Implement HMI algorithm matching Python reference implementation beha…
Copilot Sep 6, 2025
b78018b
Merge branch 'main' into copilot/fix-151
ms609 Sep 8, 2025
994bf44
Tests from .pynb
ms609 Sep 8, 2025
65f4a8c
as.HPart
ms609 Sep 8, 2025
96594b5
Replicate hmi.pynb
ms609 Sep 8, 2025
3d6ca9b
Delete hit.cpython-312.pyc
ms609 Sep 8, 2025
8b11dce
inst/__pycache__*
ms609 Sep 8, 2025
409869c
-hmi.cpp
ms609 Sep 8, 2025
e36dcd1
Remove python script
ms609 Sep 8, 2025
a88e13c
AHMI implemented
ms609 Sep 8, 2025
aabc657
<tol
ms609 Sep 9, 2025
143ece3
Delete tree_distance_hvi.R
ms609 Sep 9, 2025
0bd69bd
Pretending that children are nodes
ms609 Sep 9, 2025
d8cefb0
HPart structure
ms609 Sep 9, 2025
cc0c498
entropy calculation
ms609 Sep 10, 2025
14ba3c3
cache child_node; calculate leaf metadata
ms609 Sep 10, 2025
585422f
debug
ms609 Sep 10, 2025
31af9c1
No exports in namespace (!)
ms609 Sep 10, 2025
0f72562
SUCCESS (!?!?)
ms609 Sep 10, 2025
ef285d7
Roll out c++ HPart class precursor
ms609 Sep 10, 2025
df4f98f
HPart→phylo
ms609 Sep 10, 2025
f0ba89d
RelabelTips requires storage of child_idx
ms609 Sep 10, 2025
86649c2
Relabelling successful
ms609 Sep 10, 2025
d6e27a0
as.HPart_cpp.list
ms609 Sep 10, 2025
0756c1a
Fix for nested lists
ms609 Sep 10, 2025
6ef2617
SelfHMI
ms609 Sep 10, 2025
688281d
EHMI
ms609 Sep 10, 2025
1a19d82
AHMI
ms609 Sep 10, 2025
419e290
Extend testing
ms609 Sep 10, 2025
587236d
Python reference values
ms609 Sep 10, 2025
3dbdeab
self-testing
ms609 Sep 10, 2025
e4190ad
Update tests
ms609 Sep 10, 2025
86e4e93
Remove naive R implementation
ms609 Sep 10, 2025
edfa47c
Test leaf order
ms609 Sep 10, 2025
ea536ab
Merge branch 'main' into copilot/fix-151
ms609 Sep 10, 2025
aa87be7
Update expectations
ms609 Sep 10, 2025
08907f3
Rm duplicate SelfHMI
ms609 Sep 10, 2025
dd8a77b
Format; log 1 = 0
ms609 Sep 10, 2025
90c5d13
Understanding python quirks
ms609 Sep 10, 2025
d9f7f61
Document
ms609 Sep 11, 2025
f5b2777
Convert output to bits
ms609 Sep 11, 2025
24587a7
avoid warnings
ms609 Sep 11, 2025
b86a3bd
Update .Rbuildignore
ms609 Sep 11, 2025
46259ba
Document AHMI
ms609 Sep 11, 2025
a7b33e5
as.HPart.default
ms609 Sep 11, 2025
cf0a594
Rename
ms609 Sep 11, 2025
0940e5a
as.HPart.numeric
ms609 Sep 11, 2025
ef763f9
Round to zero
ms609 Sep 11, 2025
7280b86
Cache self-entropy
ms609 Sep 11, 2025
0b602dc
Flatten lists again
ms609 Sep 11, 2025
bf6b0b1
tolerance→precision
ms609 Sep 11, 2025
aa0c343
Bump to Version: 2.10.1.9001
ms609 Sep 11, 2025
85e4de1
Zero small values
ms609 Sep 11, 2025
50bdd3e
Add failing test cases
ms609 Sep 11, 2025
f38d9f0
Perotti 2025 tests
ms609 Sep 11, 2025
cc07986
Root position dependence
ms609 Sep 11, 2025
88cb3c2
non-passing tests
ms609 Sep 11, 2025
4d1b464
Update expectation
ms609 Sep 11, 2025
26dc4dd
HPart
ms609 Sep 11, 2025
0a88846
Document aliases
ms609 Sep 11, 2025
fc64f07
Tests for bad input
ms609 Sep 23, 2025
a8d44d3
Test plotting
ms609 Sep 23, 2025
ef348dd
Test error conditions
ms609 Sep 23, 2025
6b75cfc
Mark nocov
ms609 Sep 23, 2025
4d9a3aa
Test print.HPart
ms609 Sep 23, 2025
1d21c15
Test error; reorder tests
ms609 Sep 23, 2025
1817405
nocov
ms609 Sep 23, 2025
269110a
Seed for reproducibility
ms609 Sep 23, 2025
607e41c
Error testing
ms609 Sep 23, 2025
b54bda4
memcheck w/ template, ub24.04
ms609 Sep 23, 2025
adcf38c
Merge branch 'main' into hmi-no-copilot
ms609 Sep 25, 2025
42feacf
Document changes
ms609 Sep 25, 2025
9aa3f12
More selective activation
ms609 Sep 25, 2025
f010244
rhub2
ms609 Sep 25, 2025
00ce78b
Perotti; PhysRevE
ms609 Sep 25, 2025
9607db5
Notify on failure
ms609 Sep 25, 2025
f00a70a
spell out `...`
ms609 Sep 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
CONTRIBUTING
README.md
^\.github
^\.lintr
cran-comments.md
man-roxygen
data-raw
Expand Down
28 changes: 21 additions & 7 deletions .github/workflows/R-CMD-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-22.04, r: '4.1',
rspm: "https://packagemanager.rstudio.com/cran/__linux__/jammy/latest"}
- {os: ubuntu-latest, r: 'release',
- {os: ubuntu-24.04, r: 'release',
rspm: "https://packagemanager.rstudio.com/cran/__linux__/noble/latest"}
- {os: ubuntu-latest, r: 'devel',
rspm: "https://packagemanager.rstudio.com/cran/__linux__/noble/latest"}
Expand All @@ -76,12 +76,6 @@ jobs:
r-version: ${{ matrix.config.r }}
extra-repositories: https://ms609.github.io/packages/

- name: Install apt packages (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y texlive-latex-base libglpk-dev texlive-fonts-recommended

- name: Set up R dependencies (Windows)
if: runner.os == 'Windows'
uses: r-lib/actions/setup-r-dependencies@v2
Expand Down Expand Up @@ -126,3 +120,23 @@ jobs:
if: runner.os == 'Windows'
run: covr::codecov()
shell: Rscript {0}

- name: Notify on failure
if: failure() && github.event_name == 'schedule'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: 164,
body: 'Scheduled workflow has failed: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
});

await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: 164,
state: 'open'
});
18 changes: 18 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,28 @@ name: Benchmark
on:
workflow_dispatch:
pull_request:
paths:
- "src/**"
- "R/**"
- "**.R"
- "**.cpp"
- "**.c"
- "**.h"
- "**.hpp"
- "configure*"
- "Makevars*"
paths-ignore:
- "DESCRIPTION"
- ".**"
- "Meta**"
- "memcheck**"
- "docs**"
- "inst**"
- "man**"
- "man-roxygen**"
- "memcheck**"
- "tests**"
- "vignettes**"
- "**.git"
- "**.json"
- "**.md"
Expand Down
32 changes: 25 additions & 7 deletions .github/workflows/memcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,8 @@ on:
name: mem-check

jobs:
mem-check:
runs-on: ubuntu-20.04
# stringi requires libicui18n - apt get libicu-dev too recent,
# libicu66 deprecated in ubuntu 22.04
# Reinstalling stringi seems not to help

mem-check-templated:
runs-on: ubuntu-24.04
name: valgrind ${{ matrix.config.test }}, ubuntu, R release

strategy:
Expand All @@ -53,10 +49,32 @@ jobs:
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
_R_CHECK_FORCE_SUGGESTS_: false
RSPM: https://packagemanager.rstudio.com/cran/__linux__/focal/latest
RSPM: https://packagemanager.rstudio.com/cran/__linux__/noble/latest
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: ms609/actions/memcheck@main
with:
test: ${{ matrix.config.test}}

mem-check-legacy:
runs-on: ubuntu-24.04
name: valgrind ${{ matrix.config.test }}, ubuntu, R release

strategy:
fail-fast: false
matrix:
config:
- {test: 'tests'}
- {test: 'examples'}
- {test: 'vignettes'}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
_R_CHECK_FORCE_SUGGESTS_: false
RSPM: https://packagemanager.rstudio.com/cran/__linux__/noble/latest
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/checkout@v5

- uses: r-lib/actions/setup-r@v2
Expand Down
40 changes: 13 additions & 27 deletions .github/workflows/rhub.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# R-hub's generic GitHub Actions workflow file. Its canonical location is at
# https://github.com/r-hub/rhub2/blob/v1/inst/workflow/rhub.yaml
# R-hub's generic GitHub Actions workflow file. It's canonical location is at
# https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml
# You can update this file to a newer version using the rhub2 package:
#
# rhub2::rhub_setup()
# rhub::rhub_setup()
#
# It is unlikely that you need to modify this file manually.

Expand Down Expand Up @@ -33,7 +33,7 @@ jobs:

steps:
# NO NEED TO CHECKOUT HERE
- uses: r-hub/rhub2/actions/rhub-setup@v1
- uses: r-hub/actions/setup@v1
with:
config: ${{ github.event.inputs.config }}
id: rhub-setup
Expand All @@ -51,27 +51,17 @@ jobs:
image: ${{ matrix.config.container }}

steps:
- name: Check distribution
run: |
echo "distribution=$(awk -F= '/^ID=/{print $2}' /etc/os-release)" \
>> $GITHUB_OUTPUT;
id: check_distribution
- name: apt-get install sudo (Ubuntu, for clang-asan)
run: apt-get install sudo
if: ${{ steps.check_distribution.outputs.distribution == 'ubuntu' }}
- uses: r-lib/actions/setup-pandoc@v2
if: ${{ steps.check_distribution.outputs.distribution != 'fedora' }}
- uses: r-hub/rhub2/actions/rhub-checkout@v1
- uses: r-hub/rhub2/actions/rhub-platform-info@v1
- uses: r-hub/actions/checkout@v1
- uses: r-hub/actions/platform-info@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/rhub2/actions/rhub-setup-deps@v1
- uses: r-hub/actions/setup-deps@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
extra-packages: TreeDistData=?ignore-before-r=99.0.0
- uses: r-hub/rhub2/actions/rhub-run-check@v1
- uses: r-hub/actions/run-check@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
Expand All @@ -87,25 +77,21 @@ jobs:
config: ${{ fromJson(needs.setup.outputs.platforms) }}

steps:
- uses: teatimeguest/setup-texlive-action@v3
with:
packages: scheme-basic
- uses: r-lib/actions/setup-pandoc@v2
- uses: r-hub/rhub2/actions/rhub-checkout@v1
- uses: r-hub/rhub2/actions/rhub-setup-r@v1
- uses: r-hub/actions/checkout@v1
- uses: r-hub/actions/setup-r@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
- uses: r-hub/rhub2/actions/rhub-platform-info@v1
- uses: r-hub/actions/platform-info@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/rhub2/actions/rhub-setup-deps@v1
- uses: r-hub/actions/setup-deps@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
extra-packages: TreeDistData=?ignore-before-r=99.0.0
- uses: r-hub/rhub2/actions/rhub-run-check@v1
- uses: r-hub/actions/run-check@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ src/*.dll
*.utf8.md
/* *.Rd */
revdep/
inst/__pycache__*
vignettes/*.html
vignettes/*.pdf
vignettes/*_files
Expand Down
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: TreeDist
Type: Package
Title: Calculate and Map Distances Between Phylogenetic Trees
Version: 2.10.1.9001
Version: 2.10.1.9002
Authors@R: c(person("Martin R.", "Smith",
email = "martin.smith@durham.ac.uk",
role = c("aut", "cre", "cph", "prg"),
Expand All @@ -23,6 +23,8 @@ Description: Implements measures of tree similarity, including
including the Nye et al. (2006) metric <doi:10.1093/bioinformatics/bti720>;
the Matching Split Distance (Bogdanowicz & Giaro 2012)
<doi:10.1109/TCBB.2011.48>;
the Hierarchical Mutual Information (Perotti et al. 2015)
<doi:10.1103/PhysRevE.92.062825>;
Maximum Agreement Subtree distances;
the Kendall-Colijn (2016) distance <doi:10.1093/molbev/msw124>, and the
Nearest Neighbour Interchange (NNI) distance, approximated per Li et al.
Expand Down
22 changes: 22 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ S3method(NNIDiameter,list)
S3method(NNIDiameter,multiPhylo)
S3method(NNIDiameter,numeric)
S3method(NNIDiameter,phylo)
S3method(NTip,HPart)
S3method(RenumberTips,HPart)
S3method(SPRDist,list)
S3method(SPRDist,multiPhylo)
S3method(SPRDist,phylo)
Expand All @@ -35,8 +37,17 @@ S3method(SplitwiseInfo,Splits)
S3method(SplitwiseInfo,list)
S3method(SplitwiseInfo,multiPhylo)
S3method(SplitwiseInfo,phylo)
S3method(as.HPart,HPart)
S3method(as.HPart,default)
S3method(as.HPart,list)
S3method(as.HPart,phylo)
S3method(as.phylo,HPart)
S3method(clone,HPart)
S3method(median,multiPhylo)
S3method(plot,HPart)
S3method(print,HPart)
export(.TreeDistance)
export(AHMI)
export(AllSplitPairings)
export(CalculateTreeDistance)
export(ClusteringEntropy)
Expand All @@ -49,10 +60,15 @@ export(DifferentPhylogeneticInfo)
export(DisplayMatching)
export(DistFromMed)
export(DistanceFromMedian)
export(EHMI)
export(Entropy)
export(ExpectedVariation)
export(GeneralizedRF)
export(GetParallel)
export(HH)
export(HMI)
export(HierarchicalMutualInfo)
export(HierarchicalMutualInformation)
export(InfoRobinsonFoulds)
export(InfoRobinsonFouldsSplits)
export(Islands)
Expand Down Expand Up @@ -105,6 +121,7 @@ export(RobinsonFouldsInfo)
export(RobinsonFouldsMatching)
export(RobinsonFouldsSplits)
export(SPRDist)
export(SelfHMI)
export(SetParallel)
export(SharedPhylogeneticInfo)
export(SharedPhylogeneticInfoSplits)
Expand All @@ -127,7 +144,10 @@ export(TreeDistance)
export(TreesConsistentWithTwoSplits)
export(VisualiseMatching)
export(VisualizeMatching)
export(as.HPart)
export(clone)
export(entropy_int)
export(is.HPart)
importFrom(Rdpack,reprompt)
importFrom(TreeTools,AllAncestors)
importFrom(TreeTools,DropTip)
Expand All @@ -141,6 +161,7 @@ importFrom(TreeTools,Log2Unrooted)
importFrom(TreeTools,Log2Unrooted.int)
importFrom(TreeTools,MSTEdges)
importFrom(TreeTools,MSTLength)
importFrom(TreeTools,MatchStrings)
importFrom(TreeTools,NRooted)
importFrom(TreeTools,NSplits)
importFrom(TreeTools,NTip)
Expand All @@ -162,6 +183,7 @@ importFrom(TreeTools,as.ClusterTable)
importFrom(TreeTools,as.Splits)
importFrom(TreeTools,edge_to_splits)
importFrom(ape,Nnode.phylo)
importFrom(ape,as.phylo)
importFrom(ape,drop.tip)
importFrom(ape,edgelabels)
importFrom(ape,nodelabels)
Expand Down
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# TreeDist 2.10.1.9001 (development)
# TreeDist 2.10.1.9002 (development)

- `HierarchicalMutualInformation()` calculates the information shared between
pairs of hierarchical partition structures <doi:10.1103/PhysRevE.92.062825>.
- Fix crash in `robinson_foulds_all_pairs()` and `RobinsonFoulds(list)`.
- Fix bug in calculation of `MutualClusteringInfo()`: greedy optimization
was not guaranteed to find globally optimal matching, causing distances to be
Expand Down
Loading
Loading