file = 'E:\Projects\8.ComBAT\ComBat399T\CC_IFS\Run2\K3_consensus_matrix2.txt'
% No iterative feature selection
%file = 'E:\Projects\8.ComBAT\ComBat399T\CC_IFS\K3_consensus_matrix0.txt'
n=399
A = zeros(n, n);
fid = fopen(file, 'r');
row = 1;
% Skip first line
tline = fgetl(fid);
for row=1:n,
tline = fgetl(fid);
LineWith1stCol = regexp(tline, '\t', 'split');
A(row, :) = str2double(LineWith1stCol(1,2:n+1));
end
cd('E:\MATLAB_lib')
v=getcoph(A)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [coph] = getcoph(a)
% a is the consensus matrix
[m,m]=size(a);
uvec=a(1,2:end);
for i=2:m-1;
uvec=[uvec a(i,i+1:end)]; %get upper diagonal elements of consensus
end
y=1-uvec; % consensus are similarities, convert to distances
z=linkage(y,'average'); % use average linkage
coph=cophenet(z,y);
end
No comments:
Post a Comment