Class LeastSquaresBranchLengths
- java.lang.Object
-
- edu.rit.compbio.phyl.LeastSquaresBranchLengths
-
public class LeastSquaresBranchLengths extends java.lang.ObjectClass LeastSquaresBranchLengths provides methods for computing least squares branch lengths in a DnaSequenceTree.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static doublesolve(DnaSequenceTree tree, Distance dcalc)Find the least squares branch lengths for the given DNA sequence tree.static doublesquaredError(DnaSequenceTree tree, Distance dcalc)Compute the squared error in the given DNA sequence tree's branch lengths.
-
-
-
Method Detail
-
squaredError
public static double squaredError(DnaSequenceTree tree, Distance dcalc)
Compute the squared error in the given DNA sequence tree's branch lengths. When squaredError() is called:- Every tip node in the tree must be associated with a DNA sequence of the same length.
- Every node in the tree either is associated with a branch length, or is assumed to have a branch length of 0 if not associated with a branch length.
This method computes the distance between each pair of DNA sequences using the given dcalc object (the "direct distance"); computes the distance between each pair of DNA sequences by adding up the branch lengths along the path through the tree between the sequences (the "tree distance"); and returns the sum of the squares of the differences between the direct distance and the tree distance for each pair of DNA sequences.
- Parameters:
tree- DNA sequence tree.dcalc- Object to calculate distances between DNA sequences.- Returns:
- Squared error.
-
solve
public static double solve(DnaSequenceTree tree, Distance dcalc)
Find the least squares branch lengths for the given DNA sequence tree. When squaredError() is called, every tip node in the tree must be associated with a DNA sequence of the same length.This method calculates the branch lengths such that the squared error, as defined in the squaredError() method, is minimized. Each node of the tree is associated with the calculated branch length. The squared error is returned.
This method uses a nonnegative linear least squares solver (class edu.rit.numeric.NonNegativeLeastSquares) to calculate the branch lengths. Thus, all branch lengths will be nonnegative; some may be 0.
- Parameters:
tree- DNA sequence tree.dcalc- Object to calculate distances between DNA sequences.- Returns:
- Squared error.
-
-
DMelt 3.0 © DataMelt by jWork.ORG