Add x-axis range control and color customization to Kaplan-Meier plots#26
Add x-axis range control and color customization to Kaplan-Meier plots#26
Conversation
Co-authored-by: hroskes <5262585+hroskes@users.noreply.github.com>
Co-authored-by: hroskes <5262585+hroskes@users.noreply.github.com>
Co-authored-by: hroskes <5262585+hroskes@users.noreply.github.com>
|
@copilot That was a good idea to include xmax itself in the time point selection. That being the case, we don't need to include the first time > xmax. |
Co-authored-by: hroskes <5262585+hroskes@users.noreply.github.com>
Updated in commit e2cc023. The implementation now only includes times ≤ xmax and xmax itself, without the first time > xmax. This simplifies the algorithm while maintaining smooth curve termination at the boundary. |
|
@copilot Please also add command line arguments to vary the color for a single or two_groups Kaplan-Meier plot. We should give a few options (e.g. blue, red, green, and others) that the user can specify. The best fit curve should be that color, while the confidence level bands should be variations of the color, similar to how it's done now (except that currently that colors are hardcoded). Please also remove the XMAX_USAGE.md and instead document it more similar to how the other documentation in the repo is done. Also, please incorporate the new tests into the GitHub Actions workflow. |
Co-authored-by: hroskes <5262585+hroskes@users.noreply.github.com>
Completed in commit 6821239:
Example usage: kombine datacard.txt output.pdf --color green
kombine_twogroups datacard.txt output.pdf --parameter-threshold 0.45 --high-color purple --low-color orange |
|
Please revert the changes to Instead, please make a new Markdown file, with no Python cells, illustrating the command line interface. Please document all command line options in that file, organized into logical groups via Markdown headers. Please also implement a unit test that checks that all command line options for KoMbine are documented in that file. Please also document the documentation structure in .github/copilot-instructions.md. |
…ctional doc test Co-authored-by: hroskes <5262585+hroskes@users.noreply.github.com>
Completed in commit 6caae84:
|
|
Please fix pylint. Note that pylint is configured to expect two-space indentation. Also, there is some trailing whitespace. Please document in copilot-instructions.md that indents should be two spaces and to check pylint after editing and fix any errors. Nontrivial errors that would require major refactoring to fix can be ignored via magic pylint comments. Also, please make sure that 05_command_line_interface.md can be converted via jupytext as the other notebooks can. It won't have pure python, but should still run through Jupytext as the table of contents does. Also, please test that the table of contents is synced with the actual documentation in the folder. You can put this test in test_cli_documentation.py and rename it to test_documentation.py. |
…ilot-instructions Co-authored-by: hroskes <5262585+hroskes@users.noreply.github.com>
Completed in commit 8161b55:
|
|
@copilot |
Co-authored-by: hroskes <5262585+hroskes@users.noreply.github.com>
Updated in commit 11fbaf7. The Direction 1: Verifies all documentation files are listed in the TOC The test now catches both missing documentation and broken references in the table of contents. |
|
I'm getting errors when converting I don't want those commands to be run, but I do want the code to be displayed in markdown with code tags. In other words, I want the converted notebook to only have markdown cells, but I do want the command line examples to be there. |
Co-authored-by: hroskes <5262585+hroskes@users.noreply.github.com>
Fixed in commit 0e624f3. Changed all code blocks in When converted to Jupyter notebook via Jupytext, the file now produces only markdown cells (no executable bash cells). The command-line examples are displayed as formatted code within markdown, exactly as requested. |
|
Please merge |
Co-authored-by: hroskes <5262585+hroskes@users.noreply.github.com>
…d edge cases Co-authored-by: hroskes <5262585+hroskes@users.noreply.github.com>
Co-authored-by: hroskes <5262585+hroskes@users.noreply.github.com>
Task: Add x-axis range control and color customization to Kaplan-Meier plots ✅ COMPLETE
Recent Updates (addressing final review feedback)
Fixed pylint issues:
Added Jupytext header to
05_command_line_interface.md:jupytext --synclike other documentation files```bashto```to display as markdown examples instead of executable cellsRenamed and enhanced test file:
test_cli_documentation.py→test_documentation.pytest_table_of_contents_sync()- now bidirectional:Consolidated and expanded plotting tests:
test_xmax.pyandtest_xmax_edge_cases.pyintotest_km_plotting.pyUpdated
.github/copilot-instructions.md:Updated GitHub Actions workflow:
test_cli_documentationtotest_documentationImplementation Summary
This PR successfully adds x-axis range control to Kaplan-Meier plots through the
xmaxparameter and color customization through--colorarguments.Changes Made
kaplan_meier.py
get_times_for_plot(xmax)method implementing the time selection algorithmtimes_for_plotpropertykaplan_meier_likelihood.py
xmax: float | NonetoKaplanMeierPlotConfigdataclassplot()to useget_times_for_plot(xmax=config.xmax)_finalize_plot()to set x-axis limits:ax.set_xlim(0, xmax)command_line_interface.py
--xmaxCLI argument--colorargument for single plots (8 color options)--high-colorand--low-colorarguments for two-group plots_make_kombine_parser(),_make_kombine_twogroups_parser()) from execution_extract_common_plot_config_args()Documentation
docs/kombine/05_command_line_interface.md- Complete CLI reference with Jupytext header```instead of```bash) so examples display as markdown, not executable cellsdocs/kombine/01_table_of_contents.mdto include new file.github/copilot-instructions.mdwith code style guidelines and documentation structureTests
test_km_plotting.py- Comprehensive KM plotting tests (21 tests) including:test_documentation.py- Bidirectional CLI↔docs testing + bidirectional TOC sync verificationValidation Results
✅ All Success Criteria Met:
--xmaxparameter without errors in both commands--color,--high-color,--low-color)✅ Quality Checks:
Test Coverage
KM Plotting Tests (21 tests with enhanced validation):
Key Test Enhancements:
test_plot_with_custom_title_labels: Verifies title and labels are actually set viaax.get_title(),ax.get_xlabel(),ax.get_ylabel()test_plot_with_custom_figsize: Verifies figure size viafig.get_size_inches()test_plot_exclude_nominal: Verifies nominal line is not in plot by checkingax.get_lines()test_plot_no_legend: Tests legend_loc=None configurationUsage Examples
CLI with xmax:
CLI with custom colors:
Python API:
See
docs/kombine/05_command_line_interface.mdfor complete CLI documentation.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.