-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconstants.m
213 lines (206 loc) · 12.7 KB
/
constants.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
% Shared constants that will be used across multiple files.
% Hard-coded directory names found here.
function [const, consts] = constants()
% Edit file paths
datadir = ''; hddir = ''; boxdir = '';
%% Annotation Helper
% for looking in file names
viruses = {'GFP', 'mC', 'mCh', 'CDKN2Ash', 'RFP', 'PGK_GFP', 'PGK_PIK3CA', ...
'PIK3CA', 'RAC1Q61L', 'PGK_AKT', 'AKT1', 'AKTE17K', 'E17K', ...
'KRAS', 'PTENsh', 'YAP', 'MYC', 'ITGB1', 'B1V737N', 'ITGB1V737N', ...
'CCND1' 'CDKN2Ash_MYC', 'ERBB2', 'Twist', 'PTENsh2', 'GATA3sh', 'GATA3', ...
'H1047R', 'E545K', 'CTRLsh', 'RB1sh', 'MAP2K4sh', 'MAP3K1sh', 'TP53', ...
'CDH1sh','CTNND1sh', 'TLN1sh','notH1047R', 'untrL+mChM', ...
'GFP_puro', 'GFP_TLN1sh1puro', 'GFP_TLN1sh2puro', ...
'GFP_CTNND1sh1puro', 'GFP_TP63sh1puro', ...
'H1047R_puro', 'H1047R_TLN1sh1puro', 'H1047R_TLN1sh2puro', ...
'H1047R_CTNND1sh1puro', 'H1047R_TP63sh1puro', ...
'GFP_CTNND1sh1puroM+mCh_puroL', 'GFP_TLN1sh1puroM+mCh_puroL', ...
'ITGB1V737NL+GFPM', 'mCh_CTNND1sh1puro', ...
'GFP_puroL+mCh_CTNND1sh1M', 'H1047R_puroL+mCh_CTNND1sh1M', ...
'H1047RL+mCh_CTNND1sh1M', 'GFPL+mCh_CTNND1sh1M', ...
'CTNND1sh1M+mChL','TLN1sh1','CTNND1sh1', 'TLN1shM+mChL', ...
'TAp63','delNp63','mChL+TLN1sh1M','mChL+CTNND1sh1M','GFPLO+mChMO','mChLO+GFPMO'};
coculture = {'GLC_GFPL+mChM', 'H1047RL+GC_mChM', 'untrL+PMC_mChM', ...
'H1047RL+PLC_mChM', 'H1047RL+PMC_mChM', 'H1047RL+mChM', ...
'PLC_H1047RL+mChM', 'GLC_untrL+mChM', 'GMC_untrL+mChM', ...
'PLC_untrL+mChM', 'PMC_untrL+mChM', 'untrL+GC_mChM', ...
'untrL+PLC_mChM', 'GLC_GFPL+GLC_mChM', 'PLC_H1047RL+PLC_mChM'};
LEPonly = {'GFP_puroL+mCh_puroL', 'mChL+H1047RL', 'mChL+GFPL', 'mChL+GFP_puroL', ...
'mChL+GFP_TLN1sh1puroL', 'GFP_TLN1sh1puroL+mCh_puroL', ...
'GFP_CTNND1sh1puroL+mCh_puroL', 'ITGB1V737NL+GFPL','GFPLO+mChLO'};
MEPonly = {'GFP_puroM+mCh_puroM','mChM+GFP_puroM', ...
'mChM+H1047RM','mChM+GFPM','TLN1shM+mChM','CTNND1shM+mChM', ...
'mChM+GFP_TLN1sh1puroM', 'GFP_TLN1sh1puroM+mCh_puroM', ...
'mChM+GFP_CTNND1sh1M', 'mCh_CTNND1sh1M+GFPM', 'mCh_CTNND1sh1puroM+GFP_puroM', ...
'GFP_TLN1sh2puroM+mCh_puroM', 'CTNND1sh1M+mChM', ...
'GFPMO+mChMO'}; % O means pre-aggregated organoid
viruses = [viruses, coculture, LEPonly, MEPonly];
% these names will get merged into the first name in the set
degenerates = {{'ITGB1V737N','B1V737N'}, {'GFP', 'mCh'}, ...
{'GFPM+mChM','mChM+GFPM'}, {'GFPL+mChL','mChL+GFPL'}, ...
{'GFPLO+mChMO','GFPMO+mChLO'}, ...
{'GFP_puroL+mCh_puroL','mCh_puroL+GFP_puroL','mChL+GFP_puroL'}, ...
{'GFP_puroM+mCh_puroM','mCh_puroM+GFP_puroM','mChM+GFP_puroM'}, ...
{'TLN1sh1L+mChL','TLN1shL+mChL'}, ...
{'CTNND1sh1L+mChL','CTNND1shL+mChL'}, ...
{'GFP_TLN1sh1puroL+mCh_puroL','mCh_puroL+GFP_TLN1sh1puroL', ...
'mChL+GFP_TLN1sh1puroL'}, ...
{'GFP_CTNND1sh1puroL+mCh_puroL','mCh_puroL+GFP_CTNND1sh1puroL'}, ...
{'GFP_CTNND1sh1puro','mCh_CTNND1sh1puro'}, ...
{'CTNND1sh1M+mChM', 'GFP_CTNND1sh1M+mChM', 'CTNND1shM+mChM', ...
'mCh_CTNND1sh1M+GFPM','mChM+GFP_CTNND1sh1M'}, ...
{'TLN1sh1M+mChM','TLNshM+mChM','TLN1shM+mChM'}, ...
{'GFP_TLN1sh1puroM+mCh_puroM','mCh_puroM+GFP_TLN1sh1puroM', ...
'mChM+GFP_TLN1sh1puroM'}, ...
{'GFP_CTNND1sh1puroM+mCh_puroM','mCh_puroM+GFP_CTNND1sh1puroM', ...
'GFP_puroM+mCh_CTNND1sh1puroM','mCh_CTNND1sh1puroM+GFP_puroM', ...
'GFP_CTNNDsh1puroM+mCh_puroM','GFP_CTNND1sh1puroM+mChM'}, ...
{'GFPL+TLN1sh1M','mChL+TLN1sh1M','mChL+TLN1shM','TLN1shM+mChL','TLN1sh1M+mChL'}, ...
{'mChL+CTNND1sh1M','mChL+CTNND1shM','CTNND1shM+mChL','CTNND1sh1M+mChL'}, ...
{'GFPL+CTNND1sh1M', 'GFPL+mCh_CTNND1sh1M'}, ...
{'GFP_puroL+mCh_TLN1sh1puroM','mCh_puroL+GFP_TLN1sh1puroM', ...
'GFP_TLN1sh1puroM+mCh_puroL','mCh_TLN1sh1puroM+GFP_puroL'}, ...
{'GFP_puroL+mCh_CTNND1sh1puroM','mCh_puroL+GFP_CTNND1sh1puroM', ...
'mCh_CTNND1sh1puroM+GFP_puroL','GFP_CTNND1sh1puroM+mCh_puroL', ...
'GFP_puroL+mCh_CTNND1sh1M'}, ...
{'GFP_TLN1sh2puroM+mCh_puroM'}, ...
{'H1047RM+mChM','mChM+H1047RM'}, ...
{'H1047RM+CTNND1sh1M', 'mCh_CTNND1sh1M+H1047RM'}, ...
{'H1047RL+mChL','mChL+H1047RL'}, ...
{'H1047RL+CTNND1sh1M','H1047RL+mCh_CTNND1sh1M','H1047R_puroL+mCh_CTNND1sh1puroM','H1047R_puroL+mCh_CTNND1sh1M'}, ...
{'TLN1sh1','TLN1sh'},{'CTNND1sh1','CTNND1sh'}...
};
% ensure that 'viruses' includes everything
deg_merged = [degenerates{:}];
viruses = [viruses, deg_merged{~ismember(deg_merged, viruses)}];
all_strains = {'240L+353P', '240L', ...
'029', '059L', '071C', '101P', '112R', '122L', '172L', '191L', '210C', '211C', '215C', ...
'237', '249P', '353P', '429ER', '633P', '184', ...
'mMEC', 'HEK293T', 'MCF10A', 'MCF7'};
all_dates = {'2016-05-22', '2016-06-03', '2016-06-04', '2016-07-13', '2016-07-25', '2016-09-22', '2016-09-29', ...
'2017-01-14', '2017-01-31', '2017-02-07', '2017-03-10', '2017-04-17', '2017-05-05', ...
'2017-05-26', '2017-05-31', '2017-06-11', '2017-06-18', '2017-06-28', '2017-08-30', ...
'2017-09-15', '2017-09-19', '2017-09-23', '2017-10-10', '2017-10-25', '2017-11-03', ...
'2017-11-22', '2017-12-19', '2018-01-28', '2018-02-24', '2018-03-09', '2018-03-10', ...
'2018-03-11', '2018-03-23', '2018-03-24', '2018-03-25', '2018-04-11', '2018-05-22', ...
'2018-06-22', '2018-07-05', '2018-07-10', '2018-07-11', '2018-07-19', '2018-07-25', ...
'2018-08-01', '2018-09-04', '2018-09-11', '2018-09-18', '2018-10-16', '2018-10-23', ...
'2018-12-02', '2019-02-05', '2019-02-11', '2019-02-19', '2019-02-26', '2019-03-12', ...
'2019-03-19', '2019-04-02', '2019-04-16', '2019-04-23', '2019-05-14', '2019-05-21', ...
'2019-06-18', '2019-06-26', '2019-07-01', '2019-07-03', '2019-08-16', '2019-08-29', ...
'2019-08-29', '2019-09-03', '2019-09-09', '2019-09-10', '2019-09-17', '2019-10-15', ...
'2019-10-22', '2019-10-29', '2019-11-12', '2019-11-19', '2019-11-20', '2019-11-25', ...
'2020-01-14', '2020-01-15', '2020-02-04', '2020-02-11', '2020-06-01', '2020-06-02', '2017', ...
'2020-06-16', '2020-06-23', '2020-06-30', '2020-07-14', '2020-07-16', '2020-07-21', ...
'2020-08-04', '2020-08-25', '2020-09-01', '2020-10-06', '2020-10-13', '2020-10-27', ...
'2020-10-28', '2020-11-09', '2020-11-26', '2020-11-30', '2020-12-23', '2020-12-29', ...
'2021-01-13', '2021-02-22', '2021-03-09', '2021-03-16', '2021-03-23', '2021-04-13',...
'2021-06-15', '2021-06-22', '2021-08-06', '2021-10-25', '2021-11-04','2021-12-29',...
'2022-02-09', '2022-03-28', '2022-06-20', '2022-08-01', '2022-09-06', '2023-02-21',...
'2023-02-24', '2023-06-13', '2023-06-15'};
all_timepts = {'1h', '7h', '12h','13h', '14h', '15h', '16h', '17h', '18h', ...
'19h', '20h', '22h', '24h', '26h', '34h', '40h', ...
'44h', '45h', '46h', '48h', 'day2', '1d', '2d', 'd2', '3d', '6d', ...
'7d', '1w', '8d', '14d', '9d', '10d', '1d', '96h', '72h', '65h', '66h'};
if exist(hddir, 'dir')
czidir = fullfile(hddir, 'organization');
else
czidir = fullfile(boxdir, 'Microscopy', 'organization');
end
metadatadir = fullfile(datadir, 'Metadata');
csvfile = fullfile(metadatadir, 'dir_info.csv');
% dir_csv_reader(fullfile(metadatadir, 'dir_info.csv'));
% original annotations are saved here
classedfile = fullfile(metadatadir, 'classed_raw.csv');
% written to by process_classed.m: extracts parameters from file name
processedfile = fullfile(metadatadir, 'classed_processed.csv');
% based on original annotations, slice_imgs.m makes slices and stores info here
slicedatafile = fullfile(metadatadir, 'classed_sliced.csv');
% czi pixel sizes
sizefile = fullfile(metadatadir, 'px_sizes.csv');
%% File Headers
classed_header = {'r', 'folder', 'name', ...
'outcomes', 'lumens', 'center', 'imgtype'};
classed_format = '%d,%s,%s,%s,%s,%s,%s';
processed_header = {'r', 'folder', 'slicedir', 'name', 'imgtype', ...
'outcome', 'lumen', 'center', 'chL', 'chM', 'date', ...
'timepoint', 'strain', 'strainM', 'strainL', ...
'confluence', 'ECM', 'drug', 'virus', 'FDG', 'CD10'};
processed_format = ['%d', repmat(',%s',1,length(processed_header)-1)];
slice_header = [processed_header, {'imfile', 'imfilename'}];
slice_format = [processed_format, ',%s,%s'];
%% Pixel Classification
% pixel types based on category order in Ilastik
pxtype_ilastik = struct('M', 1, 'L', 2, 'E', 3, 'H', 4);
cmap_ilastik = zeros(4,3);
% colormap selected from our figures in Illustrator
cmap_ilastik(pxtype_ilastik.M,:) = [240, 4, 127] / 255;
cmap_ilastik(pxtype_ilastik.L,:) = [13, 176, 75] / 255;
cmap_ilastik(pxtype_ilastik.E,:) = [0 0 0];
cmap_ilastik(pxtype_ilastik.H,:) = [104 216 234] / 255;
% double-mask pixel types for all other processing
pxtype_dmask = struct('E', 0, 'M', 1, 'L', 2);
cmap_dmask = zeros(3,3);
% cannot zero-index
cmap_dmask(pxtype_dmask.E+1,:) = [0 0 0];
cmap_dmask(pxtype_dmask.M+1,:) = [240, 4, 127] / 255;
cmap_dmask(pxtype_dmask.L+1,:) = [13, 176, 75] / 255;
% imgtypes = {'LSM_FP', 'CT', 'LSM_CT', 'LSM_K'};
slicedir = fullfile(datadir, 'Slices');
% raw slices produced by slice_imgs
rawslicedir = fullfile(slicedir, 'raw');
%% Quantification
quantadjfile = fullfile(datadir, 'Results', 'quantifadj.csv');
Lfracsfile = fullfile(datadir, 'Results', 'LEPfracs.csv');
quantslicedir = fullfile(slicedir, 'etc', 'quantification');
% full names of metrics
fullmetrics = {'MEP Fraction', 'Pixels', 'Circularity', 'EqDiameter', ...
'MEP Solidity', 'LEP Solidity', 'Blob Size', ...
'Heterotypic Perimeter', 'Heterotypic Score', ...
'Edge LEP Fraction', 'Rim LEP Fraction', ...
'Outer LEP Fraction', 'Outer LEP Score', ...
'Inner LEP Fraction', 'Inner LEP Score', ...
'Correctness', 'Intercentroid', 'Bounding Box'};
% have to be valid variable names
metrics = {'MEP_Fraction', 'Pixels', 'Circularity', 'Diameter', ...
'MEP_Solidity', 'LEP_Solidity', 'Blob_Size', ...
'Heterotypic_Perimeter', 'Heterotypic_Score', ...
'Edge_LEP_Fraction', 'Rim_LEP_Fraction', ...
'Outer_LEP_Fraction', 'Outer_LEP_Score', ...
'Inner_LEP_Fraction', 'Inner_LEP_Score', ...
'Correctness', 'Intercentroid', 'Bounding_Box'};
n_metrics = length(metrics);
%% Stuff all the constants into a struct and return it (one argument is a cell array of cell arrays)
const = struct( ...
'czidir', czidir, ...
'datadir', datadir, ...
'metadatadir', metadatadir, ...
'csvfile', csvfile, ...
'classedfile', classedfile, ...
'processedfile', processedfile, ...
'slicedatafile', slicedatafile, ...
'sizefile', sizefile, ...
'classed_format', classed_format, ...
'processed_format', processed_format, ...
'slice_format', slice_format, ...
'pxtype_ilastik', pxtype_ilastik, ...
'cmap_ilastik', cmap_ilastik, ...
'pxtype_dmask', pxtype_dmask, ...
'cmap_dmask', cmap_dmask, ...
'slicedir', slicedir, ...
'rawslicedir', rawslicedir, ...
'n_metrics', n_metrics, ...
'quantadjfile', quantadjfile, ...
'Lfracsfile', Lfracsfile, ...
'quantslicedir', quantslicedir);
consts = { {'index', ...
'viruses', 'degenerates', 'LEPonly', 'MEPonly', ...
'all_strains', 'all_dates', 'all_timepts', ...
'classed_header', 'processed_header', 'slice_header', ...
'fullmetrics', 'metrics'}, ...
viruses, degenerates, LEPonly, MEPonly, ...
all_strains, all_dates, all_timepts, ...
classed_header, processed_header, slice_header, ...
fullmetrics, metrics};
end