Added source Matlab code for reference
This commit is contained in:
parent
b8af977117
commit
b5d99903d2
186 changed files with 61405 additions and 1 deletions
31
matlab/graph/@phyTree/private/Opttf.m
Normal file
31
matlab/graph/@phyTree/private/Opttf.m
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
function tf = opttf(pval)
|
||||
%OPTTF determines whether input options are true or false
|
||||
|
||||
% Copyright 2003-2004 The MathWorks, Inc.
|
||||
% $Revision: 1.3.4.2 $ $Date: 2004/12/24 20:42:39 $
|
||||
|
||||
|
||||
if islogical(pval)
|
||||
tf = all(pval);
|
||||
return
|
||||
end
|
||||
if isnumeric(pval)
|
||||
tf = all(pval~=0);
|
||||
return
|
||||
end
|
||||
if ischar(pval)
|
||||
truevals = {'true','yes','on','t'};
|
||||
k = any(strcmpi(pval,truevals));
|
||||
if k
|
||||
tf = true;
|
||||
return
|
||||
end
|
||||
falsevals = {'false','no','off','f'};
|
||||
k = any(strcmpi(pval,falsevals));
|
||||
if k
|
||||
tf = false;
|
||||
return
|
||||
end
|
||||
end
|
||||
% return empty if unknown value
|
||||
tf = logical([]);
|
||||
39
matlab/graph/@phyTree/private/prettyOrder.m
Normal file
39
matlab/graph/@phyTree/private/prettyOrder.m
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
function tr = prettyOrder(tr)
|
||||
%PRETTYORDER Reorders the leaf nodes to avoid branch crossings.
|
||||
%
|
||||
% T2 = PRETTYORDER(T1) Reorders the leaf nodes in the phylogenetic tree
|
||||
% T1 such that the layout of the tree does not contain branch crossings.
|
||||
|
||||
% Copyright 2003-2005 The MathWorks, Inc.
|
||||
% $Revision: 1.1.8.1 $ $Author: batserve $ $Date: 2005/06/09 21:56:11 $
|
||||
|
||||
numBranches = size(tr.tree,1);
|
||||
numLeaves = numBranches + 1;
|
||||
numLabels = numBranches + numLeaves;
|
||||
|
||||
L = [ones(numLeaves,1); zeros(numBranches,1)];
|
||||
for ind = 1 : numBranches
|
||||
L(ind+numLeaves) = sum(L(tr.tree(ind,:)));
|
||||
end
|
||||
X = zeros(numLabels,1);
|
||||
for ind = numBranches:-1:1
|
||||
X(tr.tree(ind,:)) = tr.dist(tr.tree(ind,:))+X(ind+numLeaves);
|
||||
end
|
||||
Li = zeros(1,numLabels); Ls = Li;
|
||||
Ls(numLabels) = numLeaves;
|
||||
for ind = numBranches:-1:1
|
||||
Ls(tr.tree(ind,:)) = Ls(ind+numLeaves);
|
||||
Li(tr.tree(ind,:)) = Li(ind+numLeaves);
|
||||
if diff(X(tr.tree(ind,:)))>=0
|
||||
Ls(tr.tree(ind,1)) = Li(tr.tree(ind,1)) + L(tr.tree(ind,1));
|
||||
Li(tr.tree(ind,2)) = Ls(tr.tree(ind,2)) - L(tr.tree(ind,2));
|
||||
else
|
||||
Ls(tr.tree(ind,2)) = Li(tr.tree(ind,2)) + L(tr.tree(ind,2));
|
||||
Li(tr.tree(ind,1)) = Ls(tr.tree(ind,1)) - L(tr.tree(ind,1));
|
||||
end
|
||||
end
|
||||
|
||||
tr.names(Ls(1:numLeaves))=tr.names(1:numLeaves);
|
||||
tr.dist(Ls(1:numLeaves))=tr.dist(1:numLeaves);
|
||||
Ls(numLeaves+1:numLabels)=numLeaves+1:numLabels;
|
||||
tr.tree = Ls(tr.tree);
|
||||
Loading…
Add table
Add a link
Reference in a new issue