From: James Procter Date: Mon, 27 Feb 2023 17:57:44 +0000 (+0000) Subject: JAL-4134 use average distance between PAE elements as distance for tree calculation X-Git-Tag: Release_2_11_3_0~15^2^2~26 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=43281ae2821768ea283161f12ab0eb91ea6bb3b5;p=jalview.git JAL-4134 use average distance between PAE elements as distance for tree calculation --- diff --git a/src/jalview/analysis/AverageDistanceEngine.java b/src/jalview/analysis/AverageDistanceEngine.java index ed6f861..e6a763b 100644 --- a/src/jalview/analysis/AverageDistanceEngine.java +++ b/src/jalview/analysis/AverageDistanceEngine.java @@ -39,71 +39,113 @@ import jalview.viewmodel.AlignmentViewport; public class AverageDistanceEngine extends TreeEngine { ContactMatrixI cm; + AlignmentViewport av; + AlignmentAnnotation aa; + /** - * compute cosine distance matrix for a given contact matrix and create a UPGMA tree + * compute cosine distance matrix for a given contact matrix and create a + * UPGMA tree + * * @param cm */ - public AverageDistanceEngine(AlignmentViewport av, AlignmentAnnotation aa, ContactMatrixI cm) + public AverageDistanceEngine(AlignmentViewport av, AlignmentAnnotation aa, + ContactMatrixI cm) { - this.av =av; + this.av = av; this.aa = aa; - this.cm=cm; + this.cm = cm; calculate(cm); } + + // 0 - normalised dot product + // 1 - L1 - ie (abs(v_1-v_2)/dim(v)) + // L1 is more rational - since can reason about value of difference, + // normalised dot product might give cleaner clusters, but more difficult to + // understand. + + int mode = 1; + public void calculate(ContactMatrixI cm) { this.cm = cm; node = new Vector(); clusters = new Vector(); distances = new Matrix(new double[cm.getWidth()][cm.getWidth()]); - noseqs=cm.getWidth(); - done = new BitSet(); - double moduli[]=new double[cm.getWidth()]; - - - for (int i=0;i findLeaves(BinaryNode nd, - Vector leaves) + Vector findLeaves(BinaryNode nd, Vector leaves) { if (nd == null) { @@ -333,12 +374,11 @@ public class AverageDistanceEngine extends TreeEngine * TODO: Identify internal nodes... if (node.isSequenceLabel()) { * leaves.addElement(node); } */ - findLeaves( nd.left(), leaves); - findLeaves( nd.right(), leaves); + findLeaves(nd.left(), leaves); + findLeaves(nd.right(), leaves); } return leaves; } - }