Skip to content

Commit 333d1d0

Browse files
[NET-275] Colorscale and edit box (#112)
* fixing of scaling so that colorbar and text edit match * Exported mlapp files --------- Co-authored-by: Github Action <action@github.com>
1 parent dc4837b commit 333d1d0

6 files changed

Lines changed: 40 additions & 34 deletions

File tree

+nla/+gfx/+plots/MatrixPlot.m

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
plot_scale % The scale and values being plotted (Linear, log, -log10, p-value, statistic p-value)
3535
current_settings % the settings for the plot (upper, lower, scale)
3636
display_legend
37+
p_value_max
3738
end
3839

3940
properties (Dependent)
@@ -111,11 +112,12 @@
111112
addParameter(matrix_input_parser, 'y_position', 0, validNumberInput);
112113
addParameter(matrix_input_parser, 'discrete_colorbar', false, @islogical);
113114
addParameter(matrix_input_parser, 'plot_scale', nla.gfx.ProbPlotMethod.DEFAULT);
115+
addParameter(matrix_input_parser, 'p_value_max', 0.05)
114116

115117
parse(matrix_input_parser, figure, name, matrix, networks, figure_size, varargin{:});
116118
properties = {'figure', 'name', 'matrix', 'networks', 'figure_size', 'network_clicked_callback',...
117119
'marked_networks', 'figure_margins', 'draw_legend', 'draw_colorbar', 'color_map', 'lower_limit',...
118-
'upper_limit', 'x_position', 'y_position', 'discrete_colorbar', 'plot_scale'};
120+
'upper_limit', 'x_position', 'y_position', 'discrete_colorbar', 'plot_scale', 'p_value_max'};
119121
for property = properties
120122
obj.(property{1}) = matrix_input_parser.Results.(property{1});
121123
if property{1} == "marked_networks"
@@ -179,7 +181,7 @@ function displayImage(obj)
179181

180182
end
181183

182-
function applyScale(obj, ~, ~, upper_limit_box, lower_limit_box, scale, color_map_select)
184+
function applyScale(obj, ~, ~, upper_limit_box, lower_limit_box, old_scale, new_scale, color_map_select)
183185
% This callback gets the colormap/scale and then applies the new bounds to the data.
184186
% Only works with APPLY button, will not work with only CLOSE
185187

@@ -197,49 +199,50 @@ function applyScale(obj, ~, ~, upper_limit_box, lower_limit_box, scale, color_ma
197199
end
198200

199201
if isnumeric(upper_limit_box)
200-
upper_limit = upper_limit_box;
202+
obj.upper_limit = upper_limit_box;
201203
else
202-
upper_limit = get(upper_limit_box, "String");
204+
obj.upper_limit = get(upper_limit_box, "String");
203205
end
204206

205207
if isnumeric(lower_limit_box)
206-
lower_limit = lower_limit_box;
208+
obj.lower_limit = lower_limit_box;
207209
else
208-
lower_limit = get(lower_limit_box, "String");
210+
obj.lower_limit = get(lower_limit_box, "String");
209211
end
210212

211213
if ~isstring(obj.plot_scale)
212214
obj.plot_scale = char(obj.plot_scale);
213215
end
214216

215217
obj.matrix = obj.original_matrix;
216-
if ismember(obj.plot_scale, ["nla.ProbPlotMethod.NEGATIVE_LOG_10", "nla.ProbPlotMethod.NEGATIVE_LOG_STATISTIC"]) &&...
217-
ismember(scale, ["nla.ProbPlotMethod.DEFAULT", "nla.ProbPlotMethod.LOG"])
218-
obj.matrix.v = 10.^(-obj.matrix.v);
219-
220-
elseif ~ismember(obj.plot_scale, ["nla.ProbPlotMethod.NEGATIVE_LOG_10", "nla.ProbPlotMethod.NEGATIVE_LOG_STATISTIC"]) &&...
221-
~ismember(scale, ["nla.ProbPlotMethod.DEFAULT", "nla.ProbPlotMethod.LOG"])
218+
if ismember(old_scale, ["nla.gfx.ProbPlotMethod.NEGATIVE_LOG_10", "nla.gfx.ProbPlotMethod.NEGATIVE_LOG_STATISTIC"]) &&...
219+
ismember(new_scale, ["nla.gfx.ProbPlotMethod.DEFAULT", "nla.gfx.ProbPlotMethod.LOG"])
220+
% obj.matrix.v = 10.^(-obj.matrix.v);
221+
obj.lower_limit = 0;
222+
obj.upper_limit = obj.p_value_max;
223+
elseif ~ismember(old_scale, ["nla.gfx.ProbPlotMethod.NEGATIVE_LOG_10", "nla.gfx.ProbPlotMethod.NEGATIVE_LOG_STATISTIC"]) &&...
224+
~ismember(new_scale, ["nla.gfx.ProbPlotMethod.DEFAULT", "nla.gfx.ProbPlotMethod.LOG"])
222225
obj.matrix.v = -log10(obj.matrix.v);
223-
lower_limit = 0;
224-
upper_limit = 2;
226+
obj.lower_limit = 0;
227+
obj.upper_limit = 2;
225228
end
226229

227230
discrete_colors = NetworkResultPlotParameter().default_discrete_colors;
228231

229-
if scale == "nla.ProbPlotMethod.DEFAULT"
230-
new_color_map = NetworkResultPlotParameter.getColormap(discrete_colors, upper_limit, color_map);
231-
obj.plot_scale = scale;
232-
elseif scale == "nla.ProbPlotMethod.LOG"
233-
new_color_map = NetworkResultPlotParameter.getLogColormap(discrete_colors, obj.matrix, upper_limit, color_map);
234-
obj.plot_scale = scale;
232+
if new_scale == "nla.gfx.ProbPlotMethod.DEFAULT"
233+
new_color_map = NetworkResultPlotParameter.getColormap(discrete_colors, obj.upper_limit, color_map);
234+
obj.plot_scale = new_scale;
235+
elseif new_scale == "nla.gfx.ProbPlotMethod.LOG"
236+
new_color_map = NetworkResultPlotParameter.getLogColormap(discrete_colors, obj.matrix, obj.upper_limit, color_map);
237+
obj.plot_scale = new_scale;
235238
else
236239
color_map_name = str2func(lower(color_map));
237240
new_color_map = color_map_name(discrete_colors);
238-
obj.plot_scale = "nla.ProbPlotMethod.NEGATIVE_LOG_10";
241+
obj.plot_scale = "nla.gfx.ProbPlotMethod.NEGATIVE_LOG_10";
239242
end
240243
obj.color_map = new_color_map;
241-
obj.embiggenMatrix(lower_limit, upper_limit);
242-
obj.createColorbar(lower_limit, upper_limit);
244+
obj.embiggenMatrix(obj.lower_limit, obj.upper_limit);
245+
obj.createColorbar(obj.lower_limit, obj.upper_limit);
243246
end
244247

245248
function createLegend(obj)
206 Bytes
Binary file not shown.

+nla/+net/+result/+plot/NetworkTestPlotApp_exported.m

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
title = ""
5252
chord_type = "nla.PlotType.CHORD"
5353
settings = false
54-
old_data = false
54+
old_data = false % data from previous output structures. Not networktestresult object
5555
end
5656

5757
properties (Dependent)
@@ -105,6 +105,7 @@ function getPlotTitle(app)
105105
app.settings = struct();
106106
app.settings.upperLimit = app.UpperLimitEditField.Value;
107107
app.settings.lowerLimit = app.LowerLimitEditField.Value;
108+
app.settings.prevPlotScale = app.matrix_plot.plot_scale;
108109
app.settings.plotScale = app.PlotScaleDropDown.Value;
109110
app.settings.pValueThreshold = app.pvalueThresholdEditField.Value;
110111
app.settings.cohensD = app.CohensDThresholdCheckBox.Value;
@@ -153,16 +154,16 @@ function getPlotTitle(app)
153154
app.test_method, probability, sprintf(app.title), mcc, app.createSignificanceFilter(),...
154155
app.RankingDropDown.Value);
155156

156-
if ~isequal(app.UpperLimitEditField.Value, 0.3) && ~isequal(app.LowerLimitEditField.Value, 0.3)
157-
probability_parameters.p_value_plot_max = app.UpperLimitEditField.Value;
158-
end
157+
% if ~isequal(app.UpperLimitEditField.Value, 0.3) && ~isequal(app.LowerLimitEditField.Value, 0.3)
158+
probability_parameters.p_value_plot_max = app.pvalueThresholdEditField.Value;
159+
% end
159160

160161
plotter = nla.net.result.plot.PermutationTestPlotter(app.edge_test_options.net_atlas);
161162
[width, height, app.matrix_plot] = plotter.plotProbability(app.Panel_2, probability_parameters, nla.inputField.LABEL_GAP, -50);
162163
if ~isequal(app.settings, false)
163-
app.UpperLimitEditField.Value = app.settings.upperLimit;
164-
app.LowerLimitEditField.Value = app.settings.lowerLimit;
165164
app.PlotScaleDropDown.Value = app.settings.plotScale;
165+
app.UpperLimitEditField.Value = app.settings.upperLimit;
166+
app.LowerLimitEditField.Value = app.settings.lowerLimit;
166167
app.pvalueThresholdEditField.Value = app.settings.pValueThreshold;
167168
app.CohensDThresholdCheckBox.Value = app.settings.cohensD;
168169
app.CohensDThresholdEditField.Value = app.settings.cohensDValue;
@@ -201,7 +202,9 @@ function getPlotTitle(app)
201202
function applyScaleChange(app)
202203
progress_bar = uiprogressdlg(app.UIFigure, "Title", "Please Wait", "Message", "Applying Changes...", "Indeterminate", true);
203204
progress_bar.Message = "Chaning scale of existing TriMatrix...";
204-
app.matrix_plot.applyScale(false, false, app.UpperLimitEditField.Value, app.LowerLimitEditField.Value, app.PlotScaleDropDown.Value, app.ColormapDropDown.Value)
205+
app.matrix_plot.applyScale(false, false, app.UpperLimitEditField.Value, app.LowerLimitEditField.Value, app.settings.prevPlotScale, app.PlotScaleDropDown.Value, app.ColormapDropDown.Value)
206+
app.UpperLimitEditField.Value = app.matrix_plot.upper_limit;
207+
app.LowerLimitEditField.Value = app.matrix_plot.lower_limit;
205208
end
206209

207210
function hideCohensDControls(app)
@@ -409,10 +412,10 @@ function createComponents(app)
409412
% Create PlotScaleDropDown
410413
app.PlotScaleDropDown = uidropdown(app.Panel);
411414
app.PlotScaleDropDown.Items = {'Linear', 'Log', 'Negative Log10'};
412-
app.PlotScaleDropDown.ItemsData = {'nla.ProbPlotMethod.DEFAULT', 'nla.ProbPlotMethod.LOG', 'nla.ProbPlotMethod.NEGATIVE_LOG_10'};
415+
app.PlotScaleDropDown.ItemsData = {'nla.gfx.ProbPlotMethod.DEFAULT', 'nla.gfx.ProbPlotMethod.LOG', 'nla.gfx.ProbPlotMethod.NEGATIVE_LOG_10'};
413416
app.PlotScaleDropDown.ValueChangedFcn = createCallbackFcn(app, @PlotScaleValueChanged, true);
414417
app.PlotScaleDropDown.Position = [78 297 100 22];
415-
app.PlotScaleDropDown.Value = 'nla.ProbPlotMethod.DEFAULT';
418+
app.PlotScaleDropDown.Value = 'nla.gfx.ProbPlotMethod.DEFAULT';
416419

417420
% Create RankingDropDownLabel
418421
app.RankingDropDownLabel = uilabel(app.Panel);

+nla/+net/+result/+plot/PermutationTestPlotter.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
matrix_plot = nla.gfx.plots.MatrixPlot(plot_figure, plot_label, statistic_matrix, obj.network_atlas.nets,...
2424
nla.gfx.FigSize.SMALL, 'x_position', x_coordinate, 'y_position', y_coordinate, 'lower_limit', 0,...
2525
'upper_limit', p_value_max, 'color_map', color_map, 'network_clicked_callback', clickCallback,...
26-
'marked_networks', significance_plot, 'plot_scale', plot_scale);
26+
'marked_networks', significance_plot, 'plot_scale', plot_scale, 'p_value_max', p_value_max);
2727
matrix_plot.displayImage();
2828
w = matrix_plot.image_dimensions("image_width");
2929
h = matrix_plot.image_dimensions("image_height");

NLAResult.mlapp

-84 Bytes
Binary file not shown.

NLAResult_exported.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
prog_bar = false
2929
net_adjustable_fields
3030
cur_iter = 0
31-
old_data = false
31+
old_data = false % data from old result objects, not NetworkTestResult
3232
end
3333

3434
methods (Access = private)

0 commit comments

Comments
 (0)