This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
# note that this is very preliminary + untested code | |
# We use pd.read_csv() because, unlike QIIME 2's Metadata object, it allows | |
# duplicate sample IDs. | |
import pandas as pd | |
import sys | |
if len(sys.argv) < 2: | |
raise ValueError("You need to specify a metadata file to check.") | |
df = pd.read_csv(sys.argv[1], sep='\t', index_col=0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
import re | |
import pandas as pd | |
from dateutil.parser import parse | |
m = pd.read_csv("metadata.tsv", sep='\t', index_col=0) | |
# Find all sample IDs in the metadata that include a "date" | |
# We assume that sample IDs that start with a 5-digit Qiita ID, then a period, | |
# then a two-character host ID string, then another period, will follow this | |
# convention. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
from qiime2 import Metadata | |
from dateutil.parser import parse | |
from dateutil.relativedelta import relativedelta | |
subject_id = "HOST SUBJECT ID" | |
subject_birthday = "HOST BIRTHDAY" | |
subject_birthday_datetime = parse(subject_birthday) | |
age_col_name = "subject_age_years" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NOTE: Assumes that there's a SAMPLE_METADATA environment variable declared pointing to a metadata file | |
# NOTE: Assumes that this metadata file contains BarcodeSequence and seq_run_ord columns | |
import pandas as pd | |
import os | |
md = pd.read_csv(os.environ["SAMPLE_METADATA"], sep="\t", index_col=0) | |
print("There are {} unique barcode sequences in this metadata file.".format(len(md["BarcodeSequence"].unique()))) | |
runs = tuple(md["seq_run_ord"].unique()) | |
print("Also, the {} runs listed in this metadata file are {}.".format(len(runs), runs)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# your link goes here | |
link = "https://github.com/knightlab-analyses/qurro-mackerel-analysis/blob/master/AnalysisOutput/qurro-plot.qzv" | |
# note: this will break if a repo/organization or subfolder is named "blob" -- would be ideal to use a fancy regex | |
# to be more precise here | |
print(link.replace("github.com", "raw.githubusercontent.com").replace("/blob/", "/")) | |
# example output link: | |
# https://raw.githubusercontent.com/knightlab-analyses/qurro-mackerel-analysis/master/AnalysisOutput/qurro-plot.qzv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
from qiime2 import Metadata | |
from dateutil.parser import parse | |
m = Metadata.load("metadata-with-age-and-ordinal-timestamp.tsv") | |
m_df = m.to_dataframe() | |
# Compute earliest date | |
min_date = None | |
for sample_id in m_df.index: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
from qiime2 import Metadata | |
from dateutil.parser import parse | |
from dateutil.relativedelta import relativedelta | |
m = Metadata.load("metadata-with-age.tsv") | |
m_df = m.to_dataframe() | |
m_df["ordinal-timestamp"] = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
""" | |
This is a small script that looks through the annotated taxonomies of all | |
features present in a dataset's negative control samples. It's handy for | |
checking that certain features are (for the most part) absent from these | |
samples. | |
This obviously isn't a very formal way of accounting for contamination, | |
but it is useful for quickly verifying that certain taxa are probably not | |
the product of contamination. (Better approaches include e.g. the decontam |
OlderNewer