Bayesian tests for set enrichment.
Project description
Bayesian tests for set enrichment.
Installation
Install from PyPI
pip install brioche-enrichment
or install from the Github repository
git clone git@github.com:dpohanlon/brioche.git
pip install -r requirements.txt .
Usage
Prepare some data in a contingency table format, with row and column set annotations
row_names = ["a", "b", "c", ...]
col_names = ["l", "m", "n", ...]
data = np.array([[30, 27, 10, ...], [28, 25, 11, ...], [31, 29, 15, ...], ...])
Import Brioche and create the multi-set enrichment object
from brioche.multisetEnrichment import MultisetEnrichment
enrichment = MultisetEnrichment(data, col_names, row_names, likelihood_type="sum")
Optionally, specify whether there are total-sum constraints on the rows or columns
enrichment = MultisetEnrichment(data, row_names, col_names, row_constraint = True,
col_constraint = False, likelihood_type="sum")
likelihood_type
determines the form of the likelihood model for each cell, and also therefore what the 'null' model is. Both assume that each cell is a combination of a row and a column term, and a term that describes the deviation of the cell from the row and column terms:
$$n_{ij} = r_i + c_j + d_{ij}$$
When likelihood_type = 'sum'
, these are combined with a sum (the default), and when likelihood_type = 'prod'
these are multiplied.
Run the Markov-chain Monte Carlo inference on the enrichment model, retrieve samples from the posterior, and return a Pandas DataFrame of enrichment z scores
samples = enrichment.runMCMC(num_samples=10000)
results = enrichment.getSummary(samples)
Plot model parameters and enrichment posterior probability distributions
from brioche.plot import plotDeviations
plotDeviations(samples, threshold=2, x_labels=col_names, y_labels=row_names, name="test-")
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
Hashes for brioche_enrichment-0.1.2a0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ccc3ce8fb1a63cb673fd235e833ef53395e7025320b4246140c269a7aed0843 |
|
MD5 | 2e8bc5f493636696bf02ed05c7002e48 |
|
BLAKE2b-256 | c61a8edb3358820ad8eb5a554fa1de4b12dbc339ea497c33c21527cabcab611c |
Hashes for brioche_enrichment-0.1.2a0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1729e9b84ea2ebbd9573ff18b244fe326515d0655c8f3d5bd50214f9e1d7d317 |
|
MD5 | 590046e1da9ec7177a7ede01431991db |
|
BLAKE2b-256 | 3368c4bd37dd31237d1f105436c8e7ff3d6355de074d8ccc2fafa3cfa502fa23 |