-
Notifications
You must be signed in to change notification settings - Fork 1
/
distance_to_average_genes.m
executable file
·41 lines (31 loc) · 1.46 KB
/
distance_to_average_genes.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
%computes the distance of each gene-time trajectory to the average gene-time
%trajectory:
function d = distance_to_average_genes (mat, average_trajectories)
%matrix = mat;
matrix=mat.submatrix;
NumberOfTimePoints = 6;
NumberOfRows = size(matrix,1);
NumberOfColumns = size(matrix,2);
NumberOfConditions = NumberOfRows/NumberOfTimePoints;
start=1;
for i=1:NumberOfConditions;
%get the trajectories:
current_gene_profile = matrix(start:start+NumberOfTimePoints-1,:);
pearson_matrix = current_gene_profile;
%append the average trajectory:
pearson_matrix(:,NumberOfColumns+1)=average_trajectories(:,i);
dist = squareform(Mypdist(pearson_matrix','correlation'));
%distances to the average are in the bottom row of the correlation
%matrix:
dist_to_average(i,:) = dist(NumberOfColumns+1,1:NumberOfColumns);
start=start+NumberOfTimePoints;
end
%d=dist_to_average;
d = struct('pearson_distance', {dist_to_average},'genenumbers', {mat.genenumbers},'conditionnumbers', {mat.conditionnumbers});
%old version:
%NumberOfColumns=size(matrix.submatrix,2);
%pearson_matrix = matrix.submatrix;
%pearson_matrix(:,NumberOfColumns+1) = average_matrix;
%dist = squareform(pdist(pearson_matrix','correlation'));
%this gives back the bottom row of the pairwise Pearson distance matrix:
%d = struct('pearson_distance', {dist(NumberOfColumns+1,1:NumberOfColumns)},'genenumbers', {matrix.genenumbers},'conditionnumbers', {matrix.conditionnumbers});