-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcorrmatrix_all.m
41 lines (31 loc) · 961 Bytes
/
corrmatrix_all.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
function MAT = corrmatrix_all(csvTable)
% Calculates correlation matrix from a csv file.
% input: string of csvTable name. csvTable contains columns with variables, with / without header.
% output: correlation matrix MAT. code written for the VAMP TRT paper
Table = readtable(csvTable);
matrix = table2array(Table);
[r,p] = corrcoef(matrix,'rows','pairwise');
figure; imagesc(p); %non corrected to multiple comparisons.
caxis([0 0.1]);
title('p values - not corrected')
% Plot
figure;
r = tril(r);
r(r==0)=1;
imagesc(r)
colormap(bone)
colorbar;
title('correlation matrix')
% Correct for multiple comparisons
[h, crit_p, adj_ci_cvrg, adj_p]= fdr_bh(p,0.05,'dep');
[x,y] = find(h);
hold on; scatter(x',y','ow','filled')
box off
hold on;
%add p values on top of the matrix
for i = 1:size(r,1)
for j = 1:size(r,2)
text(i,j,num2str(p(i,j)),'Color','white','FontSize',8)
hold on;
end
end