Repository navigation
Expand file tree
/
Copy pathStep3a_log10_plotting_revised_script_vince.m
More file actions
83 lines (63 loc) · 2.89 KB
/
Copy pathStep3a_log10_plotting_revised_script_vince.m
File metadata and controls
83 lines (63 loc) · 2.89 KB
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
78
79
80
81
82
83
%% ============================================================
% Convert values from CoM matrices to Signed Log10 p-values - script from
% Vince after having some issues plotting the log plot, and replotting
% another bar plot with the -log10 signed results
%Use this script
%% ============================================================
% t-test on averaged CoM matrices
cd '/Users/amrithah/Desktop/CalhounLab/Dissertation/Projects/Chapter6_Paper_5_SPECT Template/Scripts/sc-ICA'
%% run t-tests on group differences and plot -log10 signed values as a bar plot
%And here is the code (assuming you have a 213x60 matrix of the loading parameters in a variable a):
hcind = 1:76;
szind = 77:213;
[h1 p1 ci1 stats1] = ttest2(a(hcind,:),a(szind,:));
bar(-log10(p1).*sign(stats1.tstat));
grid on;
sigcompspos = find((mafdr(p1)<.05).*(stats1.tstat>0)); %these match what's plotted in the colored bar plot
sigcompsneg = find((mafdr(p1)<.05).*(stats1.tstat<0)); %these match what's plotted in the colored bar plot
% Set x-axis tick labels
x = 1:68; % Label components for the tickmarks
xticks(x); % Set the tickmarks
hold off;
xlabel('NeuroMark SPECT Template Component #s (Components 1-68)')
ylabel('-log10 (p) signed values for all components')
ax = gca;
ax.FontSize = 13;
title('-log10 (p) signed t values: healthy-patient loading parameter group differences');
savefig('log10_barplot_ttest.fig');
movefile('*.fig', '/Users/amrithah/Desktop/CalhounLab/Dissertation/Projects/Chapter6_Paper_5_SPECT Template/Figures');
%% now plot and do t-tests for hc-sz averaged CoM matrices
%load variables from other step 2 script I created (look in old folder)
%% Flatten subject matrices (HC and SZ)
% all_matrices_hc: 68 x 68 x 76
% all_matrices_scz: 68 x 68 x 137
HC_flat = icatb_mat2vec(permute(all_matrices_hc, [3 1 2])); % 76 x 2278
SZ_flat = icatb_mat2vec(permute(all_matrices_scz, [3 1 2])); % 137 x 2278
% Run t-tests on flattened edges
[h2, p2, ci2, stats2] = ttest2(HC_flat, SZ_flat); % p2 is 1 x 2278
% Convert vectors back to 68x68 matrices
p2_mat = icatb_vec2mat(p2);
t2_mat = icatb_vec2mat(stats2.tstat);
% Compute signed -log10(p)
logt = -log10(p2_mat) .* t2_mat;
% FDR mask
sigmask = icatb_vec2mat(fdr_calc(p2) <= 0.05);
%%Apply mask only to upper triangle
n = size(sigmask,1);
ut = triu(true(n),1);
out_masked = logt;
out_masked(ut) = logt(ut) .* sigmask(ut);
% Plot masked result
figure;
imagesc(out_masked, [-8 8]);
axis image;
colormap(whitejet);
colorbar;
xticks(tickPositions);
yticks(tickPositions);
xticklabels(uniqueCats);
yticklabels(uniqueCats);
xtickangle(90);
title('-log10(p) signed t values: Group Differences (Healthy - Patients) FDR Corrected (q < 0.05)');
savefig('log10_FDR_masked_corrected_figure.fig');
movefile('*.fig', '/Users/amrithah/Desktop/CalhounLab/Dissertation/Projects/Chapter6_Paper_5_SPECT Template/Figures');