Skip to main content

BRACoD is a method to identify associations between bacteria and physiological variables in Microbiome data

Project description

BRACoD: Bayesian Regression Analysis of Compositional Data

Installation

Installation in python:

pip install BRACoD

There is also an R interface, which depends on the python version being installed. There is a helper function that will do it for you, but it might be easier to do it with pip. You can install via CRAN.

install.packages("BRACoD.R")

Or you can install via github.

devtools::install_github("ajverster/BRACoD/BRACoD.R")

Python Walkthrough

  1. Simulate some data and normalize it

    import BRACoD
    import numpy as np
    sim_counts, sim_y, contributions = BRACoD.simulate_microbiome_counts(BRACoD.df_counts_obesity)
    sim_relab = BRACoD.scale_counts(sim_counts)
    
  2. Run BRACoD

    trace = BRACoD.run_bracod(sim_relab, sim_y, n_sample = 1000, n_burn=1000, njobs=4)
    
  3. Examine the diagnostics

    BRACoD.convergence_tests(trace, sim_relab)
    
  4. Examine the results

    df_results = BRACoD.summarize_trace(trace, sim_counts.columns, 0.3)
    
  5. Compare the results to the simulated truth

    taxon_identified = df_results["taxon_num"].values
    taxon_actual = np.where(contributions != 0)[0]
    
    precision, recall, f1 = BRACoD.score(taxon_identified, taxon_actual)
    print("Precision: {}, Recall: {}, F1: {}".format(precision, recall, f1))
    
  6. Try with your real data. We have included some functions to help you threshold and process your data

    df_counts = BRACoD.threshold_count_data(BRACoD.df_counts_obesity)
    df_rel = BRACoD.scale_counts(df_counts)
    df_rel, Y = BRACoD.remove_null(df_rel, BRACoD.df_scfa_obesity["butyric"].values)
    trace = BRACoD.run_bracod(df_rel, Y, n_sample = 1000, n_burn=1000, njobs=4)
    df_results = BRACoD.summarize_trace(trace, df_rel.columns, 0.3)
    

The taxonomy information for these OTUs is available at BRACoD.df_taxonomy

R Walkthrough

  1. Simulate some data and normalize it

    library('BRACoD.R')
    data(obesity)
    r <- simulate_microbiome_counts(df_counts_obesity)
    
    sim_counts <- r$sim_counts
    sim_y <- r$sim_y
    contributions <- r$contributions
    sim_relab <- scale_counts(sim_counts)
    
  2. Run BRACoD

    trace <- run_bracod(sim_relab, sim_y, n_sample = 1000, n_burn=1000, njobs=4)
    
  3. Examine the diagnostics

    convergence_tests(trace, sim_relab)
    
  4. Examine the results

    df_results <- summarize_trace(trace, colnames(sim_counts))
    
  5. Compare the results to the simulated truth

    taxon_identified <- df_results$taxon_num
    taxon_actual <- which(contributions != 0)
    
    r <- score(taxon_identified, taxon_actual)
    
    print(sprintf("Precision: %.2f, Recall: %.2f, F1: %.2f", r$precision, r$recall, r$f1))
    
  6. Try with your real data. We have included some functions to help you threshold and process your data

    df_counts_obesity_sub <- threshold_count_data(df_counts_obesity)
    df_rel <- scale_counts(df_counts_obesity_sub)
    r <- remove_null(df_rel, df_scfa$butyric)
    df_rel <- r$df_rel
    Y <- r$Y
    
    trace <- run_bracod(df_rel, Y, n_sample = 1000, n_burn=1000, njobs=4)
    df_results <- summarize_trace(trace, colnames(df_counts_obesity_sub), 0.3)
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

BRACoD-0.3.6.tar.gz (68.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

BRACoD-0.3.6-py3-none-any.whl (121.3 kB view details)

Uploaded Python 3

File details

Details for the file BRACoD-0.3.6.tar.gz.

File metadata

  • Download URL: BRACoD-0.3.6.tar.gz
  • Upload date:
  • Size: 68.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.11

File hashes

Hashes for BRACoD-0.3.6.tar.gz
Algorithm Hash digest
SHA256 a29a094928febb13017843409b2aa35da69a382b451a090c140ad95743603915
MD5 2169129bed2077aa5edccf316830ec0e
BLAKE2b-256 58422f730e889ca1fdb83c3fd7f2f1f33af30c90927ca279d4c74dddf22fea1a

See more details on using hashes here.

File details

Details for the file BRACoD-0.3.6-py3-none-any.whl.

File metadata

  • Download URL: BRACoD-0.3.6-py3-none-any.whl
  • Upload date:
  • Size: 121.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.11

File hashes

Hashes for BRACoD-0.3.6-py3-none-any.whl
Algorithm Hash digest
SHA256 0dc8101d806768c3e2c42107e7f1917a7b9d4ad0a463423756bd7b5091094553
MD5 d5061a99bf9e85a8c7135dae92fd9e2e
BLAKE2b-256 80f765dbe2a50470a502eddc5dc6a37bae969559007dec8e100d2523c9d04a3a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page