Skip to main content

Bland-Altman plots for Python

Project description

pyCompare

Build Status codecov PyPI - Python Version DOI PyPI Binder

A Python module for generating Bland-Altman plots to compare two sets of measurements.

You can try out the code using Binder.

Installation

To install via pip, run:

pip install pyCompare

Installation with pip allows the usage of the uninstall command:

pip uninstall pyCompare

Documentation

blandAltman( )

blandAltman(data1, data2,
            limitOfAgreement=1.96,
            confidenceInterval=95,
            confidenceIntervalMethod='approximate',
            detrend=None,
            percentage=False,
            **kwargs)

Generate a Bland-Altman plot to compare two sets of measurements of the same value.

data1 and data2 should be 1D numpy arrays of equal length containing the paired measurements.

If not None plot confidence interval over the x% range with confidenceInterval=x

Confidence intervals on the mean difference and limit of agreement may be calculated using:

  • 'exact paired' uses the exact paired method described by Carkeet
  • 'approximate' uses the approximate method described by Bland & Altman

The 'exact paired' method will give more accurate confidence intervals on the limits of agreement when the number of paired measurements is low (approx < 100), at the expense of much slower plotting time.

The detrend parameter supports the following options:

  • None do not attempt to detrend data - plots raw values
  • 'Linear' attempt to model and remove a multiplicative offset between each assay by linear regression
  • 'ODR' attempt to model and remove a multiplicative offset between each assay by orthogonal distance regression

'ODR' is the recommended method if you do not use None.

When True, the percentage option plots the difference between methods as a percentage, instead of in the units the methods were measured in.

Plots are displayed using the current matplotlib backend by default, or may be saved with the savePath= argument.

When saving, png format graphics are saved by default:

blandAltman(data1, data2,
            savePath='SavedFigure.png')

The save format type can be chosen from those known by matplotlib with the figureFormat= argument:

blandAltman(data1, data2,
            savePath='SavedFigure.svg',
            figureFormat='svg)

References

To cite pyCompare, use the Zendo DOI: 10.5281/zenodo.1238915.

  • Altman, D. G., and Bland, J. M. “Measurement in Medicine: The Analysis of Method Comparison Studies” Journal of the Royal Statistical Society. Series D (The Statistician), vol. 32, no. 3, 1983, pp. 307–317. JSTOR.
  • Altman, D. G., and Bland, J. M. “Measuring agreement in method comparison studies” Statistical Methods in Medical Research, vol. 8, no. 2, 1999, pp. 135–160. DOI.
  • Carkeet, A. "Exact Parametric Confidence Intervals for Bland-Altman Limits of Agreement" Optometry and Vision Science, vol. 92, no 3, 2015, pp. e71–e80 DOI.

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

pyCompare-1.4.1.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

pyCompare-1.4.1-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file pyCompare-1.4.1.tar.gz.

File metadata

  • Download URL: pyCompare-1.4.1.tar.gz
  • Upload date:
  • Size: 9.3 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.1

File hashes

Hashes for pyCompare-1.4.1.tar.gz
Algorithm Hash digest
SHA256 593a3e6854d8ba3dd0e037500e109c691e8231ec30e93efdc33509314c91059e
MD5 d494bc3972a884bfc6c14667743ae338
BLAKE2b-256 b0b03b51f74aafc5f9a084493a13074d0a7962ef6d5573c89bdcf77e58fbb878

See more details on using hashes here.

File details

Details for the file pyCompare-1.4.1-py3-none-any.whl.

File metadata

  • Download URL: pyCompare-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 11.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.1

File hashes

Hashes for pyCompare-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b58ced78f3232cfa40f5fe233723e46b24dbcc55848069ac58db6777dcb90c73
MD5 a216dddc7f9f2a8768f3cc14d30d7b08
BLAKE2b-256 2e73a2bc200966f217964b87c000125d5f518739ff5997bad941c8d263961d34

See more details on using hashes here.

Supported by

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