Skip to main content

Create survival curves using kaplanmeier, the log-rank test and making plots.

Project description

kaplanmeier

PyPI Version License

  • kaplanmeier is Python package to compute the kaplan meier curves, log-rank test, and make the plot instantly. This work is build on the lifelines package.

Contents

Installation

  • Install kaplanmeier from PyPI (recommended). kaplanmeier is compatible with Python 3.6+ and runs on Linux, MacOS X and Windows.
  • Distributed under the MIT license.

Requirements

  • It is advisable to create a new environment. Pgmpy requires an older version of networkx and matplotlib.
conda create -n env_KM python=3.6
conda activate env_KM
pip install matplotlib numpy pandas seaborn lifelines

Quick Start

pip install kaplanmeier
  • Alternatively, install kaplanmeier from the GitHub source:
git clone https://github.com/erdogant/kaplanmeier.git
cd kaplanmeier
python setup.py install

Import kaplanmeier package

import kaplanmeier as km

Example:

df = km.example_data()
time_event=df['time']
censoring=df['Died'] 
labx=df['group']

# Compute survival
out=km.fit(time_event, censoring, labx)

Make figure with cii_alpha=0.05 (default)

km.plot(out)

km.plot(out, cmap='Set1', cii_lines=None, cii_alpha=0.05)

km.plot(out, cmap='Set1', cii_lines='line', cii_alpha=0.05)

km.plot(out, cmap=[(1, 0, 1),(0, 1, 1)])

km.plot(out, cmap='Set2')

km.plot(out, cmap='Set2', methodtype='custom')

  • df looks like this:
     time  Died  group
0     485     0      1
1     526     1      2
2     588     1      2
3     997     0      1
4     426     1      1
..    ...   ...    ...
175   183     0      1
176  3196     0      1
177   457     1      2
178  2100     1      1
179   376     0      1

[180 rows x 3 columns]

Citation

Please cite kaplanmeier in your publications if this is useful for your research. Here is an example BibTeX entry:

@misc{erdogant2019kaplanmeier,
  title={kaplanmeier},
  author={Erdogan Taskesen},
  year={2019},
  howpublished={\url{https://github.com/erdogant/kaplanmeier}},
}

References

Maintainers

Contribute

  • All kinds of contributions are welcome!

© Copyright

See LICENSE 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

kaplanmeier-0.1.1.tar.gz (29.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kaplanmeier-0.1.1-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file kaplanmeier-0.1.1.tar.gz.

File metadata

  • Download URL: kaplanmeier-0.1.1.tar.gz
  • Upload date:
  • Size: 29.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.5

File hashes

Hashes for kaplanmeier-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4a121ae71ec6fd0b9069947ae442b763f858aa1022ff1a31c480fc58551e54c8
MD5 ddc74af0c1ed35fbb209f48c56af9b57
BLAKE2b-256 a5d243d3b54b92fe44f145aa7a9510c008be27539d492b9f1ef08e2afbc357b5

See more details on using hashes here.

File details

Details for the file kaplanmeier-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: kaplanmeier-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.5

File hashes

Hashes for kaplanmeier-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 03c9405ce01d86da01f440db65f2493a154acee932e903ca3861a9790e4cb8a3
MD5 777a3032d4d9b53aeed6bb1f345774af
BLAKE2b-256 f3e6a2d8d6b8ee942a3201872d70a9fff4a8575a56882ca63ff1224660d3dadc

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