Learning center

Tree distance matrices: zero pairs, missing means and rounded stress

Read complete saved RF matrices, preserve NaN and warnings, and distinguish raw embedding diagnostics from formatted summaries and native export evidence.

Read saved RF matrices, rounded stress and missing means in Tree Comparison. Three small synthetic ensembles illustrate the difference between pairwise topology distances, a two-dimensional embedding and the app’s summary labels. The evidence contains controlled public-method calls, with no native GUI, figure or export walkthrough.

1. Preserve the ensemble and its order

The Distance Matrix route requires at least three uploaded trees with compatible input identities. These retained cases each contain three four-taxon trees. Keep the complete Newick text, names and order; each matrix row and column refers to that order. Repeated topology observations remain separate entries.

Saved caseInput nameComplete Newick
Three identical topologiesFirst((A,B),(C,D));
Three identical topologiesRepeat((A,B),(C,D));
Three identical topologiesThird((A,B),(C,D));
Repeat plus distinct topologyFirst((A,B),(C,D));
Repeat plus distinct topologyRepeat((A,B),(C,D));
Repeat plus distinct topologyThird((A,C),(B,D));
Three distinct topologiesFirst((A,B),(C,D));
Three distinct topologiesSecond((A,C),(B,D));
Three distinct topologiesThird((A,D),(B,C));

The source’s supplied-tree path checks matching taxon sets and at least four taxa. Its simple parser and these three fixtures do not establish general Newick-conformance or malformed-input handling. The saved calls received the input contract directly; they did not test a Load dialog, launcher or hosted upload.

All twenty routes initially start selected in the reviewed source. Each saved case selected Distance Matrix alone. The other nineteen route-call counts are zero; another method’s output does not extend this lesson’s coverage.

2. Read all pairwise distances

The route uses unweighted Robinson–Foulds distance: a count of split-set differences. These values have no physical unit and do not measure branch-length or evolutionary-time differences. See the RF guide for the pairwise definition.

Three identical topologies

Row / columnFirstRepeatThird
First0.00.00.0
Repeat0.00.00.0
Third0.00.00.0

Repeat plus distinct topology

Row / columnFirstRepeatThird
First0.00.02.0
Repeat0.00.02.0
Third2.02.00.0

Three distinct topologies

Row / columnFirstSecondThird
First0.02.02.0
Second2.00.02.0
Third2.02.00.0

The diagonal is zero in every saved matrix. In the middle case, First and Repeat have zero distance, while each differs from Third by 2. Retaining the zero off-diagonal pair matters when interpreting the summary; it must not be confused with a missing matrix value.

3. Keep the complete summaries and the NaN

The following table transcribes all five summary fields for each case. The two nonzero-distance examples have the same rounded summary even though their complete matrices differ:

Saved fieldIdenticalRepeat + distinctAll distinct
N Trees333
Mean RFnan2.002.00
MDS Stress0.00000.00000.0000
Max RF022
RefHillis et al., Syst Biol 2005Hillis et al., Syst Biol 2005Hillis et al., Syst Biol 2005

Mean RF uses only strictly positive matrix entries. The source filters out every zero, including zero distances between different input entries. It is therefore not the mean over all unordered pairs. In the repeated-topology case, the saved mean remains 2.00 because the zero pair is excluded.

For the all-zero case, that positive-entry selection is empty. The saved Mean RF is the text nan, not 0.00. Four RuntimeWarnings were captured: “Mean of empty slice.” and “invalid value encountered in scalar divide,” each twice. They remain part of the accepted bounded record. Do not describe it as warning-free, fill in a zero mean or discard the warnings.

4. Separate raw stress from its four-decimal display

The source constructs a two-dimensional embedding from the distance matrix. Its stress calculation compares embedded distances with the original matrix, normalized by the sum of squared original distances when that denominator is positive. The saved raw values are:

Saved caseDenominatorRaw stressSummary text
Three identical topologies0.000.0000
Repeat plus distinct topology16.05.860068894681793e-100.0000
Three distinct topologies24.01.8129866073473578e-160.0000

The two positive-denominator cases have small nonzero raw stress values that format as 0.0000. That text does not mean the stored raw value is exactly zero. The independent checks in the retained receipt used the saved coordinates and explicit tolerances; this lesson does not repeat those calculations.

When the original distance matrix is all zero, the source takes an explicit branch that stores stress 0. The saved coordinates are all zero. This observed software branch is not a mathematical acceptance of a normalized 0/0 convention, a proof of a unique embedding or evidence that the trees are biologically correct.

The log labels all three cases Quality: Good because the source compares stress with 0.1. Treat that as implementation text, not independent validation. Negative-eigenvalue handling and general stress behavior remain outside these three checks. Small negative eigenvalues in the retained nonzero cases are preserved in the evidence rather than removed.

5. Keep geometric interpretation within the evidence

The evidence includes complete RF matrices, centering matrices, eigenvalues, eigenvectors, coordinates, embedded distances and summary values. The previous numerical review compared pairwise distances derived from the saved coordinates. This guide does not accept a particular plot orientation, a general embedding method or a larger dataset.

Hillis, Heath and St. John’s tree-space paper discusses using multidimensional scaling to explore collections of trees, including distortion when reducing tree space to two dimensions. It supplies context; it does not establish that this app reproduces the paper’s method or findings.

6. Preserve the arrays without inventing a native export

These retained checks performed zero native exports and no graphics. The complete arrays were saved by the review harness, not by a tested native Export All action. The website evidence download below is a record of those observations; it is not a native matrix CSV or figure export.

Keep the input order and full matrix together with every rounded summary. For a later authorized workflow, verify the actual export’s rows, columns, precision and source identity. Another Tree route’s successful export does not establish this route’s saved-array completeness.

Worked examples describe particular inputs, methods and recorded results. Check current availability and input requirements before planning an evaluation.

← Back to the learning center