# 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)**
```shell
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+](https://www.python.org/) installed.
```shell
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:
```shell
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.)
Raw data
{
"_id": null,
"home_page": "https://github.com/clabe-wekesa/bayesian-mpn-calculator",
"name": "bayesian-mpn-calculator",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "bayesian inference, MPN, biostatistics, microbiology, pymc",
"author": "Clabe Wekesa",
"author_email": "simiyu86wekesa@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/44/b2/3323bbbdff9c351626147ec6dec5070fb34984142640509e08258fb37253/bayesian_mpn_calculator-0.1.0.tar.gz",
"platform": null,
"description": "# Bayesian MPN Calculator\nThis 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.\n\nThe 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.\n\n### Purpose of the Package\n\nThe 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.\n\n### Features\n\n- **Bayesian Inference**: Utilizes PyMC to perform Bayesian inference for MPN estimation, providing robust and credible results.\n- **Customizable Input**: Allows users to specify the number of replicates, dilution levels, and the location of positive count data within the CSV file.\n- **Output Options**: Exports the MPN estimates and credible intervals to a CSV file for further analysis.\n- **Optional Plotting**: Generates plots showing MPN estimates with 95% credible intervals, aiding in visualization and interpretation of results.\n\n### Input Data Format\n\nThe input data must be in a CSV file format. The file should contain:\n\n- **Site Identifiers**: A column containing unique identifiers for each site or sample (e.g., Site).\n- **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.\n\n**Example of Input Data (CSV File)**\n```shell\nSite,Dilution_1,Dilution_2,Dilution_3,Dilution_4,Dilution_5,Dilution_6,Dilution_7,Dilution_8\nSite_1,0,1,3,5,7,7,7,7\nSite_2,0,0,1,4,6,7,7,7\nSite_3,0,0,0,3,5,6,7,7\n```\n- `Site`: This column contains the identifiers for each site (e.g., Site_1, Site_2, Site_3).\n- `Dilution_1 to Dilution_8`: These columns contain the count of positive results for each dilution level.\n\n### Installation Instructions\n\n**1. Python Environment** \nEnsure that you have [Python 3.8+](https://www.python.org/) installed.\n\n```shell\npip install bayesian-mpn-calculator\n```\n**2. Dependencies** \nThe following dependencies will be installed automatically:\n\n- Click (for command-line interface)\n- PyMC (for Bayesian inference)\n- NumPy (for numerical operations)\n- Pandas (for data manipulation)\n- Matplotlib and Seaborn (for plotting)\n\n### Usage\nOnce installed, the tool can be executed from the command line. Below is an example usage:\n\n```shell\ncalculate-mpn --file-path 'path/to/MPN.csv' \\\n --num-replicates 7 \\\n --dilution-levels 1,10,100,1000,10000,100000,1000000,10000000 \\\n --counts-start-col 'Dilution_1' \\\n --output-path 'MPN_results.csv' \\\n --plot \\\n --id-col 'Site' \\\n --dpi 300 \\\n --fig-type 'png'\n```\n\nCommand-Line Options\nommand-Line Options\n- `-f, --file-path`: Path to the CSV file containing the data. (required)\n- `-n, --num-replicates`: Number of replicates per dilution level. (required)\n- `-D, --dilution-levels`: Comma-separated dilution levels (e.g., --dilution-levels 1,10,100). (required)\n- `-c, --counts-start-col`: The column index or name where the positive counts start. (required)\n- `-o, --output-path`: Path to save the output CSV file with MPN estimates and credible intervals. Default is 'MPN_results.csv'.\n- `-p, --plot/--no-plot`: Whether to generate a plot of the MPN results. Default is no plot.\n- `-i, --id-col`: Column name for the site identifiers in the CSV file. (required if --plot is used)\n- `-d, --dpi`: DPI for saving the plot. Default is 300.\n- `-ft, --fig-type`: File type for saving the plot (e.g., png, jpg). Default is 'png'.\n\n### Acknowledgment\nThe 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.) \n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A package to calculate Most Probable Number (MPN) using Bayesian inference.",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/clabe-wekesa/bayesian-mpn-calculator"
},
"split_keywords": [
"bayesian inference",
" mpn",
" biostatistics",
" microbiology",
" pymc"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "bdbd5b0df087ac83c798edecc0cd16bbf43cb0c8bd2e1f3b40db84adcb1d8d3f",
"md5": "4585fb5b70590593368a2ab0a619655e",
"sha256": "1a1f26322fe55da3eee41f32845dc397773ce0b88b889324763a9cf622db265a"
},
"downloads": -1,
"filename": "bayesian_mpn_calculator-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4585fb5b70590593368a2ab0a619655e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 6501,
"upload_time": "2024-08-19T19:47:20",
"upload_time_iso_8601": "2024-08-19T19:47:20.496193Z",
"url": "https://files.pythonhosted.org/packages/bd/bd/5b0df087ac83c798edecc0cd16bbf43cb0c8bd2e1f3b40db84adcb1d8d3f/bayesian_mpn_calculator-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "44b23323bbbdff9c351626147ec6dec5070fb34984142640509e08258fb37253",
"md5": "976167a124987588c7234dcc559ff9f0",
"sha256": "8749f17bf5c018e551b2987ee53993ded2956947b820db739f64f93f270b6d4a"
},
"downloads": -1,
"filename": "bayesian_mpn_calculator-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "976167a124987588c7234dcc559ff9f0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 5865,
"upload_time": "2024-08-19T19:47:22",
"upload_time_iso_8601": "2024-08-19T19:47:22.207645Z",
"url": "https://files.pythonhosted.org/packages/44/b2/3323bbbdff9c351626147ec6dec5070fb34984142640509e08258fb37253/bayesian_mpn_calculator-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-19 19:47:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "clabe-wekesa",
"github_project": "bayesian-mpn-calculator",
"github_not_found": true,
"lcname": "bayesian-mpn-calculator"
}