Skip to content

Commit e2f0cdf

Browse files
committed
Merge branch 'pearson' into main (2D analyses mainly)
2 parents 38dd084 + fde9e2d commit e2f0cdf

File tree

24 files changed

+345
-72
lines changed

24 files changed

+345
-72
lines changed

.github/workflows/cat_src.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v4
1414

1515
- name: Concatenate Files
1616
run: |

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
# Steps represent a sequence of tasks that will be executed as part of the job
2323
steps:
2424
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
25-
- uses: actions/checkout@v3
25+
- uses: actions/checkout@v4
2626

2727
# Sets up MATLAB on the GitHub Actions runner
2828
- name: Setup MATLAB

.github/workflows/draft-pdf.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
on: [push]
1+
on:
2+
push:
3+
branches: [ main ]
24

35
jobs:
46
paper:
57
runs-on: ubuntu-latest
68
name: Paper Draft
79
steps:
810
- name: Checkout
9-
uses: actions/checkout@v2
11+
uses: actions/checkout@v4
1012
- name: Build draft PDF
1113
uses: openjournals/openjournals-draft-action@master
1214
with:
1315
journal: joss
1416
# This should be the path to the paper within your repo.
1517
paper-path: paper/paper.md
1618
- name: Upload
17-
uses: actions/upload-artifact@v1
19+
uses: actions/upload-artifact@v4
1820
with:
1921
name: paper
2022
# This is the output path where Pandoc will write the compiled

MATLAB/+smi_cluster/@PairAnalysis/PairAnalysis.m

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@
3131

3232
n_ROIs_ALL = defineROIs2(Files1, Files2, Pixel2nm, Color, ROI_sizes, ...
3333
ResultsDir, RegistrationNeeded, RegistrationViaDC);
34-
[results_pcc, resultsRC_pcc, results_c, results_cs, results_ls, ...
35-
results_o1, results_o2] = ...
34+
[results_pcc, resultsRC_pcc, results_ss, results_c, results_cs, ...
35+
results_ls, results_o1, results_o2] = ...
3636
doAnalysis(n_ROIs, RoI, ROI_sizes, desc, particles, results_dir, ...
3737
options, PixelSize, HistBinSize, RmaxAxisLimit, E, minPts, ...
3838
PlotNonOverlap, Color)
39-
doBiStats(n_ROIs, RoI, desc, particles, results_dir, combined)
39+
results_bi = doBiStats(n_ROIs, RoI, desc, particles, results_dir, combined)
4040
results_c = doClustering(n_ROIs, RoI, desc, results_dir, plotting, ...
4141
PixelSize, E, minPts)
4242
results_cs = ...
@@ -47,7 +47,9 @@
4747
plotting, HistBinSize, RmaxAxisLimit)
4848
results_o = doOverlap(n_ROIs, RoI, results_c, l12, desc, particles, ...
4949
results_dir, PlotNonOverlap, Color, plotting)
50-
overlayBaGoLROIs(pathnameB, filesB, MAPNfile, ROI_sizes, SRImageZoom);
50+
results_ss = doSimpleStats(n_ROIs, RoI, PixelSize, desc, particles, ...
51+
results_dir)
52+
overlayBaGoLROIs(pathnameB, filesB, MAPNfile, ROI_sizes, SRImageZoom)
5153
doPlot2(n_ROIs, RoI, desc, particles, results_dir, Color, plotting)
5254

5355
% =============================================================================

MATLAB/+smi_cluster/@PairAnalysis/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ methods:
3030
Pair cross-correlation for each ROI and combined ROI
3131
- **[doPlot2](doPlot2.m)**:
3232
Plot 2D ROIs
33+
- **[doSimpleStats](doSimpleStats.m)**:
34+
Pearson's correlation and Manders' split coefficients for each ROI
3335
- **[overlayBaGoLROIs](overlayBaGoLROIs.m)**:
3436
overlay label 1 onto label 2 Gaussian images produced from the input ROI file
3537
names into appropriately named files

MATLAB/+smi_cluster/@PairAnalysis/defineROIs2.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,20 @@
101101
[n_ROIs, RoI, XYsize] = RT.getROI({SMD1, SMD2}, txt);
102102
n_ROIs_ALL = n_ROIs_ALL + n_ROIs;
103103

104-
% Redefine Pixel2nm for later use.
104+
% Redefine Pixel2nm for later use. This is done as original coordinates
105+
% are in pixels, but are now converted into nm for use in the RoI
106+
% structure, and uses such as clustering and related statistics.
107+
% This is only really needed for H-SET clustering. (2024/12/11)
105108
Pixel2nmSAVE = Pixel2nm;
106-
Pixel2nm = 1;
109+
% Pixel2nm = 1;
107110
saveas(gcf, fullfile(ResultsDir, sprintf('%s_ROIs.fig', desc)));
108111
print(fullfile(ResultsDir, sprintf('%s_ROIs.png', desc)), '-dpng');
109112
save(fullfile(ResultsDir, sprintf('%s_ROIs.mat', desc)), ...
110113
'Label1', 'Label2', 'Pixel2nm', 'XYsize', 'n_ROIs', 'RoI');
111114
close
112115
Pixel2nm = Pixel2nmSAVE;
113116
fid = fopen(fullfile(ResultsDir, sprintf('%s_ROIs.txt', desc)), 'w');
117+
fprintf(fid, 'ROI #, [xmin, xmax, ymin, ymax]\n');
114118
for i = 1 : n_ROIs
115119
fprintf(fid, '%d %7.3f %7.3f %7.3f %7.3f\n', ...
116120
i, RoI{i}.ROI ./ Pixel2nm);

MATLAB/+smi_cluster/@PairAnalysis/doAnalysis.m

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
function [results_pcc, resultsRC_pcc, results_c, results_cs, results_ls, ...
2-
results_o1, results_o2] = ...
1+
function [results_pcc, resultsRC_pcc, results_ss, results_c, results_cs, ...
2+
results_ls, results_o1, results_o2] = ...
33
doAnalysis(n_ROIs, RoI, ROI_sizes, desc, particles, results_dir, ...
44
options, PixelSize, HistBinSize, RmaxAxisLimit, E, minPts, ...
55
PlotNonOverlap, Color)
@@ -15,6 +15,8 @@
1515
% options string array of strings specifying analyses to be performed:
1616
% 'combined' the analysis is combined over all ROIs
1717
% 'plotting' plots are to be produced.
18+
% 'SimpleStats' Pearson's correlation and Manders' split
19+
% coefficients per ROI
1820
% 'BiStats' pairwise mutual distances and bivariate
1921
% Ripley's statistics for each ROI
2022
% 'Clustering' clusters for each label per ROI
@@ -41,7 +43,7 @@
4143
% desc_results.mat containing the various results_ cell arrays for one cell
4244
% Various results containers from the called helper functions in case the
4345
% user wants to have more details:
44-
% bivariate statistics
46+
% results_bi bivariate statistics
4547
% Also, figures *_ROI*_L1/2_pairwiseCDF/PDF compared to a random dist.
4648
% *_ROI*_L1,L2_pairwisePDF2/CDF2 2-label PDF/CDF
4749
% *_ROI*_bivripley bivariate Ripley
@@ -108,6 +110,8 @@
108110
plotting = true;
109111
end
110112

113+
results_ss = [];
114+
results_bi = [];
111115
results_pcc = [];
112116
resultsRC_pcc = [];
113117
results_c = [];
@@ -116,30 +120,42 @@
116120
results_o1 = [];
117121
results_o2 = [];
118122

123+
% Pearson's correlation and Manders' split coefficients per ROI.
124+
if any(contains(options, "SimpleStats"))
125+
results_ss = PA.doSimpleStats(n_ROIs, RoI, PixelSize, desc, particles, ...
126+
results_dir);
127+
fprintf("Done SimpleStats\n");
128+
end
129+
119130
% Pairwise mutual distances and bivariate Ripley's per ROI and the latter
120131
% also combined over all ROIs.
121132
if any(contains(options, "BiStats"))
122-
PA.doBiStats(n_ROIs, RoI, desc, particles, results_dir, combined);
133+
results_bi = PA.doBiStats(n_ROIs, RoI, desc, particles, results_dir, ...
134+
combined);
135+
fprintf("Done BiStats\n");
123136
end
124137

125138
% Clusters for each label per ROI.
126139
if any(contains(options, "Clustering"))
127-
results_c = PA.doClustering(n_ROIs, RoI, desc, results_dir, plotting,...
128-
PixelSize, E, minPts);
140+
results_c = PA.doClustering(n_ROIs, RoI, desc, results_dir, plotting,...
141+
PixelSize, E, minPts);
142+
fprintf("Done Clustering\n");
129143
end
130144

131145
% C2C nearest neighbor distances between label 1/label 2 clusters per ROI
132146
% and combined over all ROIs.
133147
if any(contains(options, "Clustering2"))
134148
results_cs = PA.doClusterSep2(n_ROIs, results_c, desc, particles, ...
135149
results_dir, plotting);
150+
fprintf("Done Clustering2\n");
136151
end
137152

138153
% Nearest neighbor distances between label 1/label 2 localizations per ROI
139154
% and combined over all ROIs.
140155
if any(contains(options, "LocSep2"))
141156
results_ls = PA.doLocSep2(n_ROIs, RoI, desc, particles, results_dir, ...
142157
plotting);
158+
fprintf("Done LocSep2\n");
143159
end
144160

145161
% Overlaps between label 1 clusters and label 2 localizations.
@@ -148,6 +164,7 @@
148164
results_o1 = PA.doOverlap(n_ROIs, RoI, results_c, l12, desc, ...
149165
particles, results_dir, PlotNonOverlap, ...
150166
Color, plotting);
167+
fprintf("Done Overlap1\n");
151168
end
152169

153170
% Overlaps between label 2 clusters and label 1 localizations.
@@ -156,23 +173,27 @@
156173
results_o2 = PA.doOverlap(n_ROIs, RoI, results_c, l12, desc, ...
157174
particles, results_dir, PlotNonOverlap, ...
158175
Color, plotting);
176+
fprintf("Done Overlap2\n");
159177
end
160178

161179
% Pair correlation per ROI and combined over all ROIs.
162180
if any(contains(options, "PairCorr"))
163181
[results_pcc, resultsRC_pcc] = ...
164182
PA.doPairCorr(n_ROIs, RoI, ROI_sizes, desc, results_dir, combined, ...
165183
plotting, HistBinSize, RmaxAxisLimit);
184+
fprintf("Done PairCorr\n");
166185
end
167186

168187
% 2D plot per ROI.
169188
if any(contains(options, "Plot2"))
170189
PA.doPlot2(n_ROIs, RoI, desc, particles, results_dir, Color, plotting);
190+
fprintf("Done Plot2\n");
171191
end
172192

173193
% Save results.
174194
save(fullfile(results_dir, sprintf('%s_results.mat', desc)), 'n_ROIs', ...
175-
'RoI', 'results_pcc', 'resultsRC_pcc', 'results_c', 'results_cs', ...
176-
'results_o1', 'results_o2');
195+
'RoI', 'results_ss', 'results_c', 'results_cs', 'results_ls', ...
196+
'results_o1', 'results_o2', 'results_pcc', 'resultsRC_pcc');
197+
fprintf("Done saving results\n");
177198

178199
end

MATLAB/+smi_cluster/@PairAnalysis/doBiStats.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
function doBiStats(n_ROIs, RoI, desc, particles, results_dir, combined)
1+
function results_bi = ...
2+
doBiStats(n_ROIs, RoI, desc, particles, results_dir, combined)
23
% Pairwise mutual distances and bivariate Ripley's statistics for each ROI.
34
%
45
% INPUTS:
@@ -17,11 +18,13 @@ function doBiStats(n_ROIs, RoI, desc, particles, results_dir, combined)
1718
% Created by
1819
% Michael J. Wester (2022)
1920

21+
results_bi = [];
22+
2023
SC = smi_cluster.StatisticsClustering();
2124
SC.ResultsDir = results_dir;
2225

2326
if ~combined
24-
results_birip = cell(n_ROIs, 1);
27+
%results_birip = cell(n_ROIs, 1);
2528
for i = 1 : n_ROIs
2629
SC.BaseName = sprintf('%s_ROI%d', desc, i);
2730
% Compare the actual distribution of nearest neighbor distances to a

MATLAB/+smi_cluster/@PairAnalysis/doClustering.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828
%minPts = 3; % minimum number of points in a cluster
2929

3030
c = smi_cluster.Clustering();
31-
c.PixelSize = PixelSize;
31+
% PixelSize is only used for H-SET clustering, and has been set to nm units
32+
% (Pixelsize = 1) earlier.
33+
% c.PixelSize = PixelSize;
34+
c.PixelSize = 1;
3235
c.Plotting = true;
3336
c.Alpha = 2;
3437
c.Valgorithm = 2;

MATLAB/+smi_cluster/@PairAnalysis/doPairCorr.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@
3535
pc = smi_cluster.PairCorrelation();
3636

3737
pc.ResultsDir = results_dir; % results directory
38-
pc.Fig_ext = 'png'; % figure extension
38+
if combined
39+
pc.Fig_ext = ''; % figure extension
40+
else
41+
pc.Fig_ext = 'png'; % figure extension
42+
end
3943
pc.Rmax_axis = RmaxAxisLimit; % sets plotting limit if > 0
4044
% Histogram bin size for pairwise correlation---this is the number of pixels
4145
% per bin over which correlation statistics are collected.
@@ -67,6 +71,7 @@
6771
fprintf('ROI combined\n\n');
6872
txt = sprintf('%s_RC', desc);
6973
pc.BaseName = txt;
74+
pc.Fig_ext = 'png'; % figure extension
7075
resultsRC_pcc = ...
7176
pc.pair_correlation_ROIcombined(2, n_ROIs, ROIs_combined, 1)
7277
end

0 commit comments

Comments
 (0)