Skip to main content

Reusable React-based UI for Dash apps that computes and plots a Kaplan-Meier curve entirely using raw event and time-to-event data passed from Dash app. It eliminates analysis libraries, making it lightweight and frontend-driven.

Project description

DashKaplanMeier Dash Component

Dash component built with React to render Kaplan–Meier survival curves with enhanced interactivity and styling options. This component is ideal for visualizing survival analysis data directly within Dash applications.

Features

  • Plot Kaplan–Meier survival curves from preprocessed data.
  • Support for multiple curves with different group labels.
  • Interactive tooltips and hover effects.
  • Customizable colors and dimensions.
  • Fully integrated with Dash callback system.

Installation

pip install dash-kaplan-meier

Install requirements

pip install dash
pip install lifelines

Usage

Here’s how to use the DashKaplanMeier component in your Dash app:

import dash
from dash import html, Dash
import dash_kaplan_meier as dkm
from dash_kaplan_meier.survival_stats import compute_survival_stats

# Example data
time        = [your time values list here]
event       = [your event values list here]
group       = [you rgroup values list here]

# Compute statistics
stats       = compute_survival_stats(time ,event, group)

# Dash app
app         = Dash()

# Dash app layout with DashKaplanMeier component
app.layout = html.Div([
    dkm.DashKaplanMeier(
        id              = 'km-example',
        time            = time,
        event           = event,
        group           = group,
        showCIs         = True,
        colors          = ['blue', 'green', 'red'],
        showStatistics  = True,
        logrankP        = stats["logrank_p"],
        coxP            = stats["cox_p"],
        hazardRatio     = stats["hazard_ratio"],
        layout          ={  'title': 'Kaplan-Meier Survival Curve Example',
                            "xaxis": {"title": {"text": "Time (months)"}},
                            "yaxis": {"title": {"text": "Survival Probability"}}},
        title           = "Kaplan-Meier curves",
        config          = {'responsive': True}
    )
])

if __name__ == '__main__':
    app.run(debug=True)

Plot Example

Survival Example

Contributing

See CONTRIBUTING.md

License

MIT License. See LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dash_kaplan_meier-0.1.2.tar.gz (1.4 MB view details)

Uploaded Source

File details

Details for the file dash_kaplan_meier-0.1.2.tar.gz.

File metadata

  • Download URL: dash_kaplan_meier-0.1.2.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for dash_kaplan_meier-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d06e6d5d3827b72d9070368cb25e2182e0a446ae290a8985e4f6db6b55f6e2e5
MD5 11182b0dd38aea88e9fc1479235120be
BLAKE2b-256 64b92d80f506a59cd77e7e303f220a21ea041334285cf295761ca25a3aeca8e2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page