AlignmentAnnotation aa;
+ // 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;
+
/**
* compute cosine distance matrix for a given contact matrix and create a
* UPGMA tree
- *
* @param cm
+ * @param cosineOrDifference false - dot product : true - L1
*/
public AverageDistanceEngine(AlignmentViewport av, AlignmentAnnotation aa,
- ContactMatrixI cm)
+ ContactMatrixI cm, boolean cosineOrDifference)
{
this.av = av;
this.aa = aa;
this.cm = cm;
+ mode = (cosineOrDifference) ? 1 :0;
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)
{
// compute distance matrix element
ContactListI ith = cm.getContactList(i);
-
+ distances.setValue(i, i, 0);
+ if (ith==null)
+ {
+ continue;
+ }
for (int j = 0; j < i; j++)
{
- distances.setValue(i, i, 0);
ContactListI jth = cm.getContactList(j);
+ if (jth == null)
+ {
+ break;
+ }
double prd = 0;
for (int indx = 0; indx < cm.getHeight(); indx++)
{