A package to calculate Most Probable Number (MPN) using Bayesian inference.
Project description
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.)
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
Built Distribution
File details
Details for the file bayesian_mpn_calculator-0.1.0.tar.gz
.
File metadata
- Download URL: bayesian_mpn_calculator-0.1.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8749f17bf5c018e551b2987ee53993ded2956947b820db739f64f93f270b6d4a |
|
MD5 | 976167a124987588c7234dcc559ff9f0 |
|
BLAKE2b-256 | 44b23323bbbdff9c351626147ec6dec5070fb34984142640509e08258fb37253 |
File details
Details for the file bayesian_mpn_calculator-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: bayesian_mpn_calculator-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a1f26322fe55da3eee41f32845dc397773ce0b88b889324763a9cf622db265a |
|
MD5 | 4585fb5b70590593368a2ab0a619655e |
|
BLAKE2b-256 | bdbd5b0df087ac83c798edecc0cd16bbf43cb0c8bd2e1f3b40db84adcb1d8d3f |