gnumeric r16965 - in trunk: . src/dialogs src/tools
- From: guelzow svn gnome org
- To: svn-commits-list gnome org
- Subject: gnumeric r16965 - in trunk: . src/dialogs src/tools
- Date: Sat, 15 Nov 2008 07:03:05 +0000 (UTC)
Author: guelzow
Date: Sat Nov 15 07:03:05 2008
New Revision: 16965
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16965&view=rev
Log:
2008-11-15 Andreas J. Guelzow <aguelzow pyrshep ca>
* kaplan-meier.glade: add median checkbox
* dialog-analysis-tool-kaplan-meier.c (kaplan_meier_tool_ok_clicked_cb):
handle median checkbox
2008-11-15 Andreas J. Guelzow <aguelzow pyrshep ca>
* analysis-kaplan-meier.c (analysis_tool_kaplan_meier_engine_run):
calculate median survival times
(analysis_tool_kaplan_meier_engine): properly dispose of all data
and adjust dao size for median output
* analysis-kaplan-meier.h (analysis_tools_data_kaplan_meier_t): add
new field
Modified:
trunk/NEWS
trunk/src/dialogs/ChangeLog
trunk/src/dialogs/dialog-analysis-tool-kaplan-meier.c
trunk/src/dialogs/kaplan-meier.glade
trunk/src/tools/ChangeLog
trunk/src/tools/analysis-kaplan-meier.c
trunk/src/tools/analysis-kaplan-meier.h
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Sat Nov 15 07:03:05 2008
@@ -8,7 +8,7 @@
dialog [#527076]
* Add functional seealso links in the function browser
* Allow ranges of censor marks in Kaplan-Meier tool and
- multiple groups [#558582]
+ multiple groups. Output median survival times. [#558582]
Hib Eris:
* Fix problems with toolbars when no handle bar present. [#559249]
Modified: trunk/src/dialogs/dialog-analysis-tool-kaplan-meier.c
==============================================================================
--- trunk/src/dialogs/dialog-analysis-tool-kaplan-meier.c (original)
+++ trunk/src/dialogs/dialog-analysis-tool-kaplan-meier.c Sat Nov 15 07:03:05 2008
@@ -274,6 +274,10 @@
data->range_3 = ((data->group_list == NULL) ? NULL : gnm_expr_entry_parse_as_value
(GNM_EXPR_ENTRY (state->groups_input), state->base.sheet));
+ data->median = gtk_toggle_button_get_active (
+ GTK_TOGGLE_BUTTON (glade_xml_get_widget
+ (state->base.gui,
+ "median-button")));
data->chart = gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON (state->graph_button));
data->ticks = gtk_toggle_button_get_active (
Modified: trunk/src/dialogs/kaplan-meier.glade
==============================================================================
--- trunk/src/dialogs/kaplan-meier.glade (original)
+++ trunk/src/dialogs/kaplan-meier.glade Sat Nov 15 07:03:05 2008
@@ -43,52 +43,45 @@
<placeholder/>
</child>
<child>
- <widget class="GtkCheckButton" id="censor-button">
+ <widget class="GtkSpinButton" id="censored-spinbutton2">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="label" translatable="yes">Permit censorship</property>
- <property name="response_id">0</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
+ <property name="adjustment">0 0 1000 1 10 10</property>
+ <property name="climb_rate">1</property>
</widget>
<packing>
+ <property name="left_attach">2</property>
<property name="right_attach">3</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options">GTK_FILL</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="var2-label">
+ <widget class="GtkSpinButton" id="censored-spinbutton1">
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Censor co_lumn:</property>
- <property name="use_underline">True</property>
- <property name="justify">GTK_JUSTIFY_RIGHT</property>
+ <property name="can_focus">True</property>
+ <property name="adjustment">0 0 1000 1 10 10</property>
+ <property name="climb_rate">1</property>
</widget>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options">GTK_FILL</property>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="var1-label">
+ <widget class="GtkLabel" id="label5">
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="xpad">5</property>
- <property name="label" translatable="yes">_Time column:</property>
- <property name="use_underline">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">to:</property>
<property name="justify">GTK_JUSTIFY_RIGHT</property>
</widget>
<packing>
+ <property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options">GTK_FILL</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
</packing>
</child>
<child>
@@ -106,45 +99,52 @@
</packing>
</child>
<child>
- <widget class="GtkLabel" id="label5">
+ <widget class="GtkLabel" id="var1-label">
<property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">to:</property>
+ <property name="xalign">0</property>
+ <property name="xpad">5</property>
+ <property name="label" translatable="yes">_Time column:</property>
+ <property name="use_underline">True</property>
<property name="justify">GTK_JUSTIFY_RIGHT</property>
</widget>
<packing>
- <property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
- <widget class="GtkSpinButton" id="censored-spinbutton1">
+ <widget class="GtkLabel" id="var2-label">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="adjustment">0 0 1000 1 10 10</property>
- <property name="climb_rate">1</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Censor co_lumn:</property>
+ <property name="use_underline">True</property>
+ <property name="justify">GTK_JUSTIFY_RIGHT</property>
</widget>
<packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
- <widget class="GtkSpinButton" id="censored-spinbutton2">
+ <widget class="GtkCheckButton" id="censor-button">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="adjustment">0 0 1000 1 10 10</property>
- <property name="climb_rate">1</property>
+ <property name="label" translatable="yes">Permit censorship</property>
+ <property name="response_id">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
</widget>
<packing>
- <property name="left_attach">2</property>
<property name="right_attach">3</property>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
</packing>
</child>
</widget>
@@ -212,66 +212,66 @@
<placeholder/>
</child>
<child>
- <widget class="GtkLabel" id="groups-label">
+ <widget class="GtkScrolledWindow" id="groups-scrolled">
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Groups column:</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="shadow_type">GTK_SHADOW_IN</property>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
- <property name="y_options">GTK_FILL</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">7</property>
</packing>
</child>
<child>
- <widget class="GtkButton" id="add-button">
+ <widget class="GtkButton" id="remove-button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="label" translatable="yes">gtk-add</property>
+ <property name="label" translatable="yes">gtk-remove</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_SHRINK | GTK_FILL</property>
</packing>
</child>
<child>
- <widget class="GtkButton" id="remove-button">
+ <widget class="GtkButton" id="add-button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="label" translatable="yes">gtk-remove</property>
+ <property name="label" translatable="yes">gtk-add</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_SHRINK | GTK_FILL</property>
</packing>
</child>
<child>
- <widget class="GtkScrolledWindow" id="groups-scrolled">
+ <widget class="GtkLabel" id="groups-label">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <child>
- <placeholder/>
- </child>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Groups column:</property>
</widget>
<packing>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">7</property>
+ <property name="y_options">GTK_FILL</property>
</packing>
</child>
</widget>
@@ -310,34 +310,34 @@
<placeholder/>
</child>
<child>
- <widget class="GtkCheckButton" id="tick-button">
+ <widget class="GtkCheckButton" id="graph-button">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="label" translatable="yes">Include censorship ticks</property>
+ <property name="label" translatable="yes">Show graph </property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
- <property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
- <widget class="GtkCheckButton" id="graph-button">
+ <widget class="GtkCheckButton" id="tick-button">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="label" translatable="yes">Show graph </property>
+ <property name="label" translatable="yes">Include censorship ticks</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
+ <property name="left_attach">1</property>
<property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
@@ -362,6 +362,21 @@
<property name="position">1</property>
</packing>
</child>
+ <child>
+ <widget class="GtkCheckButton" id="median-button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Show median survival times</property>
+ <property name="response_id">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="position">2</property>
Modified: trunk/src/tools/analysis-kaplan-meier.c
==============================================================================
--- trunk/src/tools/analysis-kaplan-meier.c (original)
+++ trunk/src/tools/analysis-kaplan-meier.c Sat Nov 15 07:03:05 2008
@@ -74,6 +74,7 @@
GnmFunc *fd_small;
GnmFunc *fd_sum;
GnmFunc *fd_sqrt = NULL;
+ GnmFunc *fd_min = NULL;
GogGraph *graph;
GogPlot *plot;
@@ -95,6 +96,10 @@
fd_sqrt = gnm_func_lookup ("SQRT", NULL);
gnm_func_ref (fd_sqrt);
}
+ if (info->median) {
+ fd_min = gnm_func_lookup ("MIN", NULL);
+ gnm_func_ref (fd_min);
+ }
rows = info->base.range_1->v_range.cell.b.row
- info->base.range_1->v_range.cell.a.row + 1;
@@ -465,6 +470,58 @@
dao_set_sheet_object (dao, 0, 1, so);
}
+ if (info->median) {
+ dao_set_italic (dao, 1, 1, 1, 1);
+ dao_set_cell (dao, 1, 1, _("Median:"));
+
+ dao->offset_col += 2;
+ gl = info->group_list;
+
+ for (i = 0; i < repetitions; i++) {
+ gint prob_dx = - (repetitions - i)* (colspan - 1) - 1;
+ gint times_dx = - colspan * repetitions - i - 3;
+ GnmExpr const *expr_median;
+
+ dao_set_italic (dao, 0, 0, 0, 0);
+
+ if (gl != NULL && gl->data != NULL) {
+ analysis_tools_kaplan_meier_group_t *gd = gl->data;
+ if (gd->name != NULL) {
+ dao_set_cell (dao, 0, 0, gd->name);
+ }
+ gl = gl->next;
+ }
+
+ expr_prob = gnm_expr_new_binary
+ (gnm_expr_new_funcall3
+ (fd_if,
+ gnm_expr_new_binary
+ (make_rangeref(prob_dx, 1, prob_dx, rows),
+ GNM_EXPR_OP_GT,
+ gnm_expr_new_constant (value_new_float (0.5))),
+ gnm_expr_new_constant (value_new_string ("NA")),
+ gnm_expr_new_constant (value_new_int (1))),
+ GNM_EXPR_OP_MULT,
+ make_rangeref (times_dx, 1, times_dx, rows));
+
+ expr_median = gnm_expr_new_funcall1
+ (fd_min,
+ gnm_expr_new_funcall3
+ (fd_if,
+ gnm_expr_new_funcall1
+ (fd_iserror,
+ gnm_expr_copy (expr_prob)),
+ gnm_expr_new_constant (value_new_string ("NA")),
+ expr_prob));
+
+ dao_set_cell_array_expr (dao, 0, 1,expr_median);
+
+ dao->offset_col += 1;
+ }
+ }
+
+
+
gnm_expr_free (expr_data);
if (expr_group_data != NULL)
gnm_expr_free (expr_group_data);
@@ -475,6 +532,8 @@
gnm_func_unref (fd_sum);
if (fd_sqrt != NULL)
gnm_func_unref (fd_sqrt);
+ if (fd_min != NULL)
+ gnm_func_unref (fd_min);
dao_redraw_respan (dao);
@@ -498,6 +557,7 @@
{
analysis_tools_data_kaplan_meier_t *info = specs;
int multiple;
+ int median;
switch (selector) {
case TOOL_ENGINE_UPDATE_DESCRIPTOR:
@@ -507,13 +567,16 @@
== NULL);
case TOOL_ENGINE_UPDATE_DAO:
multiple = ((info->group_list == NULL) ? 1 : g_slist_length (info->group_list));
- dao_adjust (dao, 1 + multiple * ((info->std_err ? 4 : 3) + (info->censored ? 1 : 0)),
+ median = (info->median ? (2 + multiple) : 0);
+ dao_adjust (dao, median + 1 + multiple * ((info->std_err ? 4 : 3) + (info->censored ? 1 : 0)),
info->base.range_1->v_range.cell.b.row
- info->base.range_1->v_range.cell.a.row + 3);
return FALSE;
case TOOL_ENGINE_CLEAN_UP:
- value_release (info->range_3);
- info->range_3 = NULL;
+ if (info->range_3) {
+ value_release (info->range_3);
+ info->range_3 = NULL;
+ }
g_slist_foreach (info->group_list, analysis_tool_kaplan_meier_clear_gl_cb, NULL);
g_slist_free (info->group_list);
info->group_list = NULL;
Modified: trunk/src/tools/analysis-kaplan-meier.h
==============================================================================
--- trunk/src/tools/analysis-kaplan-meier.h (original)
+++ trunk/src/tools/analysis-kaplan-meier.h Sat Nov 15 07:03:05 2008
@@ -51,6 +51,7 @@
gboolean chart;
gboolean ticks;
gboolean std_err;
+ gboolean median;
GSList *group_list;
} analysis_tools_data_kaplan_meier_t;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]