-
Notifications
You must be signed in to change notification settings - Fork 1
/
recalculateConditions.m
executable file
·77 lines (65 loc) · 2.57 KB
/
recalculateConditions.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
function results = recalculateConditions(dataset, results, condition_threshold, moduletype, texthandle)
counter = 0;
%for i=1:length(dataset.conditions)
% allconditions{i} = dataset.submatrix(:,counter+1:counter+length(dataset.timepoints{i}));
% counter = counter+length(dataset.timepoints{i});
%end
%Reducing the dataset to the contained conditions
timesteps = cell(length(dataset.conditions),1);
count = 1;
%Extracting all time-points from all conditions contained in the module
for j=1:length(dataset.conditions)
timesteps{j} = [count:count+length(dataset.timepoints{j})-1];
count = count+length(dataset.timepoints{j});
end
%allconditions
conditions = 1:length(dataset.conditions);
for i = 1 : size(results,1)
%i = minimal_size;
%BelowThreshold = GetAllBelow(results, condition_threshold, minimal_size);
%Reducing the dataset to the contained conditions
%timesteps = [];
count = 1;
%for j=conditions
% timesteps = [timesteps, count:count+sum(dataset.timepoints{j})-1];
% count = count+sum(dataset.timepoints{j});
%end
%timesteps
%Calculate centroid
%genes = size(dataset.submatrix(results{i,1},:),1);
%Recalculate centroid
if strcmp('coherent',moduletype)
[centroidco, time] = calculateCentroidCoherent(dataset, results(i,:));
timepointsco = length(dataset.timepoints{1});
centroidnew = zeros(1, length(conditions)*length(dataset.timepoints{1}));
countcent = 1;
centroidco = centroidco(1:timepointsco);
for j=1:length(conditions)
centroidnew(countcent:countcent+timepointsco-1) = centroidco;
countcent = countcent + timepointsco;
end
else
%Calculate aligned conditions
centroidnew = mean(dataset.submatrix(results{i,1},:));
end
results{i,3} = centroidnew;
end
%Stored the correlations of the conditions
corrcond = zeros(length(results), length(dataset.conditions));
countcond = 1;
for j=1:length(dataset.conditions)
points = length(dataset.timepoints{j});
for i=1:size(results,1)
centroid = results{i,3};
centroid = centroid(countcond:countcond+points-1);
corrcond(i,j) = mean( corr( dataset.submatrix(results{i,1},timesteps{j})', centroid'));
end
countcond = countcond + points;
if nargin > 4
set(texthandle, 'String', strcat('Recalculating conditions ' , '(', int2str(j),',',int2str(length(dataset.conditions)) , ')'));
end
pause(0.01);
end
for i=1:size(results,1)
results{i,2} = find(corrcond(i,:) > 1-condition_threshold);
end