pycompare

Python module for generating Bland-Altman plots

https://github.com/jaketmp/pycompare

Science Score: 23.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 10 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.8%) to scientific vocabulary

Keywords

data-science python visualization
Last synced: 6 months ago · JSON representation

Repository

Python module for generating Bland-Altman plots

Basic Info
  • Host: GitHub
  • Owner: jaketmp
  • License: mit
  • Language: Jupyter Notebook
  • Default Branch: main
  • Size: 284 KB
Statistics
  • Stars: 36
  • Watchers: 1
  • Forks: 15
  • Open Issues: 5
  • Releases: 7
Topics
data-science python visualization
Created almost 8 years ago · Last pushed over 2 years ago
Metadata Files
Readme License

README.md

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

See the example notebook (or the interactive version on Binder) for detailed examples of all the options.

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.

Paired measurmentes from each set should be passed in data1 and data2 with each containing a list of values from one of the methods.

The range of the limits of agreement is 1.96 by default, and can be customised with the limitOfAgreement= argument.

By default confidance intervals are plotted over the 95% range, this can be customised to the x% range by passing the argument confidenceInterval=x or removed with confidenceInterval=None.

There are two options for plotting confidence intervals on the mean difference and limit of agreement: - [default] 'approximate' uses the approximate method described by Bland & Altman - 'exact paired' uses the exact paired method described by Carkeet

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 a much slower plotting time.

A multiplicative offset between the two measures can be modeled with the detrend= argument, which supports the following options: - [default] None do not attempt to detrend data - plots the 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.

If passed as True, the percentage= argument plots the percentage difference between measures, instead of 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)

Full list of arguments

blandAltman(data1, data2)

  • data1 (list like) – List of values from the first method
  • data2 (list like) – List of paired values from the second method
  • limitOfAgreement (float) – Multiple of the standard deviation to plot limit of agreement bounds at (defaults to 1.96)
  • confidenceInterval (None* or *float) – If not None, plot the specified percentage confidence interval on the mean and limits of agreement
  • confidenceIntervalMethod (str) – Method used to calculated confidence interval on the limits of agreement
  • detrend (None* or *str) – If not None attempt to detrend by the method specified
  • percentage (bool) – If True, plot differences as percentages (instead of in the units the data sources are in)
  • title (str) – Title text for the figure
  • ax (matplotlib.axes._subplots.AxesSubplot) – Matplotlib axis handle - if not None draw into this axis rather than creating a new figure
  • figureSize ((float, *float*)) – Figure size as a tuple of (width, height) in inches
  • dpi (int) – Figure resolution
  • savePath (str) – If not None, save figure at this path
  • figureFormat (str) – When saving figure use this format
  • meanColour (str) – Colour to use for plotting the mean difference
  • loaColour (str) – Colour to use for plotting the limits of agreement
  • pointColour (str) – Colour for plotting data points

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.

Owner

  • Login: jaketmp
  • Kind: user
  • Company: @ImperialCollegeLondon @phenomecentre @csmsoftware

GitHub Events

Total
  • Watch event: 1
Last Year
  • Watch event: 1

Committers

Last synced: over 2 years ago

All Time
  • Total Commits: 81
  • Total Committers: 4
  • Avg Commits per committer: 20.25
  • Development Distribution Score (DDS): 0.037
Past Year
  • Commits: 10
  • Committers: 3
  • Avg Commits per committer: 3.333
  • Development Distribution Score (DDS): 0.2
Top Committers
Name Email Commits
Jake TM Pearce j****t@g****m 78
asch99 a****9@u****m 1
dependabot[bot] 4****]@u****m 1
Lee Tirrell l****l@u****m 1

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 11
  • Total pull requests: 7
  • Average time to close issues: 9 months
  • Average time to close pull requests: about 1 month
  • Total issue authors: 8
  • Total pull request authors: 5
  • Average comments per issue: 1.55
  • Average comments per pull request: 1.71
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 3
Past Year
  • Issues: 1
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 0.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • jaketmp (4)
  • chaplinta (1)
  • TSSlade (1)
  • hoechenberger (1)
  • constructor-s (1)
  • ltirrell (1)
  • philippaichinger (1)
  • Yanda-Meng (1)
Pull Request Authors
  • dependabot[bot] (3)
  • asch99 (1)
  • haesleinhuepf (1)
  • hoechenberger (1)
  • ltirrell (1)
Top Labels
Issue Labels
enhancement (1) wontfix (1) bug (1)
Pull Request Labels
dependencies (3)

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 594 last-month
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 1
    (may contain duplicates)
  • Total versions: 23
  • Total maintainers: 1
pypi.org: pycompare

Bland-Altman plots for Python

  • Versions: 15
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 594 Last month
Rankings
Downloads: 6.7%
Forks count: 9.6%
Dependent packages count: 10.0%
Stargazers count: 11.3%
Average: 11.8%
Dependent repos count: 21.7%
Maintainers (1)
Last synced: 6 months ago
conda-forge.org: pycompare
  • Versions: 8
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Forks count: 43.4%
Average: 43.5%
Stargazers count: 43.5%
Last synced: 6 months ago

Dependencies

requirements.txt pypi
  • matplotlib ==3.3.4
  • numpy ==1.19.5
  • pandas ==1.1.5
  • scipy ==1.5.4
setup.py pypi
  • matplotlib >=3.0.2
  • numpy >=1.18.1
  • scipy >=1.0.1