Create survival curves using kaplanmeier, the log-rank test and making plots.
Project description
kaplanmeier
- kaplanmeier is Python package to compute the kaplan meier curves, log-rank test, and make the plot instantly. This work contains some parts of 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
- New environment can be created as following:
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
- Erdogan Taskesen, github: erdogant
Licence
- See LICENSE for details.
Donation
- This work is created and maintained in my free time. If you wish to buy me a Coffee for this work, it is very appreciated.
Project details
Release history Release notifications | RSS feed
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.2.tar.gz
(26.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kaplanmeier-0.1.2.tar.gz.
File metadata
- Download URL: kaplanmeier-0.1.2.tar.gz
- Upload date:
- Size: 26.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed93251901a5b8f8cce2ea1d03e38acf4d1046ffb726433aa07d4acca0b3422b
|
|
| MD5 |
d33873392ac529d5963399593556eed5
|
|
| BLAKE2b-256 |
a08dfb55c9416704a7e435d731527f470532a59a6df7e6772472b89077279ca0
|
File details
Details for the file kaplanmeier-0.1.2-py3-none-any.whl.
File metadata
- Download URL: kaplanmeier-0.1.2-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1109e9fb5e8e5a625fc5a9eab0efd03a70b6b9bbd0d99b261306c6b063219dcb
|
|
| MD5 |
c550c73c3c13e1a1c42c85d913b6d7ad
|
|
| BLAKE2b-256 |
86a3d99e4e62ee757ee43cfc61c36cdcfe258993c314f5a086b2c94eeecabf8c
|