
% read data in matrix format
A = textread('cho_cell_cycle_ex90_100_data.txt');

% normalize X
X = A - repmat(mean(A,2),1,size(A,2));
X = X ./ (repmat(std(X,[],2),1,size(X,2))+eps);



opts = statset('Display','final');
[idx,ctrs] = kmeans(X,50,...
                    'Distance','sqEuclidean',...
                    'Replicates',5,...
                    'Options',opts);




XX = [];

perm_index = [];
N = max(idx);
for k=1:N,
  perm_index = [perm_index; find(idx==k)];

  XX = [XX; X(find(idx==k),:)];
  XX = [XX; -2*ones(20,size(X,2))];
end



figure(1);
imagesc(X);

figure(2);
imagesc(X(perm_index,:));

figure(3);
imagesc(XX);

