Skip to main content

Bayesian MPN Calculator

This Python application calculates the Most Probable Number (MPN) using Bayesian inference, leveraging the PyMC library for robust statistical modeling. It enables users to estimate MPN and its credible intervals from microbiological data, typically used in determining the concentration of viable microorganisms in a sample.

The application is command-line driven, making it easy to integrate into automated workflows or larger data analysis pipelines. Users can input data from a CSV file, specify the number of replicates and dilution levels, and optionally generate plots of the MPN estimates with their credible intervals.

Purpose of the Package

The Bayesian MPN Calculator is tailored for microbiologists and data scientists who need a reliable and statistically sound method for calculating MPN. The package uses Bayesian inference to provide more robust estimates compared to traditional methods, along with credible intervals that offer a clear measure of uncertainty.

Features

  • Bayesian Inference: Utilizes PyMC to perform Bayesian inference for MPN estimation, providing robust and credible results.
  • Customizable Input: Allows users to specify the number of replicates, dilution levels, and the location of positive count data within the CSV file.
  • Output Options: Exports the MPN estimates and credible intervals to a CSV file for further analysis.
  • Optional Plotting: Generates plots showing MPN estimates with 95% credible intervals, aiding in visualization and interpretation of results.

Input Data Format

The input data must be in a CSV file format. The file should contain:

  • Site Identifiers: A column containing unique identifiers for each site or sample (e.g., Site).
  • Positive Count Data: Several columns with the number of positive tubes or wells for each dilution level. The first column for positive counts is specified using the --counts-start-col option.

Example of Input Data (CSV File)

Site,Dilution_1,Dilution_2,Dilution_3,Dilution_4,Dilution_5,Dilution_6,Dilution_7,Dilution_8
Site_1,0,1,3,5,7,7,7,7
Site_2,0,0,1,4,6,7,7,7
Site_3,0,0,0,3,5,6,7,7
  • Site: This column contains the identifiers for each site (e.g., Site_1, Site_2, Site_3).
  • Dilution_1 to Dilution_8: These columns contain the count of positive results for each dilution level.

Installation Instructions

1. Python Environment
Ensure that you have Python 3.8+ installed.

pip install bayesian-mpn-calculator

2. Dependencies
The following dependencies will be installed automatically:

  • Click (for command-line interface)
  • PyMC (for Bayesian inference)
  • NumPy (for numerical operations)
  • Pandas (for data manipulation)
  • Matplotlib and Seaborn (for plotting)

Usage

Once installed, the tool can be executed from the command line. Below is an example usage:

calculate-mpn --file-path 'path/to/MPN.csv' \
              --num-replicates 7 \
              --dilution-levels 1,10,100,1000,10000,100000,1000000,10000000 \
              --counts-start-col 'Dilution_1' \
              --output-path 'MPN_results.csv' \
              --plot \
              --id-col 'Site' \
              --dpi 300 \
              --fig-type 'png'

Command-Line Options ommand-Line Options

  • -f, --file-path: Path to the CSV file containing the data. (required)
  • -n, --num-replicates: Number of replicates per dilution level. (required)
  • -D, --dilution-levels: Comma-separated dilution levels (e.g., --dilution-levels 1,10,100). (required)
  • -c, --counts-start-col: The column index or name where the positive counts start. (required)
  • -o, --output-path: Path to save the output CSV file with MPN estimates and credible intervals. Default is 'MPN_results.csv'.
  • -p, --plot/--no-plot: Whether to generate a plot of the MPN results. Default is no plot.
  • -i, --id-col: Column name for the site identifiers in the CSV file. (required if --plot is used)
  • -d, --dpi: DPI for saving the plot. Default is 300.
  • -ft, --fig-type: File type for saving the plot (e.g., png, jpg). Default is 'png'.

Acknowledgment

The development of this application builds on the capabilities of various Python libraries, especially PyMC for Bayesian inference and Pandas for data manipulation. These libraries provide the essential tools needed for robust statistical modeling and analysis in microbiological research.)

Metadata

Release files for bayesian-mpn-calculator 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bayesian-mpn-calculator 0.1.0
File Size Uploaded Provenance
bayesian_mpn_calculator-0.1.0.tar.gz 5.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for bayesian-mpn-calculator 0.1.0
File Interpreter ABI Platform
bayesian_mpn_calculator-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.4 kB

Release files / bayesian_mpn_calculator-0.1.0.tar.gz

Download URL bayesian_mpn_calculator-0.1.0.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8749f17bf5c018e551b2987ee53993ded2956947b820db739f64f93f270b6d4a
BLAKE2b-256 checksum
How to use checksums
44b23323bbbdff9c351626147ec6dec5070fb34984142640509e08258fb37253
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.7

Release files / bayesian_mpn_calculator-0.1.0-py3-none-any.whl

Download URL bayesian_mpn_calculator-0.1.0-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1a1f26322fe55da3eee41f32845dc397773ce0b88b889324763a9cf622db265a
BLAKE2b-256 checksum
How to use checksums
bdbd5b0df087ac83c798edecc0cd16bbf43cb0c8bd2e1f3b40db84adcb1d8d3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.7

Security for bayesian-mpn-calculator 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page