Skip to content

Instantly share code, notes, and snippets.

View fedarko's full-sized avatar

Marcus Fedarko fedarko

View GitHub Profile
@fedarko
fedarko / align_q2_table_and_metadata.py
Last active July 25, 2019 05:51
Filter a QIIME 2 feature table and a metadata TSV file to shared samples
#! /usr/bin/env python3
import biom
from qiime2 import Artifact, Metadata
YOUR_QZA_TABLE_FILEPATH_GOES_HERE = "table.qza"
YOUR_METADATA_FILEPATH_GOES_HERE = "metadata.tsv"
# Load the table
tbl_qza = Artifact.load(YOUR_QZA_TABLE_FILEPATH_GOES_HERE)
t = tbl_qza.view(biom.Table)
@fedarko
fedarko / poisson-cat.py
Created April 17, 2019 22:18 — forked from mortonjt/poisson-cat.py
Closed form categorical Poisson regression
import numpy as np
import patsy
import pandas as pd
from biom import Table
# This is the main function
def poisson_cat(table, metadata, category, ref=None):
""" Poisson differential abundance.
Parameters