Skip to content

Commit

Permalink
captions now include custom figure styles
Browse files Browse the repository at this point in the history
  • Loading branch information
msrosenberg committed Sep 9, 2022
1 parent 71b170a commit 5c4f7ae
Show file tree
Hide file tree
Showing 5 changed files with 240 additions and 140 deletions.
20 changes: 20 additions & 0 deletions resources/metawin_help.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ <h1>Help Table of Contents</h1>
<li><a href="#graph_tab">Graph Tab</a>
<ul>
<li><a href="#graph_edit">Editing Figures</a></li>
<li><a href="#captions_note">A Note on Captions</a></li>
</ul>
</li>
<li><a href="#phylogeny_tab">Phylogeny Tab</a></li>
Expand Down Expand Up @@ -424,6 +425,25 @@ <h4 id="markers_styles">Markers</h4>
the chosen marker is a filled marker. Unfilled markers will turn invisible if the no fill option is
checked.
</p>
<h3 id="captions_note">A Note on Captions</h3>
<p>
<span class="metawin">MetaWin</span> will autogenerate captions for each figure it creates, including
references in some cases. As style elements of figures can be user edited, this creates a bit of a
challenge for captioning, particularly as it relates to specifying color. Computers can
generate over 16.7 million unique colors, most of which obviously do not have unique names.
Although exact, specifying colors by RGB or hex number in captions would not be particularly
useful. Therefore, whenever a caption includes a reference to a color, a color name is chosen by
matching the specific color to the closest named color from a set of approximately 1,000
named colors based on a <a href="https://blog.xkcd.com/2010/05/03/color-survey-results/">survey done at
XKCD</a>. This set was chosen primarily because of it's size; other standard color names,
<em>e.g.,</em> CSS4, only include names for fewer than 150 colors. With that many crowd-coursed color
names, many me be a bit odd, so simply be warned if strange color labels appear.
</p>
<p>
Currently only line and markers description appear in captions. Line descriptions include only color
and style (solid, dahsed, etc.), while markers include color and shape (two colors if the primary
and border colors are different). Properties such as size and thickness are not included in captions.
</p>

<h2 id="phylogeny_tab">Phylogeny Tab</h2>
<p>
Expand Down
67 changes: 7 additions & 60 deletions src/MetaWinAnalysisFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,13 +525,6 @@ def output_filtered_bad(filtered: list, bad_data: list) -> list:
return output_blocks


# def caption_bootstrap_text(bs_n: int):
# """
# extra figure caption info for forest plots with bootstrap confidence intervals
# """
# citation = "Adams_et_1997"
# return get_text("bootstrap_caption").format(bs_n, get_citation(citation)), [citation]

# ---- I'm not convinced this is correct, which is why I'm removing it for now ---
# def calc_aic(q: float, n: int, p: int) -> float:
# """
Expand Down Expand Up @@ -577,7 +570,6 @@ def simple_meta_analysis(data, options, decimal_places: int = 4, alpha: float =
output_blocks = output_filtered_bad(filtered, bad_data)

figure = None
# fig_caption = None
chart_data = None
n = len(e_data)
citations = []
Expand Down Expand Up @@ -640,20 +632,13 @@ def simple_meta_analysis(data, options, decimal_places: int = 4, alpha: float =

if options.create_graph:
figure, chart_data = MetaWinCharts.chart_forest_plot("basic analysis", effect_sizes.label, forest_data,
alpha, options.bootstrap_mean)
# fig_caption = get_text("Forest plot of individual effect sizes for each study, as well as the overall "
# "mean.") + MetaWinCharts.common_forest_plot_caption(effect_sizes.label, alpha)
# if options.bootstrap_mean is not None:
# new_text, new_cites = caption_bootstrap_text(options.bootstrap_mean)
# # fig_caption += new_text + create_reference_list(new_cites, True)
alpha, options.bootstrap_mean, normal_ci=norm_ci)

else:
output_blocks.append([get_text("Fewer than two studies were valid for analysis")])
qt, df, p, pooled_var, i2 = None, None, None, None, None
mean_data = None

# return (output_blocks, figure, fig_caption, chart_data, simple_ma_values(mean_data, pooled_var, qt, df, p, i2),
# citations)
return output_blocks, figure, chart_data, simple_ma_values(mean_data, pooled_var, qt, df, p, i2), citations


Expand All @@ -676,7 +661,6 @@ def check_data_for_group(output_blocks, n, group_cnts, group_label) -> bool:
output.append(get_text("Please filter problematic data to continue"))
output_blocks.append(output)
return all_good
# return True


def grouped_meta_analysis(data, options, decimal_places: int = 4, alpha: float = 0.05, norm_ci: bool = True):
Expand Down Expand Up @@ -717,7 +701,6 @@ def grouped_meta_analysis(data, options, decimal_places: int = 4, alpha: float =
output_blocks = output_filtered_bad(filtered, bad_data)

figure = None
# fig_caption = None
chart_data = None
n = len(e_data)
g_cnt = len(group_names)
Expand Down Expand Up @@ -865,12 +848,8 @@ def grouped_meta_analysis(data, options, decimal_places: int = 4, alpha: float =

if options.create_graph:
figure, chart_data = MetaWinCharts.chart_forest_plot("grouped analysis", effect_sizes.label, forest_data,
alpha, options.bootstrap_mean, groups.label)
# fig_caption = get_text("group_forest_plot").format(groups.label) + \
# MetaWinCharts.common_forest_plot_caption(effect_sizes.label, alpha)
# if options.bootstrap_mean is not None:
# new_text, new_cites = caption_bootstrap_text(options.bootstrap_mean)
# fig_caption += new_text + create_reference_list(new_cites, True)
alpha, options.bootstrap_mean, groups.label,
normal_ci=norm_ci)

global_values = simple_ma_values(global_mean_data, pooled_var, qt, df, pqt, i2)
else:
Expand All @@ -882,8 +861,6 @@ def grouped_meta_analysis(data, options, decimal_places: int = 4, alpha: float =

return (output_blocks, figure, chart_data,
group_ma_values(global_values, group_mean_values, group_het_values, model_het, error_het), citations)
# return (output_blocks, figure, fig_caption, chart_data,
# group_ma_values(global_values, group_mean_values, group_het_values, model_het, error_het), citations)


# ---------- cumulative meta-analysis ----------
Expand All @@ -910,7 +887,6 @@ def cumulative_meta_analysis(data, options, decimal_places: int = 4, alpha: floa
output_blocks = output_filtered_bad(filtered, bad_data)

figure = None
# fig_caption = None
chart_data = None
n = len(tmp_data)
if n > 1:
Expand Down Expand Up @@ -975,17 +951,12 @@ def cumulative_meta_analysis(data, options, decimal_places: int = 4, alpha: floa
if options.create_graph:
figure, chart_data = MetaWinCharts.chart_forest_plot("cumulative analysis", effect_sizes.label,
cumulative_means, alpha, options.bootstrap_mean,
order.label)
# fig_caption = get_text("cumulative_forest_plot").format(order.label) + \
# MetaWinCharts.common_forest_plot_caption(effect_sizes.label, alpha)
# if options.bootstrap_mean is not None:
# new_text, new_cites = caption_bootstrap_text(options.bootstrap_mean)
# fig_caption += new_text + create_reference_list(new_cites, True)
order.label, normal_ci=norm_ci)

else:
output_blocks.append([get_text("Fewer than two studies were valid for analysis")])

return output_blocks, figure, chart_data
# return output_blocks, figure, fig_caption, chart_data


# ---------- simple regression meta-analysis ----------
Expand Down Expand Up @@ -1038,7 +1009,6 @@ def regression_meta_analysis(data, options, decimal_places: int = 4, alpha: floa
output_blocks = output_filtered_bad(filtered, bad_data)

figure = None
# fig_caption = None
chart_data = None
model_het = None
error_het = None
Expand Down Expand Up @@ -1152,16 +1122,11 @@ def regression_meta_analysis(data, options, decimal_places: int = 4, alpha: floa
figure, chart_data = MetaWinCharts.chart_regression(options.independent_variable.label, effect_sizes.label,
x_data, e_data, b1_slope, b0_intercept, model,
ref_list, fig_citations)
# fig_caption = get_text("regression_caption").format(effect_sizes.label, options.independent_variable.label,
# model, ref_list) + \
# create_reference_list(fig_citations, True)

else:
output_blocks.append([get_text("Fewer than two studies were valid for analysis")])

return output_blocks, figure, chart_data, reg_ma_values(global_values, model_het, error_het, predictors), citations
# return (output_blocks, figure, fig_caption, chart_data,
# reg_ma_values(global_values, model_het, error_het, predictors), citations)


# ---------- complex (glm) meta-analysis ----------
Expand Down Expand Up @@ -1586,7 +1551,6 @@ def nested_meta_analysis(data, options, decimal_places: int = 4, alpha: float =
n = len(e_data)

figure = None
# fig_caption = None
chart_data = None
group_het_values = None
group_mean_values = None
Expand Down Expand Up @@ -1709,17 +1673,10 @@ def nested_meta_analysis(data, options, decimal_places: int = 4, alpha: float =

if options.create_graph:
figure, chart_data = MetaWinCharts.chart_forest_plot("nested analysis", effect_sizes.label, forest_data,
alpha, options.bootstrap_mean)
# fig_caption = get_text("nest_caption") + MetaWinCharts.common_forest_plot_caption(effect_sizes.label, alpha)
# if options.bootstrap_mean is not None:
# new_text, new_cites = caption_bootstrap_text(options.bootstrap_mean)
# fig_caption += new_text + create_reference_list(new_cites, True)
alpha, options.bootstrap_mean, normal_ci=norm_ci)

return (output_blocks, figure, chart_data, group_ma_values(global_values, group_mean_values, group_het_values,
model_het_values, error_het_values), citations)
# return (output_blocks, figure, fig_caption, chart_data,
# group_ma_values(global_values, group_mean_values, group_het_values, model_het_values, error_het_values),
# citations)


# ---------- trim-and-fill analysis ----------
Expand Down Expand Up @@ -1753,7 +1710,6 @@ def trim_and_fill_analysis(data, options, decimal_places: int = 4, alpha: float
output_blocks = output_filtered_bad(filtered, bad_data)

figure = None
# fig_caption = None
chart_data = None
n = len(e_data)
citations = []
Expand Down Expand Up @@ -1877,9 +1833,6 @@ def trim_and_fill_analysis(data, options, decimal_places: int = 4, alpha: float
if options.create_graph:
figure, chart_data = MetaWinCharts.chart_trim_fill_plot(effect_sizes.label, tmp_data, n, original_mean,
mean_e)
# fig_caption = get_text("trim_fill_caption").format(effect_sizes.label, "Duval and Tweedie 2000a, b")
# new_cites = ["Duval_Tweedie_2000a", "Duval_Tweedie_2000b"]
# fig_caption += create_reference_list(new_cites, True)

else:
output_blocks.append([get_text("Fewer than two studies were valid for analysis")])
Expand Down Expand Up @@ -2199,7 +2152,6 @@ def jackknife_meta_analysis(data, options, decimal_places: int = 4, alpha: float
output_blocks = output_filtered_bad(filtered, bad_data)

figure = None
# fig_caption = None
chart_data = None
n = len(e_data)
citations = []
Expand Down Expand Up @@ -2295,12 +2247,7 @@ def jackknife_meta_analysis(data, options, decimal_places: int = 4, alpha: float

if options.create_graph:
figure, chart_data = MetaWinCharts.chart_forest_plot("jackknife analysis", effect_sizes.label, forest_data,
alpha, options.bootstrap_mean)
# fig_caption = get_text("jackknife_forest_plot") + \
# MetaWinCharts.common_forest_plot_caption(effect_sizes.label, alpha)
# if options.bootstrap_mean is not None:
# new_text, new_cites = caption_bootstrap_text(options.bootstrap_mean)
# fig_caption += new_text + create_reference_list(new_cites, True)
alpha, options.bootstrap_mean, normal_ci=norm_ci)
else:
output_blocks.append([get_text("Fewer than two studies were valid for analysis")])

Expand Down
Loading

0 comments on commit 5c4f7ae

Please sign in to comment.