Next changeset 1:232b874046a7 (2023-08-10) |
Commit message:
Initial commit |
added:
lifelines_tool/LICENSE lifelines_tool/README.md lifelines_tool/lifelines_report.png lifelines_tool/lifelines_rossi_km.png lifelines_tool/lifelines_rossi_schoenfeld.png lifelines_tool/lifelineskmcph.xml lifelines_tool/plotlykm.py lifelines_tool/rossi.tab lifelines_tool/run_log.txt lifelines_tool/test-data/input_tab_sample lifelines_tool/test-data/readme_sample lifelines_tool/tongue.tab |
b |
diff -r 000000000000 -r dd49a7040643 lifelines_tool/LICENSE --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lifelines_tool/LICENSE Wed Aug 09 11:12:16 2023 +0000 |
b |
@@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Ross + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. |
b |
diff -r 000000000000 -r dd49a7040643 lifelines_tool/README.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lifelines_tool/README.md Wed Aug 09 11:12:16 2023 +0000 |
[ |
@@ -0,0 +1,35 @@ +# lifelines_tool - lifelines statistical package wrapped as a Galaxy tool. + +## Galaxy tool to run failure time models using lifelines + +## Install to your Galaxy server from the toolshed - search for lifelines_tool owned by fubar2 + +### More at https://lazarus.name/demo/ + +#### Using the Rossi sample input data from lifelines, tool outputs include: + +![KM plot sample](lifelines_rossi_km.png) +and +![KM plot sample](lifelines_rossi_schoenfeld.png) +and +![KM plot sample](lifelines_report.png) + + +Runs Kaplan-Meier and generates a plot. Optional grouping variable. +If 2 groups, runs a log-rank test for difference. +Plots show confidence intervals + +If a list of covariate column names is provided, these are used in a +Cox Proportional Hazards model with tests for proportionality. + +Should work with any tabular data with the required columns - time and status for observations. + +Issues to https://github.com/fubar2/lifelines_tool please. +Autogenerated so pull requests are possibly meaningless but regeneration of a new version is easy so please tell me what is needed. + +## Tool made with the Galaxy ToolFactory: https://github.com/fubar2/galaxy_tf_overlay +The current release includes this and a generic tabular version, and a java .jar wrapper in a history where the generating +ToolFactory form can be recreated using the redo button. Editing the tool id will make a new tool, so all other edits to parameters can be +made and the new tool generated without destroying the original sample. + + |
b |
diff -r 000000000000 -r dd49a7040643 lifelines_tool/lifelines_report.png |
b |
Binary file lifelines_tool/lifelines_report.png has changed |
b |
diff -r 000000000000 -r dd49a7040643 lifelines_tool/lifelines_rossi_km.png |
b |
Binary file lifelines_tool/lifelines_rossi_km.png has changed |
b |
diff -r 000000000000 -r dd49a7040643 lifelines_tool/lifelines_rossi_schoenfeld.png |
b |
Binary file lifelines_tool/lifelines_rossi_schoenfeld.png has changed |
b |
diff -r 000000000000 -r dd49a7040643 lifelines_tool/lifelineskmcph.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lifelines_tool/lifelineskmcph.xml Wed Aug 09 11:12:16 2023 +0000 |
[ |
b'@@ -0,0 +1,229 @@\n+<tool name="lifelineskmcph" id="lifelineskmcph" version="0.01">\n+ <!--Source in git at: https://github.com/fubar2/galaxy_tf_overlay-->\n+ <!--Created by toolfactory@galaxy.org at 09/08/2023 17:43:16 using the Galaxy Tool Factory.-->\n+ <description>Lifelines KM and optional Cox PH models</description>\n+ <requirements>\n+ <requirement version="1.5.3" type="package">pandas</requirement>\n+ <requirement version="3.7.2" type="package">matplotlib</requirement>\n+ <requirement version="0.27.7" type="package">lifelines</requirement>\n+ </requirements>\n+ <stdio>\n+ <exit_code range="1:" level="fatal"/>\n+ </stdio>\n+ <version_command><![CDATA[echo "0.01"]]></version_command>\n+ <command><![CDATA[python\n+$runme\n+--input_tab\n+$input_tab\n+--readme\n+$readme\n+--time\n+\'$time\'\n+--status\n+\'$status\'\n+--cphcols\n+\'$CPHcovariatecolumnnames\'\n+--title\n+\'$title\'\n+--header\n+\'$header\'\n+--group\n+\'$group\'\n+--image_type\n+\'$image_type\'\n+--image_dir\n+\'image_dir\']]></command>\n+ <configfiles>\n+ <configfile name="runme"><![CDATA[#raw\n+\n+# script for a lifelines ToolFactory KM/CPH tool for Galaxy\n+# km models for https://github.com/galaxyproject/tools-iuc/issues/5393\n+# test as\n+# python plotlykm.py --input_tab rossi.tab --htmlout "testfoo" --time "week" --status "arrest" --title "test" --image_dir images --cphcol="prio,age,race,paro,mar,fin"\n+\n+import argparse\n+import os\n+import sys\n+\n+import lifelines\n+\n+from matplotlib import pyplot as plt\n+\n+import pandas as pd\n+\n+# Ross Lazarus July 2023\n+\n+\n+kmf = lifelines.KaplanMeierFitter()\n+cph = lifelines.CoxPHFitter()\n+\n+parser = argparse.ArgumentParser()\n+a = parser.add_argument\n+a(\'--input_tab\', default=\'\', required=True)\n+a(\'--header\', default=\'\')\n+a(\'--htmlout\', default="test_run.html")\n+a(\'--group\', default=\'\')\n+a(\'--time\', default=\'\', required=True)\n+a(\'--status\',default=\'\', required=True)\n+a(\'--cphcols\',default=\'\')\n+a(\'--title\', default=\'Default plot title\')\n+a(\'--image_type\', default=\'png\')\n+a(\'--image_dir\', default=\'images\')\n+a(\'--readme\', default=\'run_log.txt\')\n+args = parser.parse_args()\n+sys.stdout = open(args.readme, \'w\')\n+df = pd.read_csv(args.input_tab, sep=\'\\t\')\n+NCOLS = df.columns.size\n+NROWS = len(df.index)\n+defaultcols = [\'col%d\' % (x+1) for x in range(NCOLS)]\n+testcols = df.columns\n+if len(args.header.strip()) > 0:\n+ newcols = args.header.split(\',\')\n+ if len(newcols) == NCOLS:\n+ if (args.time in newcols) and (args.status in newcols):\n+ df.columns = newcols\n+ else:\n+ sys.stderr.write(\'## CRITICAL USAGE ERROR (not a bug!): time %s and/or status %s not found in supplied header parameter %s\' % (args.time, args.status, args.header))\n+ sys.exit(4)\n+ else:\n+ sys.stderr.write(\'## CRITICAL USAGE ERROR (not a bug!): Supplied header %s has %d comma delimited header names - does not match the input tabular file %d columns\' % (args.header, len(newcols), NCOLS))\n+ sys.exit(5)\n+else: # no header supplied - check for a real one that matches the x and y axis column names\n+ colsok = (args.time in testcols) and (args.status in testcols) # if they match, probably ok...should use more code and logic..\n+ if colsok:\n+ df.columns = testcols # use actual header\n+ else:\n+ colsok = (args.time in defaultcols) and (args.status in defaultcols)\n+ if colsok:\n+ sys.stderr.write(\'replacing first row of data derived header %s with %s\' % (testcols, defaultcols))\n+ df.columns = defaultcols\n+ else:\n+ sys.stderr.write(\'## CRITICAL USAGE ERROR (not a bug!): time %s and status %s do not match anything in the file header, supplied header or automatic default column names %s\' % (args.time, args.status, defaultcols))\n+print(\'## Lifelines tool starting.\\nUsing data header =\', df.columns, \'time column =\', args.time, \'status column =\', args.status)\n+os.makedirs(args.image_dir, exist_ok=True)\n+fig, ax = plt.subplots()\n+if args.group > \'\':\n+ names = []\n+ times = []\n'..b'e-table observations" help="Use a column name from the header if the file has one, or use one from the list supplied below, or use col1....colN otherwise to select the correct column"/>\n+ <param name="CPHcovariatecolumnnames" type="text" value="prio,age,race,paro,mar,fin" label="Optional comma delimited column names to use as covariates in the Cox Proportional Hazards model" help="Leave blank for no Cox PH model tests "/>\n+ <param name="title" type="text" value="KM and CPH in lifelines test" label="Title for this lifelines analysis" help="Special characters will probably be escaped so do not use them"/>\n+ <param name="header" type="text" value="" label="Optional comma delimited list of column names to use for this tabular file. Default is None when col1...coln will be used if no header row in the input data" help="The column names supplied for time, status and so on MUST match either this supplied list, or if none, the original file header if it exists, or col1...coln as the default of last resort."/>\n+ <param name="group" type="text" value="race" label="Optional group column name for KM plot" help="If there are exactly 2 groups, a log-rank statistic will be generated as part of the Kaplan-Meier test."/>\n+ <param name="image_type" type="select" label="Output format for all images" help="">\n+ <option value="png">Portable Network Graphics .png format</option>\n+ <option value="jpg">JPEG</option>\n+ <option value="pdf">PDF</option>\n+ <option value="tiff">TIFF</option>\n+ </param>\n+ </inputs>\n+ <outputs>\n+ <collection name="image_dir" type="list" label="Images from $title on $input_tab.element_identifier">\n+ <discover_datasets pattern="__name_and_ext__" directory="image_dir" visible="false"/>\n+ </collection>\n+ <data name="readme" format="txt" label="Lifelines_km_cph $title on $input_tab.element_identifier" hidden="false"/>\n+ </outputs>\n+ <tests>\n+ <test>\n+ <output_collection name="image_dir"/>\n+ <output name="readme" value="readme_sample" compare="sim_size" delta="1000"/>\n+ <param name="input_tab" value="input_tab_sample"/>\n+ <param name="time" value="week"/>\n+ <param name="status" value="arrest"/>\n+ <param name="CPHcovariatecolumnnames" value="prio,age,race,paro,mar,fin"/>\n+ <param name="title" value="KM and CPH in lifelines test"/>\n+ <param name="header" value=""/>\n+ <param name="group" value="race"/>\n+ <param name="image_type" value="png"/>\n+ </test>\n+ </tests>\n+ <help><![CDATA[\n+\n+This is a wrapper for some elementary life table analysis functions from the Lifelines package - see https://lifelines.readthedocs.io/en/latest for the full story\n+\n+\n+\n+Given a Galaxy tabular dataset with suitable indicators for time and status at observation, this tool can perform some simple life-table analyses and produce some useful plots. Kaplan-Meier is the default. Cox Proportional Hazards model will be tested if covariates to include are provided.\n+\n+\n+\n+1. Kaplan-Meier survival analysis - see https://lifelines.readthedocs.io/en/latest/Survival%20analysis%20with%20lifelines.html\n+\n+ This is always performed and a survival curve is plotted. \n+\n+ If there is an optional "group" column, the plot will show each group separately. If there are *exactly* two groups, a log-rank test for difference is performed and reported\n+\n+\n+\n+2. The Cox Proportional Hazards model can be tested, if a comma separated list of covariate column names is supplied on the tool form.\n+\n+ These are used in as covariates. \n+\n+ Although not usually a real problem, some diagnostics and advice about the assumption of proportional hazards are are also provided as outputs - see https://lifelines.readthedocs.io/en/latest/Survival%20Regression.html\n+\n+\n+\n+A big shout out to the lifelines authors - no R code needed - nice job, thanks!\n+\n+ ]]></help>\n+ <citations>\n+ <citation type="doi">10.1093/bioinformatics/bts573</citation>\n+ </citations>\n+</tool>\n+\n' |
b |
diff -r 000000000000 -r dd49a7040643 lifelines_tool/plotlykm.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lifelines_tool/plotlykm.py Wed Aug 09 11:12:16 2023 +0000 |
[ |
@@ -0,0 +1,118 @@ +# script for a lifelines ToolFactory KM/CPH tool for Galaxy +# km models for https://github.com/galaxyproject/tools-iuc/issues/5393 +# test as +# python plotlykm.py --input_tab rossi.tab --htmlout "testfoo" --time "week" --status "arrest" --title "test" --image_dir images --cphcol="prio,age,race,paro,mar,fin" + +import argparse +import os +import sys + +import lifelines + +from matplotlib import pyplot as plt + +import pandas as pd + +# Ross Lazarus July 2023 + + +kmf = lifelines.KaplanMeierFitter() +cph = lifelines.CoxPHFitter() + +parser = argparse.ArgumentParser() +a = parser.add_argument +a('--input_tab', default='', required=True) +a('--header', default='') +a('--htmlout', default="test_run.html") +a('--group', default='') +a('--time', default='', required=True) +a('--status',default='', required=True) +a('--cphcols',default='') +a('--title', default='Default plot title') +a('--image_type', default='png') +a('--image_dir', default='images') +a('--readme', default='run_log.txt') +args = parser.parse_args() +sys.stdout = open(args.readme, 'w') +df = pd.read_csv(args.input_tab, sep='\t') +NCOLS = df.columns.size +NROWS = len(df.index) +defaultcols = ['col%d' % (x+1) for x in range(NCOLS)] +testcols = df.columns +if len(args.header.strip()) > 0: + newcols = args.header.split(',') + if len(newcols) == NCOLS: + if (args.time in newcols) and (args.status in newcols): + df.columns = newcols + else: + sys.stderr.write('## CRITICAL USAGE ERROR (not a bug!): time %s and/or status %s not found in supplied header parameter %s' % (args.time, args.status, args.header)) + sys.exit(4) + else: + sys.stderr.write('## CRITICAL USAGE ERROR (not a bug!): Supplied header %s has %d comma delimited header names - does not match the input tabular file %d columns' % (args.header, len(newcols), NCOLS)) + sys.exit(5) +else: # no header supplied - check for a real one that matches the x and y axis column names + colsok = (args.time in testcols) and (args.status in testcols) # if they match, probably ok...should use more code and logic.. + if colsok: + df.columns = testcols # use actual header + else: + colsok = (args.time in defaultcols) and (args.status in defaultcols) + if colsok: + sys.stderr.write('replacing first row of data derived header %s with %s' % (testcols, defaultcols)) + df.columns = defaultcols + else: + sys.stderr.write('## CRITICAL USAGE ERROR (not a bug!): time %s and status %s do not match anything in the file header, supplied header or automatic default column names %s' % (args.time, args.status, defaultcols)) +print('## Lifelines tool starting.\nUsing data header =', df.columns, 'time column =', args.time, 'status column =', args.status) +os.makedirs(args.image_dir, exist_ok=True) +fig, ax = plt.subplots() +if args.group > '': + names = [] + times = [] + events = [] + rmst = [] + for name, grouped_df in df.groupby(args.group): + T = grouped_df[args.time] + E = grouped_df[args.status] + gfit = kmf.fit(T, E, label=name) + kmf.plot_survival_function(ax=ax) + rst = lifelines.utils.restricted_mean_survival_time(gfit) + rmst.append(rst) + names.append(str(name)) + times.append(T) + events.append(E) + ngroup = len(names) + if ngroup == 2: # run logrank test if 2 groups + results = lifelines.statistics.logrank_test(times[0], times[1], events[0], events[1], alpha=.99) + print(' vs '.join(names), results) + results.print_summary() + elif ngroup > 1: + fig, ax = plt.subplots(nrows=ngroup, ncols=1, sharex=True) + for i, rst in rmst: + lifelines.plotting.rmst_plot(rst, ax=ax) + fig.savefig(os.path.join(args.image_dir,'RMST_%s.png' % args.title)) +else: + kmf.fit(df[args.time], df[args.status]) + kmf.plot_survival_function(ax=ax) +fig.savefig(os.path.join(args.image_dir,'KM_%s.png' % args.title)) +if len(args.cphcols) > 0: + fig, ax = plt.subplots() + cphcols = args.cphcols.strip().split(',') + cphcols = [x.strip() for x in cphcols] + notfound = sum([(x not in df.columns) for x in cphcols]) + if notfound > 0: + sys.stderr.write('## CRITICAL USAGE ERROR (not a bug!): One or more requested Cox PH columns %s not found in supplied column header %s' % (args.cphcols, df.columns)) + sys.exit(6) + print('### Lifelines test of Proportional Hazards results with %s as covariates on %s' % (', '.join(cphcols), args.title)) + cphcols += [args.time, args.status] + cphdf = df[cphcols] + cph.fit(cphdf, duration_col=args.time, event_col=args.status) + cph.print_summary() + cphaxes = cph.check_assumptions(cphdf, p_value_threshold=0.01, show_plots=True) + for i, ax in enumerate(cphaxes): + figr = ax[0].get_figure() + titl = figr._suptitle.get_text().replace(' ','_').replace("'","") + oname = os.path.join(args.image_dir,'CPH%s.%s' % (titl, args.image_type)) + figr.savefig(oname) + + + + |
b |
diff -r 000000000000 -r dd49a7040643 lifelines_tool/rossi.tab --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lifelines_tool/rossi.tab Wed Aug 09 11:12:16 2023 +0000 |
b |
b'@@ -0,0 +1,433 @@\n+\tweek\tarrest\tfin\tage\trace\twexp\tmar\tparo\tprio\n+0\t20\t1\t0\t27\t1\t0\t0\t1\t3\n+1\t17\t1\t0\t18\t1\t0\t0\t1\t8\n+2\t25\t1\t0\t19\t0\t1\t0\t1\t13\n+3\t52\t0\t1\t23\t1\t1\t1\t1\t1\n+4\t52\t0\t0\t19\t0\t1\t0\t1\t3\n+5\t52\t0\t0\t24\t1\t1\t0\t0\t2\n+6\t23\t1\t0\t25\t1\t1\t1\t1\t0\n+7\t52\t0\t1\t21\t1\t1\t0\t1\t4\n+8\t52\t0\t0\t22\t1\t0\t0\t0\t6\n+9\t52\t0\t0\t20\t1\t1\t0\t0\t0\n+10\t52\t0\t1\t26\t1\t0\t0\t1\t3\n+11\t52\t0\t0\t40\t1\t1\t0\t0\t2\n+12\t37\t1\t0\t17\t1\t1\t0\t1\t5\n+13\t52\t0\t0\t37\t1\t1\t0\t0\t2\n+14\t25\t1\t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t29\t1\t0\t0\t0\t4\n+81\t52\t0\t0\t30\t1\t1\t0\t1\t3\n+82\t52\t0\t1\t21\t0\t1\t1\t1\t10\n+83\t52\t0\t0\t20\t1\t0\t0\t1\t7\n+84\t22\t1\t1\t19\t1\t0\t0\t1\t10\n+85\t52\t0\t1\t22\t1\t1\t0\t1\t1\n+86\t52\t0\t0\t25\t1\t0\t0\t1\t3\n+87\t18\t1\t0\t22\t1\t0\t0\t0\t4\n+88\t52\t0\t1\t22\t1\t1\t0\t1\t4\n+89\t52\t0\t1\t24\t1\t0\t0\t1\t2\n+90\t52\t0\t0\t39\t1\t1\t1\t1\t4\n+91\t52\t0\t0\t21\t1\t1\t0\t1\t1\n+92\t52\t0\t1\t20\t1\t1\t0\t1\t2\n+93\t52\t0\t1\t24\t1\t0\t0\t0\t1\n+94\t52\t0\t0\t25\t1\t1\t0\t1\t2\n+95\t24\t1\t1\t21\t1\t1\t0\t0\t4\n+96\t52\t0\t1\t20\t1\t0\t0\t1\t1\n+97\t52\t0\t1\t19\t1\t0\t0\t1\t3\n+98\t52\t0\t1\t24\t1\t0\t0\t0\t2\n+99\t52\t0\t1\t24\t1\t1\t0\t1\t1\n+100\t2\t1\t0\t44\t1\t1\t0\t1\t2\n+101\t26\t1\t0\t32\t1\t1\t0\t0\t2\n+102\t52\t0\t0\t23\t1\t1\t0\t0\t3\n+103\t49\t1\t1\t19\t1\t0\t0\t1\t1\n+104\t52\t0\t0\t20\t1\t0\t0\t1\t1\n+105\t21\t1\t0\t27\t1\t1\t0\t1\t0\n+106\t48\t1\t0\t19\t1\t0\t0\t0\t6\n+107\t52\t0\t1\t21\t1\t1\t0\t0\t1\n+108\t52\t0\t0\t20\t1\t0\t0\t1\t1\n+109\t52\t0\t0\t25\t1\t0\t0\t1\t3\n+110\t52\t0\t0\t20\t1\t0\t0\t1\t6\n+111\t52\t0\t1\t23\t1\t1\t0\t1\t3\n+112\t52\t0\t0\t20\t1\t0\t0\t0\t2\n+113\t52\t0\t1\t30\t1\t1\t0\t0\t1\n+114\t52\t0\t0\t25\t1\t1\t1\t1\t0\n+115\t52\t0\t0\t22\t1\t1\t0\t1\t1\n+116\t52\t0\t0\t24\t1\t1\t0\t1\t3\n+117\t52\t0\t1\t18\t1\t0\t0\t0\t4\n+118\t8\t1\t1\t40\t1\t1\t0\t1\t1\n+119\t52\t0\t0\t22\t1\t0\t0\t1\t1\n+120\t52\t0\t1\t23\t1\t0\t0\t1\t6\n+121\t49\t1\t0\t21\t1\t1\t0\t1\t1\n+122\t52\t0\t1\t24\t0\t1\t1\t1\t2\n+123\t52\t0\t1\t24\t1\t0\t0\t1\t14\n+124\t52\t0\t0\t38\t1\t1\t0\t1\t2\n+125\t52\t0\t0\t26\t0\t1\t0\t0\t3\n+126\t52\t0\t1\t29\t1\t1\t0\t0\t1\n+127\t52\t0\t0\t21\t1\t0\t0\t1\t8\n+128\t52\t0\t1\t21\t1\t1\t1\t1\t2\n+129\t52\t0\t0\t22\t0\t0\t0\t1\t4\n+130\t8\t1\t0\t23\t1\t0\t0\t1\t5\n+131\t52\t0\t0\t27\t1\t1\t0\t0\t2\n+132\t52\t0\t1\t18\t1\t0\t0\t1\t2\n+133\t13\t1\t0\t23\t1\t0\t0\t0\t5\n+134\t52\t0\t1\t24\t1\t0\t0\t1\t2\n+135\t52\t0\t1\t21\t1\t0\t0\t0\t3\n+136\t52\t0\t1\t20\t1\t0\t0\t1\t4\n+137\t52\t0\t1\t27\t1\t1\t0\t0\t4\n+138\t8\t1\t1\t20\t1\t0\t0\t1\t11\n+139\t52\t0\t1\t29\t1\t1\t1\t1\t5\n+140\t33\t1\t0\t19\t1\t0\t0\t0\t10\n+141\t52\t0\t0\t20\t1\t0\t0\t0\t8\n+142\t52\t0\t1\t18\t1\t0\t0\t1\t0\n+143\t11\t1\t1\t19\t1\t0\t0\t1\t2\n+144\t52\t0\t1\t24\t1\t1\t0\t1\t1\n+145\t52\t0\t0\t28\t0\t1\t0\t1\t4\n+146\t52\t0\t1\t26\t1\t0\t0\t0\t4\n+147\t52\t0\t1\t17\t1\t0\t0\t1\t0\n+148\t52\t0\t0\t21\t1\t0\t0\t1\t3\n+149\t37\t1\t0\t34\t1\t1\t0\t0\t2\n+150\t52\t0\t1\t26\t1\t1\t0\t0\t1\n+151\t52\t0\t1\t43\t1\t1\t0\t1\t2\n+152\t52\t0\t0\t20\t1\t0\t0\t1\t0\n+153\t44\t1\t0\t20\t1\t1\t0\t1\t1\n+154\t52\t0\t0\t32\t1\t1\t0\t1\t1\n+155\t52\t1\t0\t25\t0\t1\t0\t1\t1\n+156\t52\t0\t1\t22\t1\t0\t0\t1\t1\n+157\t52\t0\t1\t31\t0\t1\t0\t1\t1\n+158\t52\t0\t1\t42\t1\t1\t1\t1\t4\n+159\t52\t0\t1\t32\t1\t1\t0\t0\t10\n+160\t52\t0\t1\t20\t1\t0\t0\t0\t8\n+161\t52\t0\t0\t20'..b'272\t32\t1\t1\t19\t1\t0\t0\t1\t0\n+273\t52\t0\t0\t18\t1\t0\t0\t1\t4\n+274\t52\t0\t1\t28\t1\t1\t0\t0\t0\n+275\t52\t0\t1\t22\t1\t1\t0\t0\t2\n+276\t52\t0\t1\t25\t1\t0\t0\t1\t1\n+277\t52\t0\t1\t28\t1\t1\t0\t0\t2\n+278\t52\t0\t1\t25\t1\t1\t0\t0\t2\n+279\t52\t0\t1\t20\t1\t1\t0\t0\t4\n+280\t52\t0\t1\t24\t1\t0\t0\t0\t5\n+281\t52\t0\t0\t24\t1\t1\t0\t0\t0\n+282\t52\t0\t1\t36\t0\t1\t0\t1\t2\n+283\t52\t0\t1\t34\t1\t1\t0\t0\t1\n+284\t31\t1\t0\t19\t1\t1\t0\t1\t5\n+285\t20\t1\t1\t23\t1\t0\t0\t1\t1\n+286\t40\t1\t0\t19\t1\t1\t0\t1\t3\n+287\t52\t0\t1\t40\t1\t1\t0\t0\t2\n+288\t52\t0\t1\t31\t1\t1\t0\t0\t2\n+289\t52\t0\t0\t23\t1\t1\t1\t1\t0\n+290\t52\t0\t0\t42\t1\t0\t0\t1\t2\n+291\t42\t1\t1\t26\t1\t1\t1\t1\t1\n+292\t52\t0\t0\t20\t1\t0\t0\t1\t9\n+293\t26\t1\t0\t27\t1\t1\t0\t1\t1\n+294\t52\t0\t1\t24\t1\t0\t0\t0\t5\n+295\t52\t0\t0\t25\t1\t0\t0\t0\t2\n+296\t52\t0\t1\t22\t1\t1\t0\t1\t3\n+297\t52\t0\t1\t20\t1\t0\t0\t1\t2\n+298\t52\t0\t1\t20\t1\t1\t0\t1\t2\n+299\t47\t1\t0\t22\t1\t0\t0\t1\t3\n+300\t52\t0\t0\t18\t1\t1\t0\t1\t1\n+301\t52\t0\t0\t20\t1\t1\t0\t1\t2\n+302\t40\t1\t0\t20\t1\t1\t0\t1\t1\n+303\t52\t0\t0\t22\t1\t1\t0\t1\t2\n+304\t52\t0\t1\t30\t1\t1\t1\t0\t2\n+305\t52\t0\t0\t36\t0\t1\t0\t0\t1\n+306\t52\t0\t0\t25\t0\t1\t1\t1\t5\n+307\t21\t1\t0\t29\t1\t0\t0\t1\t3\n+308\t52\t0\t0\t19\t1\t1\t0\t1\t3\n+309\t52\t0\t1\t24\t1\t1\t0\t1\t2\n+310\t52\t0\t1\t21\t1\t0\t0\t0\t0\n+311\t52\t0\t1\t35\t1\t1\t0\t1\t6\n+312\t52\t0\t1\t19\t0\t1\t0\t0\t4\n+313\t1\t1\t0\t20\t1\t0\t0\t0\t0\n+314\t43\t1\t0\t22\t0\t0\t0\t0\t3\n+315\t24\t1\t0\t23\t1\t1\t0\t0\t1\n+316\t11\t1\t0\t19\t1\t0\t0\t0\t18\n+317\t52\t0\t0\t18\t1\t0\t0\t1\t3\n+318\t52\t0\t1\t38\t0\t1\t0\t1\t2\n+319\t52\t0\t1\t18\t0\t0\t0\t1\t6\n+320\t52\t0\t0\t22\t1\t1\t1\t1\t1\n+321\t33\t1\t0\t21\t1\t0\t0\t1\t3\n+322\t52\t0\t0\t21\t1\t1\t0\t1\t1\n+323\t46\t1\t1\t21\t1\t0\t0\t1\t5\n+324\t36\t1\t1\t17\t1\t0\t0\t1\t3\n+325\t52\t0\t1\t22\t1\t1\t0\t1\t1\n+326\t52\t0\t1\t23\t1\t1\t1\t1\t0\n+327\t18\t1\t1\t19\t1\t0\t0\t1\t4\n+328\t52\t0\t1\t21\t1\t1\t0\t0\t1\n+329\t52\t0\t1\t35\t1\t1\t0\t0\t5\n+330\t50\t1\t0\t23\t1\t1\t0\t0\t8\n+331\t52\t0\t1\t22\t1\t0\t0\t0\t2\n+332\t34\t1\t1\t25\t1\t0\t0\t0\t11\n+333\t52\t0\t1\t20\t1\t1\t0\t0\t4\n+334\t35\t1\t1\t19\t0\t0\t0\t0\t1\n+335\t52\t0\t0\t20\t1\t0\t0\t0\t1\n+336\t52\t0\t1\t41\t0\t1\t1\t1\t3\n+337\t39\t1\t0\t23\t0\t1\t0\t1\t4\n+338\t9\t1\t1\t26\t1\t1\t0\t0\t0\n+339\t52\t0\t0\t26\t1\t0\t0\t0\t2\n+340\t52\t0\t1\t38\t1\t1\t0\t1\t1\n+341\t52\t0\t0\t27\t1\t1\t0\t1\t1\n+342\t34\t1\t1\t19\t1\t0\t0\t1\t3\n+343\t52\t0\t0\t25\t1\t1\t0\t0\t1\n+344\t52\t0\t1\t30\t1\t1\t0\t0\t2\n+345\t52\t0\t1\t42\t1\t1\t0\t0\t1\n+346\t44\t1\t0\t20\t1\t1\t0\t1\t2\n+347\t52\t0\t1\t23\t1\t1\t0\t1\t1\n+348\t52\t0\t0\t21\t1\t0\t0\t1\t3\n+349\t35\t1\t1\t20\t1\t1\t0\t0\t3\n+350\t30\t1\t0\t17\t1\t0\t0\t0\t1\n+351\t39\t1\t1\t26\t1\t0\t1\t0\t5\n+352\t52\t0\t1\t24\t1\t1\t0\t1\t1\n+353\t52\t0\t0\t37\t1\t1\t1\t1\t1\n+354\t52\t0\t0\t28\t1\t1\t1\t1\t1\n+355\t52\t0\t0\t33\t1\t1\t0\t1\t0\n+356\t19\t1\t1\t22\t1\t0\t0\t1\t4\n+357\t52\t0\t0\t25\t1\t1\t1\t1\t2\n+358\t43\t1\t0\t20\t0\t0\t1\t0\t10\n+359\t52\t0\t0\t20\t1\t0\t0\t0\t1\n+360\t48\t1\t1\t24\t0\t1\t0\t0\t4\n+361\t37\t1\t1\t26\t0\t0\t0\t0\t11\n+362\t20\t1\t1\t26\t1\t1\t0\t1\t1\n+363\t52\t0\t0\t25\t0\t1\t0\t1\t1\n+364\t52\t0\t0\t26\t1\t1\t0\t1\t1\n+365\t36\t1\t1\t23\t1\t0\t0\t0\t3\n+366\t52\t0\t1\t28\t1\t0\t0\t1\t4\n+367\t52\t0\t0\t27\t1\t1\t0\t1\t0\n+368\t52\t0\t1\t23\t1\t0\t0\t0\t3\n+369\t52\t0\t0\t17\t1\t0\t0\t1\t7\n+370\t52\t0\t0\t20\t0\t0\t0\t1\t4\n+371\t52\t0\t1\t20\t1\t0\t0\t1\t5\n+372\t52\t0\t1\t20\t0\t0\t0\t1\t9\n+373\t30\t1\t1\t22\t1\t1\t0\t1\t2\n+374\t52\t0\t0\t31\t1\t0\t0\t1\t1\n+375\t52\t0\t0\t43\t1\t1\t0\t0\t1\n+376\t52\t0\t0\t29\t1\t1\t0\t0\t1\n+377\t52\t0\t1\t21\t1\t0\t0\t0\t0\n+378\t52\t0\t0\t24\t0\t1\t0\t0\t2\n+379\t52\t0\t1\t30\t1\t1\t1\t0\t3\n+380\t52\t0\t0\t22\t1\t1\t0\t0\t0\n+381\t52\t0\t1\t26\t1\t1\t1\t0\t1\n+382\t42\t1\t1\t20\t1\t1\t0\t0\t0\n+383\t52\t0\t0\t23\t1\t1\t0\t0\t6\n+384\t52\t0\t0\t25\t1\t1\t0\t1\t5\n+385\t52\t0\t1\t40\t1\t1\t0\t1\t2\n+386\t52\t0\t1\t30\t1\t1\t1\t1\t0\n+387\t26\t1\t0\t22\t1\t0\t1\t1\t2\n+388\t40\t1\t0\t18\t1\t0\t0\t1\t2\n+389\t52\t0\t0\t18\t1\t0\t0\t1\t0\n+390\t52\t0\t0\t24\t1\t1\t0\t1\t2\n+391\t52\t0\t1\t25\t1\t1\t1\t1\t2\n+392\t35\t1\t1\t19\t1\t0\t0\t1\t2\n+393\t52\t0\t0\t24\t1\t1\t0\t1\t2\n+394\t46\t1\t0\t24\t1\t0\t1\t1\t2\n+395\t52\t0\t0\t18\t1\t1\t0\t1\t3\n+396\t49\t1\t1\t18\t1\t1\t0\t1\t0\n+397\t52\t0\t0\t23\t1\t1\t0\t0\t0\n+398\t52\t0\t0\t20\t1\t0\t0\t1\t2\n+399\t49\t1\t1\t18\t1\t1\t0\t1\t1\n+400\t52\t0\t0\t23\t1\t1\t0\t1\t2\n+401\t52\t0\t1\t20\t1\t0\t0\t1\t1\n+402\t52\t0\t0\t23\t1\t0\t0\t0\t5\n+403\t52\t0\t0\t23\t1\t1\t0\t1\t1\n+404\t52\t0\t0\t23\t1\t1\t1\t1\t2\n+405\t35\t1\t0\t20\t1\t1\t0\t1\t4\n+406\t52\t0\t1\t26\t1\t1\t1\t0\t4\n+407\t52\t0\t1\t30\t1\t0\t0\t0\t1\n+408\t52\t0\t1\t36\t0\t1\t0\t0\t4\n+409\t52\t0\t1\t43\t1\t1\t0\t0\t4\n+410\t27\t1\t0\t20\t0\t1\t0\t0\t1\n+411\t52\t0\t1\t24\t1\t1\t0\t1\t1\n+412\t52\t0\t0\t22\t1\t1\t0\t0\t1\n+413\t52\t0\t1\t20\t1\t0\t1\t0\t1\n+414\t52\t1\t0\t21\t1\t0\t0\t0\t0\n+415\t45\t1\t1\t18\t1\t0\t0\t0\t5\n+416\t4\t1\t0\t18\t1\t1\t0\t0\t1\n+417\t52\t1\t0\t33\t1\t1\t0\t1\t2\n+418\t36\t1\t1\t19\t1\t0\t0\t1\t2\n+419\t52\t0\t1\t21\t0\t1\t0\t1\t1\n+420\t52\t0\t1\t21\t1\t0\t0\t1\t1\n+421\t8\t1\t1\t21\t1\t1\t0\t1\t4\n+422\t15\t1\t1\t22\t1\t0\t0\t1\t3\n+423\t52\t0\t0\t18\t1\t0\t0\t1\t3\n+424\t19\t1\t0\t18\t1\t0\t0\t0\t2\n+425\t52\t0\t0\t24\t1\t1\t0\t1\t2\n+426\t12\t1\t1\t22\t1\t1\t1\t1\t2\n+427\t52\t0\t1\t31\t0\t1\t0\t1\t3\n+428\t52\t0\t0\t20\t1\t0\t0\t1\t1\n+429\t52\t0\t1\t20\t1\t1\t1\t1\t1\n+430\t52\t0\t0\t29\t1\t1\t0\t1\t3\n+431\t52\t0\t1\t24\t1\t1\t0\t1\t1\n' |
b |
diff -r 000000000000 -r dd49a7040643 lifelines_tool/run_log.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lifelines_tool/run_log.txt Wed Aug 09 11:12:16 2023 +0000 |
[ |
@@ -0,0 +1,107 @@ +## Lifelines tool starting. +Using data header = Index(['Unnamed: 0', 'week', 'arrest', 'fin', 'age', 'race', 'wexp', 'mar', + 'paro', 'prio'], + dtype='object') time column = week status column = arrest +### Lifelines test of Proportional Hazards results with prio, age, race, paro, mar, fin as covariates on test +<lifelines.CoxPHFitter: fitted with 432 total observations, 318 right-censored observations> + duration col = 'week' + event col = 'arrest' + baseline estimation = breslow + number of observations = 432 +number of events observed = 114 + partial log-likelihood = -659.00 + time fit was run = 2023-08-09 00:18:43 UTC + +--- + coef exp(coef) se(coef) coef lower 95% coef upper 95% exp(coef) lower 95% exp(coef) upper 95% +covariate +prio 0.10 1.10 0.03 0.04 0.15 1.04 1.16 +age -0.06 0.94 0.02 -0.10 -0.02 0.90 0.98 +race 0.32 1.38 0.31 -0.28 0.92 0.75 2.52 +paro -0.09 0.91 0.20 -0.47 0.29 0.62 1.34 +mar -0.48 0.62 0.38 -1.22 0.25 0.30 1.29 +fin -0.38 0.68 0.19 -0.75 -0.00 0.47 1.00 + + cmp to z p -log2(p) +covariate +prio 0.00 3.53 <0.005 11.26 +age 0.00 -2.95 <0.005 8.28 +race 0.00 1.04 0.30 1.75 +paro 0.00 -0.46 0.65 0.63 +mar 0.00 -1.28 0.20 2.32 +fin 0.00 -1.98 0.05 4.40 +--- +Concordance = 0.63 +Partial AIC = 1330.00 +log-likelihood ratio test = 32.77 on 6 df +-log2(p) of ll-ratio test = 16.39 + + + Bootstrapping lowess lines. May take a moment... + + + Bootstrapping lowess lines. May take a moment... + +The ``p_value_threshold`` is set at 0.01. Even under the null hypothesis of no violations, some +covariates will be below the threshold by chance. This is compounded when there are many covariates. +Similarly, when there are lots of observations, even minor deviances from the proportional hazard +assumption will be flagged. + +With that in mind, it's best to use a combination of statistical tests and visual tests to determine +the most serious violations. Produce visual plots using ``check_assumptions(..., show_plots=True)`` +and looking for non-constant lines. See link [A] below for a full example. + +<lifelines.StatisticalResult: proportional_hazard_test> + null_distribution = chi squared +degrees_of_freedom = 1 + model = <lifelines.CoxPHFitter: fitted with 432 total observations, 318 right-censored observations> + test_name = proportional_hazard_test + +--- + test_statistic p -log2(p) +age km 6.99 0.01 6.93 + rank 7.40 0.01 7.26 +fin km 0.02 0.90 0.15 + rank 0.01 0.91 0.13 +mar km 1.64 0.20 2.32 + rank 1.80 0.18 2.48 +paro km 0.06 0.81 0.31 + rank 0.07 0.79 0.34 +prio km 0.92 0.34 1.57 + rank 0.88 0.35 1.52 +race km 1.70 0.19 2.38 + rank 1.68 0.19 2.36 + + +1. Variable 'age' failed the non-proportional test: p-value is 0.0065. + + Advice 1: the functional form of the variable 'age' might be incorrect. That is, there may be +non-linear terms missing. The proportional hazard test used is very sensitive to incorrect +functional forms. See documentation in link [D] below on how to specify a functional form. + + Advice 2: try binning the variable 'age' using pd.cut, and then specify it in `strata=['age', +...]` in the call in `.fit`. See documentation in link [B] below. + + Advice 3: try adding an interaction term with your time variable. See documentation in link [C] +below. + + + Bootstrapping lowess lines. May take a moment... + + + Bootstrapping lowess lines. May take a moment... + + + Bootstrapping lowess lines. May take a moment... + + + Bootstrapping lowess lines. May take a moment... + + +--- +[A] https://lifelines.readthedocs.io/en/latest/jupyter_notebooks/Proportional%20hazard%20assumption.html +[B] https://lifelines.readthedocs.io/en/latest/jupyter_notebooks/Proportional%20hazard%20assumption.html#Bin-variable-and-stratify-on-it +[C] https://lifelines.readthedocs.io/en/latest/jupyter_notebooks/Proportional%20hazard%20assumption.html#Introduce-time-varying-covariates +[D] https://lifelines.readthedocs.io/en/latest/jupyter_notebooks/Proportional%20hazard%20assumption.html#Modify-the-functional-form +[E] https://lifelines.readthedocs.io/en/latest/jupyter_notebooks/Proportional%20hazard%20assumption.html#Stratification + |
b |
diff -r 000000000000 -r dd49a7040643 lifelines_tool/test-data/input_tab_sample --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lifelines_tool/test-data/input_tab_sample Wed Aug 09 11:12:16 2023 +0000 |
b |
b'@@ -0,0 +1,433 @@\n+\tweek\tarrest\tfin\tage\trace\twexp\tmar\tparo\tprio\n+0\t20\t1\t0\t27\t1\t0\t0\t1\t3\n+1\t17\t1\t0\t18\t1\t0\t0\t1\t8\n+2\t25\t1\t0\t19\t0\t1\t0\t1\t13\n+3\t52\t0\t1\t23\t1\t1\t1\t1\t1\n+4\t52\t0\t0\t19\t0\t1\t0\t1\t3\n+5\t52\t0\t0\t24\t1\t1\t0\t0\t2\n+6\t23\t1\t0\t25\t1\t1\t1\t1\t0\n+7\t52\t0\t1\t21\t1\t1\t0\t1\t4\n+8\t52\t0\t0\t22\t1\t0\t0\t0\t6\n+9\t52\t0\t0\t20\t1\t1\t0\t0\t0\n+10\t52\t0\t1\t26\t1\t0\t0\t1\t3\n+11\t52\t0\t0\t40\t1\t1\t0\t0\t2\n+12\t37\t1\t0\t17\t1\t1\t0\t1\t5\n+13\t52\t0\t0\t37\t1\t1\t0\t0\t2\n+14\t25\t1\t0\t20\t1\t0\t0\t1\t3\n+15\t46\t1\t1\t22\t1\t1\t0\t1\t2\n+16\t28\t1\t0\t19\t1\t0\t0\t0\t7\n+17\t52\t0\t0\t20\t1\t0\t0\t0\t2\n+18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22\t1\t1\t19\t1\t0\t0\t1\t10\n+85\t52\t0\t1\t22\t1\t1\t0\t1\t1\n+86\t52\t0\t0\t25\t1\t0\t0\t1\t3\n+87\t18\t1\t0\t22\t1\t0\t0\t0\t4\n+88\t52\t0\t1\t22\t1\t1\t0\t1\t4\n+89\t52\t0\t1\t24\t1\t0\t0\t1\t2\n+90\t52\t0\t0\t39\t1\t1\t1\t1\t4\n+91\t52\t0\t0\t21\t1\t1\t0\t1\t1\n+92\t52\t0\t1\t20\t1\t1\t0\t1\t2\n+93\t52\t0\t1\t24\t1\t0\t0\t0\t1\n+94\t52\t0\t0\t25\t1\t1\t0\t1\t2\n+95\t24\t1\t1\t21\t1\t1\t0\t0\t4\n+96\t52\t0\t1\t20\t1\t0\t0\t1\t1\n+97\t52\t0\t1\t19\t1\t0\t0\t1\t3\n+98\t52\t0\t1\t24\t1\t0\t0\t0\t2\n+99\t52\t0\t1\t24\t1\t1\t0\t1\t1\n+100\t2\t1\t0\t44\t1\t1\t0\t1\t2\n+101\t26\t1\t0\t32\t1\t1\t0\t0\t2\n+102\t52\t0\t0\t23\t1\t1\t0\t0\t3\n+103\t49\t1\t1\t19\t1\t0\t0\t1\t1\n+104\t52\t0\t0\t20\t1\t0\t0\t1\t1\n+105\t21\t1\t0\t27\t1\t1\t0\t1\t0\n+106\t48\t1\t0\t19\t1\t0\t0\t0\t6\n+107\t52\t0\t1\t21\t1\t1\t0\t0\t1\n+108\t52\t0\t0\t20\t1\t0\t0\t1\t1\n+109\t52\t0\t0\t25\t1\t0\t0\t1\t3\n+110\t52\t0\t0\t20\t1\t0\t0\t1\t6\n+111\t52\t0\t1\t23\t1\t1\t0\t1\t3\n+112\t52\t0\t0\t20\t1\t0\t0\t0\t2\n+113\t52\t0\t1\t30\t1\t1\t0\t0\t1\n+114\t52\t0\t0\t25\t1\t1\t1\t1\t0\n+115\t52\t0\t0\t22\t1\t1\t0\t1\t1\n+116\t52\t0\t0\t24\t1\t1\t0\t1\t3\n+117\t52\t0\t1\t18\t1\t0\t0\t0\t4\n+118\t8\t1\t1\t40\t1\t1\t0\t1\t1\n+119\t52\t0\t0\t22\t1\t0\t0\t1\t1\n+120\t52\t0\t1\t23\t1\t0\t0\t1\t6\n+121\t49\t1\t0\t21\t1\t1\t0\t1\t1\n+122\t52\t0\t1\t24\t0\t1\t1\t1\t2\n+123\t52\t0\t1\t24\t1\t0\t0\t1\t14\n+124\t52\t0\t0\t38\t1\t1\t0\t1\t2\n+125\t52\t0\t0\t26\t0\t1\t0\t0\t3\n+126\t52\t0\t1\t29\t1\t1\t0\t0\t1\n+127\t52\t0\t0\t21\t1\t0\t0\t1\t8\n+128\t52\t0\t1\t21\t1\t1\t1\t1\t2\n+129\t52\t0\t0\t22\t0\t0\t0\t1\t4\n+130\t8\t1\t0\t23\t1\t0\t0\t1\t5\n+131\t52\t0\t0\t27\t1\t1\t0\t0\t2\n+132\t52\t0\t1\t18\t1\t0\t0\t1\t2\n+133\t13\t1\t0\t23\t1\t0\t0\t0\t5\n+134\t52\t0\t1\t24\t1\t0\t0\t1\t2\n+135\t52\t0\t1\t21\t1\t0\t0\t0\t3\n+136\t52\t0\t1\t20\t1\t0\t0\t1\t4\n+137\t52\t0\t1\t27\t1\t1\t0\t0\t4\n+138\t8\t1\t1\t20\t1\t0\t0\t1\t11\n+139\t52\t0\t1\t29\t1\t1\t1\t1\t5\n+140\t33\t1\t0\t19\t1\t0\t0\t0\t10\n+141\t52\t0\t0\t20\t1\t0\t0\t0\t8\n+142\t52\t0\t1\t18\t1\t0\t0\t1\t0\n+143\t11\t1\t1\t19\t1\t0\t0\t1\t2\n+144\t52\t0\t1\t24\t1\t1\t0\t1\t1\n+145\t52\t0\t0\t28\t0\t1\t0\t1\t4\n+146\t52\t0\t1\t26\t1\t0\t0\t0\t4\n+147\t52\t0\t1\t17\t1\t0\t0\t1\t0\n+148\t52\t0\t0\t21\t1\t0\t0\t1\t3\n+149\t37\t1\t0\t34\t1\t1\t0\t0\t2\n+150\t52\t0\t1\t26\t1\t1\t0\t0\t1\n+151\t52\t0\t1\t43\t1\t1\t0\t1\t2\n+152\t52\t0\t0\t20\t1\t0\t0\t1\t0\n+153\t44\t1\t0\t20\t1\t1\t0\t1\t1\n+154\t52\t0\t0\t32\t1\t1\t0\t1\t1\n+155\t52\t1\t0\t25\t0\t1\t0\t1\t1\n+156\t52\t0\t1\t22\t1\t0\t0\t1\t1\n+157\t52\t0\t1\t31\t0\t1\t0\t1\t1\n+158\t52\t0\t1\t42\t1\t1\t1\t1\t4\n+159\t52\t0\t1\t32\t1\t1\t0\t0\t10\n+160\t52\t0\t1\t20\t1\t0\t0\t0\t8\n+161\t52\t0\t0\t20'..b'272\t32\t1\t1\t19\t1\t0\t0\t1\t0\n+273\t52\t0\t0\t18\t1\t0\t0\t1\t4\n+274\t52\t0\t1\t28\t1\t1\t0\t0\t0\n+275\t52\t0\t1\t22\t1\t1\t0\t0\t2\n+276\t52\t0\t1\t25\t1\t0\t0\t1\t1\n+277\t52\t0\t1\t28\t1\t1\t0\t0\t2\n+278\t52\t0\t1\t25\t1\t1\t0\t0\t2\n+279\t52\t0\t1\t20\t1\t1\t0\t0\t4\n+280\t52\t0\t1\t24\t1\t0\t0\t0\t5\n+281\t52\t0\t0\t24\t1\t1\t0\t0\t0\n+282\t52\t0\t1\t36\t0\t1\t0\t1\t2\n+283\t52\t0\t1\t34\t1\t1\t0\t0\t1\n+284\t31\t1\t0\t19\t1\t1\t0\t1\t5\n+285\t20\t1\t1\t23\t1\t0\t0\t1\t1\n+286\t40\t1\t0\t19\t1\t1\t0\t1\t3\n+287\t52\t0\t1\t40\t1\t1\t0\t0\t2\n+288\t52\t0\t1\t31\t1\t1\t0\t0\t2\n+289\t52\t0\t0\t23\t1\t1\t1\t1\t0\n+290\t52\t0\t0\t42\t1\t0\t0\t1\t2\n+291\t42\t1\t1\t26\t1\t1\t1\t1\t1\n+292\t52\t0\t0\t20\t1\t0\t0\t1\t9\n+293\t26\t1\t0\t27\t1\t1\t0\t1\t1\n+294\t52\t0\t1\t24\t1\t0\t0\t0\t5\n+295\t52\t0\t0\t25\t1\t0\t0\t0\t2\n+296\t52\t0\t1\t22\t1\t1\t0\t1\t3\n+297\t52\t0\t1\t20\t1\t0\t0\t1\t2\n+298\t52\t0\t1\t20\t1\t1\t0\t1\t2\n+299\t47\t1\t0\t22\t1\t0\t0\t1\t3\n+300\t52\t0\t0\t18\t1\t1\t0\t1\t1\n+301\t52\t0\t0\t20\t1\t1\t0\t1\t2\n+302\t40\t1\t0\t20\t1\t1\t0\t1\t1\n+303\t52\t0\t0\t22\t1\t1\t0\t1\t2\n+304\t52\t0\t1\t30\t1\t1\t1\t0\t2\n+305\t52\t0\t0\t36\t0\t1\t0\t0\t1\n+306\t52\t0\t0\t25\t0\t1\t1\t1\t5\n+307\t21\t1\t0\t29\t1\t0\t0\t1\t3\n+308\t52\t0\t0\t19\t1\t1\t0\t1\t3\n+309\t52\t0\t1\t24\t1\t1\t0\t1\t2\n+310\t52\t0\t1\t21\t1\t0\t0\t0\t0\n+311\t52\t0\t1\t35\t1\t1\t0\t1\t6\n+312\t52\t0\t1\t19\t0\t1\t0\t0\t4\n+313\t1\t1\t0\t20\t1\t0\t0\t0\t0\n+314\t43\t1\t0\t22\t0\t0\t0\t0\t3\n+315\t24\t1\t0\t23\t1\t1\t0\t0\t1\n+316\t11\t1\t0\t19\t1\t0\t0\t0\t18\n+317\t52\t0\t0\t18\t1\t0\t0\t1\t3\n+318\t52\t0\t1\t38\t0\t1\t0\t1\t2\n+319\t52\t0\t1\t18\t0\t0\t0\t1\t6\n+320\t52\t0\t0\t22\t1\t1\t1\t1\t1\n+321\t33\t1\t0\t21\t1\t0\t0\t1\t3\n+322\t52\t0\t0\t21\t1\t1\t0\t1\t1\n+323\t46\t1\t1\t21\t1\t0\t0\t1\t5\n+324\t36\t1\t1\t17\t1\t0\t0\t1\t3\n+325\t52\t0\t1\t22\t1\t1\t0\t1\t1\n+326\t52\t0\t1\t23\t1\t1\t1\t1\t0\n+327\t18\t1\t1\t19\t1\t0\t0\t1\t4\n+328\t52\t0\t1\t21\t1\t1\t0\t0\t1\n+329\t52\t0\t1\t35\t1\t1\t0\t0\t5\n+330\t50\t1\t0\t23\t1\t1\t0\t0\t8\n+331\t52\t0\t1\t22\t1\t0\t0\t0\t2\n+332\t34\t1\t1\t25\t1\t0\t0\t0\t11\n+333\t52\t0\t1\t20\t1\t1\t0\t0\t4\n+334\t35\t1\t1\t19\t0\t0\t0\t0\t1\n+335\t52\t0\t0\t20\t1\t0\t0\t0\t1\n+336\t52\t0\t1\t41\t0\t1\t1\t1\t3\n+337\t39\t1\t0\t23\t0\t1\t0\t1\t4\n+338\t9\t1\t1\t26\t1\t1\t0\t0\t0\n+339\t52\t0\t0\t26\t1\t0\t0\t0\t2\n+340\t52\t0\t1\t38\t1\t1\t0\t1\t1\n+341\t52\t0\t0\t27\t1\t1\t0\t1\t1\n+342\t34\t1\t1\t19\t1\t0\t0\t1\t3\n+343\t52\t0\t0\t25\t1\t1\t0\t0\t1\n+344\t52\t0\t1\t30\t1\t1\t0\t0\t2\n+345\t52\t0\t1\t42\t1\t1\t0\t0\t1\n+346\t44\t1\t0\t20\t1\t1\t0\t1\t2\n+347\t52\t0\t1\t23\t1\t1\t0\t1\t1\n+348\t52\t0\t0\t21\t1\t0\t0\t1\t3\n+349\t35\t1\t1\t20\t1\t1\t0\t0\t3\n+350\t30\t1\t0\t17\t1\t0\t0\t0\t1\n+351\t39\t1\t1\t26\t1\t0\t1\t0\t5\n+352\t52\t0\t1\t24\t1\t1\t0\t1\t1\n+353\t52\t0\t0\t37\t1\t1\t1\t1\t1\n+354\t52\t0\t0\t28\t1\t1\t1\t1\t1\n+355\t52\t0\t0\t33\t1\t1\t0\t1\t0\n+356\t19\t1\t1\t22\t1\t0\t0\t1\t4\n+357\t52\t0\t0\t25\t1\t1\t1\t1\t2\n+358\t43\t1\t0\t20\t0\t0\t1\t0\t10\n+359\t52\t0\t0\t20\t1\t0\t0\t0\t1\n+360\t48\t1\t1\t24\t0\t1\t0\t0\t4\n+361\t37\t1\t1\t26\t0\t0\t0\t0\t11\n+362\t20\t1\t1\t26\t1\t1\t0\t1\t1\n+363\t52\t0\t0\t25\t0\t1\t0\t1\t1\n+364\t52\t0\t0\t26\t1\t1\t0\t1\t1\n+365\t36\t1\t1\t23\t1\t0\t0\t0\t3\n+366\t52\t0\t1\t28\t1\t0\t0\t1\t4\n+367\t52\t0\t0\t27\t1\t1\t0\t1\t0\n+368\t52\t0\t1\t23\t1\t0\t0\t0\t3\n+369\t52\t0\t0\t17\t1\t0\t0\t1\t7\n+370\t52\t0\t0\t20\t0\t0\t0\t1\t4\n+371\t52\t0\t1\t20\t1\t0\t0\t1\t5\n+372\t52\t0\t1\t20\t0\t0\t0\t1\t9\n+373\t30\t1\t1\t22\t1\t1\t0\t1\t2\n+374\t52\t0\t0\t31\t1\t0\t0\t1\t1\n+375\t52\t0\t0\t43\t1\t1\t0\t0\t1\n+376\t52\t0\t0\t29\t1\t1\t0\t0\t1\n+377\t52\t0\t1\t21\t1\t0\t0\t0\t0\n+378\t52\t0\t0\t24\t0\t1\t0\t0\t2\n+379\t52\t0\t1\t30\t1\t1\t1\t0\t3\n+380\t52\t0\t0\t22\t1\t1\t0\t0\t0\n+381\t52\t0\t1\t26\t1\t1\t1\t0\t1\n+382\t42\t1\t1\t20\t1\t1\t0\t0\t0\n+383\t52\t0\t0\t23\t1\t1\t0\t0\t6\n+384\t52\t0\t0\t25\t1\t1\t0\t1\t5\n+385\t52\t0\t1\t40\t1\t1\t0\t1\t2\n+386\t52\t0\t1\t30\t1\t1\t1\t1\t0\n+387\t26\t1\t0\t22\t1\t0\t1\t1\t2\n+388\t40\t1\t0\t18\t1\t0\t0\t1\t2\n+389\t52\t0\t0\t18\t1\t0\t0\t1\t0\n+390\t52\t0\t0\t24\t1\t1\t0\t1\t2\n+391\t52\t0\t1\t25\t1\t1\t1\t1\t2\n+392\t35\t1\t1\t19\t1\t0\t0\t1\t2\n+393\t52\t0\t0\t24\t1\t1\t0\t1\t2\n+394\t46\t1\t0\t24\t1\t0\t1\t1\t2\n+395\t52\t0\t0\t18\t1\t1\t0\t1\t3\n+396\t49\t1\t1\t18\t1\t1\t0\t1\t0\n+397\t52\t0\t0\t23\t1\t1\t0\t0\t0\n+398\t52\t0\t0\t20\t1\t0\t0\t1\t2\n+399\t49\t1\t1\t18\t1\t1\t0\t1\t1\n+400\t52\t0\t0\t23\t1\t1\t0\t1\t2\n+401\t52\t0\t1\t20\t1\t0\t0\t1\t1\n+402\t52\t0\t0\t23\t1\t0\t0\t0\t5\n+403\t52\t0\t0\t23\t1\t1\t0\t1\t1\n+404\t52\t0\t0\t23\t1\t1\t1\t1\t2\n+405\t35\t1\t0\t20\t1\t1\t0\t1\t4\n+406\t52\t0\t1\t26\t1\t1\t1\t0\t4\n+407\t52\t0\t1\t30\t1\t0\t0\t0\t1\n+408\t52\t0\t1\t36\t0\t1\t0\t0\t4\n+409\t52\t0\t1\t43\t1\t1\t0\t0\t4\n+410\t27\t1\t0\t20\t0\t1\t0\t0\t1\n+411\t52\t0\t1\t24\t1\t1\t0\t1\t1\n+412\t52\t0\t0\t22\t1\t1\t0\t0\t1\n+413\t52\t0\t1\t20\t1\t0\t1\t0\t1\n+414\t52\t1\t0\t21\t1\t0\t0\t0\t0\n+415\t45\t1\t1\t18\t1\t0\t0\t0\t5\n+416\t4\t1\t0\t18\t1\t1\t0\t0\t1\n+417\t52\t1\t0\t33\t1\t1\t0\t1\t2\n+418\t36\t1\t1\t19\t1\t0\t0\t1\t2\n+419\t52\t0\t1\t21\t0\t1\t0\t1\t1\n+420\t52\t0\t1\t21\t1\t0\t0\t1\t1\n+421\t8\t1\t1\t21\t1\t1\t0\t1\t4\n+422\t15\t1\t1\t22\t1\t0\t0\t1\t3\n+423\t52\t0\t0\t18\t1\t0\t0\t1\t3\n+424\t19\t1\t0\t18\t1\t0\t0\t0\t2\n+425\t52\t0\t0\t24\t1\t1\t0\t1\t2\n+426\t12\t1\t1\t22\t1\t1\t1\t1\t2\n+427\t52\t0\t1\t31\t0\t1\t0\t1\t3\n+428\t52\t0\t0\t20\t1\t0\t0\t1\t1\n+429\t52\t0\t1\t20\t1\t1\t1\t1\t1\n+430\t52\t0\t0\t29\t1\t1\t0\t1\t3\n+431\t52\t0\t1\t24\t1\t1\t0\t1\t1\n' |
b |
diff -r 000000000000 -r dd49a7040643 lifelines_tool/test-data/readme_sample --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lifelines_tool/test-data/readme_sample Wed Aug 09 11:12:16 2023 +0000 |
[ |
@@ -0,0 +1,119 @@ +## Lifelines tool starting. +Using data header = Index(['Unnamed: 0', 'week', 'arrest', 'fin', 'age', 'race', 'wexp', 'mar', + 'paro', 'prio'], + dtype='object') time column = week status column = arrest +Logrank test for race - 0 vs 1 + +<lifelines.StatisticalResult: logrank_test> + t_0 = -1 + null_distribution = chi squared +degrees_of_freedom = 1 + alpha = 0.99 + test_name = logrank_test + +--- + test_statistic p -log2(p) + 0.58 0.45 1.16 +### Lifelines test of Proportional Hazards results with prio, age, race, paro, mar, fin as covariates on KM and CPH in lifelines test +<lifelines.CoxPHFitter: fitted with 432 total observations, 318 right-censored observations> + duration col = 'week' + event col = 'arrest' + baseline estimation = breslow + number of observations = 432 +number of events observed = 114 + partial log-likelihood = -659.00 + time fit was run = 2023-08-09 07:43:37 UTC + +--- + coef exp(coef) se(coef) coef lower 95% coef upper 95% exp(coef) lower 95% exp(coef) upper 95% +covariate +prio 0.10 1.10 0.03 0.04 0.15 1.04 1.16 +age -0.06 0.94 0.02 -0.10 -0.02 0.90 0.98 +race 0.32 1.38 0.31 -0.28 0.92 0.75 2.52 +paro -0.09 0.91 0.20 -0.47 0.29 0.62 1.34 +mar -0.48 0.62 0.38 -1.22 0.25 0.30 1.29 +fin -0.38 0.68 0.19 -0.75 -0.00 0.47 1.00 + + cmp to z p -log2(p) +covariate +prio 0.00 3.53 <0.005 11.26 +age 0.00 -2.95 <0.005 8.28 +race 0.00 1.04 0.30 1.75 +paro 0.00 -0.46 0.65 0.63 +mar 0.00 -1.28 0.20 2.32 +fin 0.00 -1.98 0.05 4.40 +--- +Concordance = 0.63 +Partial AIC = 1330.00 +log-likelihood ratio test = 32.77 on 6 df +-log2(p) of ll-ratio test = 16.39 + + + Bootstrapping lowess lines. May take a moment... + + + Bootstrapping lowess lines. May take a moment... + +The ``p_value_threshold`` is set at 0.01. Even under the null hypothesis of no violations, some +covariates will be below the threshold by chance. This is compounded when there are many covariates. +Similarly, when there are lots of observations, even minor deviances from the proportional hazard +assumption will be flagged. + +With that in mind, it's best to use a combination of statistical tests and visual tests to determine +the most serious violations. Produce visual plots using ``check_assumptions(..., show_plots=True)`` +and looking for non-constant lines. See link [A] below for a full example. + +<lifelines.StatisticalResult: proportional_hazard_test> + null_distribution = chi squared +degrees_of_freedom = 1 + model = <lifelines.CoxPHFitter: fitted with 432 total observations, 318 right-censored observations> + test_name = proportional_hazard_test + +--- + test_statistic p -log2(p) +age km 6.99 0.01 6.93 + rank 7.40 0.01 7.26 +fin km 0.02 0.90 0.15 + rank 0.01 0.91 0.13 +mar km 1.64 0.20 2.32 + rank 1.80 0.18 2.48 +paro km 0.06 0.81 0.31 + rank 0.07 0.79 0.34 +prio km 0.92 0.34 1.57 + rank 0.88 0.35 1.52 +race km 1.70 0.19 2.38 + rank 1.68 0.19 2.36 + + +1. Variable 'age' failed the non-proportional test: p-value is 0.0065. + + Advice 1: the functional form of the variable 'age' might be incorrect. That is, there may be +non-linear terms missing. The proportional hazard test used is very sensitive to incorrect +functional forms. See documentation in link [D] below on how to specify a functional form. + + Advice 2: try binning the variable 'age' using pd.cut, and then specify it in `strata=['age', +...]` in the call in `.fit`. See documentation in link [B] below. + + Advice 3: try adding an interaction term with your time variable. See documentation in link [C] +below. + + + Bootstrapping lowess lines. May take a moment... + + + Bootstrapping lowess lines. May take a moment... + + + Bootstrapping lowess lines. May take a moment... + + + Bootstrapping lowess lines. May take a moment... + + +--- +[A] https://lifelines.readthedocs.io/en/latest/jupyter_notebooks/Proportional%20hazard%20assumption.html +[B] https://lifelines.readthedocs.io/en/latest/jupyter_notebooks/Proportional%20hazard%20assumption.html#Bin-variable-and-stratify-on-it +[C] https://lifelines.readthedocs.io/en/latest/jupyter_notebooks/Proportional%20hazard%20assumption.html#Introduce-time-varying-covariates +[D] https://lifelines.readthedocs.io/en/latest/jupyter_notebooks/Proportional%20hazard%20assumption.html#Modify-the-functional-form +[E] https://lifelines.readthedocs.io/en/latest/jupyter_notebooks/Proportional%20hazard%20assumption.html#Stratification + |
b |
diff -r 000000000000 -r dd49a7040643 lifelines_tool/tongue.tab --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lifelines_tool/tongue.tab Wed Aug 09 11:12:16 2023 +0000 |
b |
@@ -0,0 +1,81 @@ +type time delta +1 1 1 +1 3 1 +1 3 1 +1 4 1 +1 10 1 +1 13 1 +1 13 1 +1 16 1 +1 16 1 +1 24 1 +1 26 1 +1 27 1 +1 28 1 +1 30 1 +1 30 1 +1 32 1 +1 41 1 +1 51 1 +1 65 1 +1 67 1 +1 70 1 +1 72 1 +1 73 1 +1 77 1 +1 91 1 +1 93 1 +1 96 1 +1 100 1 +1 104 1 +1 157 1 +1 167 1 +1 61 0 +1 74 0 +1 79 0 +1 80 0 +1 81 0 +1 87 0 +1 87 0 +1 88 0 +1 89 0 +1 93 0 +1 97 0 +1 101 0 +1 104 0 +1 108 0 +1 109 0 +1 120 0 +1 131 0 +1 150 0 +1 231 0 +1 240 0 +1 400 0 +2 1 1 +2 3 1 +2 4 1 +2 5 1 +2 5 1 +2 8 1 +2 12 1 +2 13 1 +2 18 1 +2 23 1 +2 26 1 +2 27 1 +2 30 1 +2 42 1 +2 56 1 +2 62 1 +2 69 1 +2 104 1 +2 104 1 +2 112 1 +2 129 1 +2 181 1 +2 8 0 +2 67 0 +2 76 0 +2 104 0 +2 176 0 +2 231 0 |