Tutorial
Installing QIIME 2¶
This tutorial uses the command line interface or cli. If you are uncomfortable with using the cli, this video serves as an introduction to basic cli usage.
Make sure you have conda installed by running the command conda --version. If you do not have conda installed follow the instructions here.
conda env create -n q2-amf-tutorial -f https://raw.githubusercontent.com/caporaso-lab/amf-tutorial/refs/heads/main/book/_static/environment.yml
conda activate q2-amf-tutorialIn order to use q2-fondue, you will first need to configure fondue. Instructions for doing so may be found here.
Sample metadata¶
This study investigates differences in AMF communities between modern high-yielding rice varieties (BR28, BR29, BR58) and local traditional varieties (Shampakatar, Ushapari), sampled from eight rice fields with five soil samples each. A total of 200 samples were collected, of which subsample of 143 AMF-relevant samples (79 from modern and 64 from traditional varieties), to test the hypothesis recorded in the metadata file. Before starting the analysis, explore the sample metadata to familiarize yourself with the samples used in this study. The following command will download the sample metadata as tab-separated text and save it in the file sample-metadata.tsv. This sample-metadata.tsv file is used throughout the rest of the tutorial.
wget -O 'metadata.tsv' \
'https://amf-tutorial.readthedocs.io/en/latest/data/amf-tutorial/metadata.tsv'
from qiime2 import Metadata
from urllib import request
url = 'https://amf-tutorial.readthedocs.io/en/latest/data/amf-tutorial/metadata.tsv'
fn = 'metadata.tsv'
request.urlretrieve(url, fn)
metadata_md = Metadata.load(fn)
- Using the
Upload Datatool: - On the first tab (Regular), press the
Paste/Fetchdata button at the bottom.- Set "Name" (first text-field) to:
metadata.tsv - In the larger text-area, copy-and-paste: https://
amf -tutorial .readthedocs .io /en /latest /data /amf -tutorial /metadata .tsv - ("Type", "Genome", and "Settings" can be ignored)
- Set "Name" (first text-field) to:
- Press the
Startbutton at the bottom.
- On the first tab (Regular), press the
library(reticulate)
Metadata <- import("qiime2")$Metadata
request <- import("urllib")$request
url <- 'https://amf-tutorial.readthedocs.io/en/latest/data/amf-tutorial/metadata.tsv'
fn <- 'metadata.tsv'
request$urlretrieve(url, fn)
metadata_md <- Metadata$load(fn)
metadata = use.init_metadata_from_url('metadata',
'https://www.dropbox.com/scl/fi/zgcnuetdxochydkb0o3bw/metadata_file_rice.tsv?rlkey=fo5ywq8549fn5optv1u1nh4m4&st=hzljxvx3&dl=1')metadata.tsv| download
Obtaining the data¶
In this tutorial, we will use q2-fondue to download our publicly available data and import them into QIIME 2. The data we use in this tutorial has already been imported into QIIME 2 for you. This video gives a basic overview of what importing data into QIIME 2 using a manifest file looks like.
First, let’s download the metadata containing the NCBI SRA project, accession number SRR13445888.
wget -O 'project-accession.qza' \
'https://amf-tutorial.readthedocs.io/en/latest/data/amf-tutorial/project-accession.qza'
from qiime2 import Artifact
url = 'https://amf-tutorial.readthedocs.io/en/latest/data/amf-tutorial/project-accession.qza'
fn = 'project-accession.qza'
request.urlretrieve(url, fn)
project_accession = Artifact.load(fn)
- Using the
Upload Datatool: - On the first tab (Regular), press the
Paste/Fetchdata button at the bottom.- Set "Name" (first text-field) to:
project-accession.qza - In the larger text-area, copy-and-paste: https://
amf -tutorial .readthedocs .io /en /latest /data /amf -tutorial /project -accession .qza - ("Type", "Genome", and "Settings" can be ignored)
- Set "Name" (first text-field) to:
- Press the
Startbutton at the bottom.
- On the first tab (Regular), press the
Artifact <- import("qiime2")$Artifact
url <- 'https://amf-tutorial.readthedocs.io/en/latest/data/amf-tutorial/project-accession.qza'
fn <- 'project-accession.qza'
request$urlretrieve(url, fn)
project_accession <- Artifact$load(fn)
project_accession = use.init_artifact_from_url('project-accession',
'https://www.dropbox.com/scl/fi/reb68ejk9qxkvyq4h3twr/project_ids.qza?rlkey=6iit6w5v7omzgqxvg4phgymjd&st=5q023rc9&dl=1')Then we can visualize it using qiime metadata tabulate.
qiime metadata tabulate \
--m-input-file project-accession.qza \
--o-visualization project-accession.qzvimport qiime2.plugins.metadata.actions as metadata_actions
project_accession_md_md = project_accession.view(Metadata)
project_accession_viz, = metadata_actions.tabulate(
input=project_accession_md_md,
)- Using the
qiime2 metadata tabulatetool: - For "input":
- Perform the following steps.
- Change to
Metadata from Artifact - Set "Metadata Source" to
project-accession.qza
- Change to
- Perform the following steps.
- Press the
Executebutton.
- For "input":
- Once completed, for the new entry in your history, use the
Editbutton to set the name as follows: - (Renaming is optional, but it will make any subsequent steps easier to complete.)
History Name "Name" to set (be sure to press [Save]) #: qiime2 metadata tabulate [...] : visualization.qzvproject-accession.qzv
metadata_actions <- import("qiime2.plugins.metadata.actions")
project_accession_md_md <- project_accession$view(Metadata)
action_results <- metadata_actions$tabulate(
input=project_accession_md_md,
)
project_accession_viz <- action_results$visualizationproject_accession_md = use.view_as_metadata('project_accession_md', project_accession)
use.action(
use.UsageAction(plugin_id='metadata',
action_id='tabulate'),
use.UsageInputs(input=project_accession_md),
use.UsageOutputNames(visualization='project-accession'))We can use q2-fondue 🫕 to easily import the data using this command:
qiime fondue get-sequences \
--i-accession-ids project-accession.qza \
--p-email [Insert Your Email] \
--o-single-reads single-reads-demux.qza \
--o-paired-reads demux.qza \
--o-failed-runs failed-runs.qzaor you can download the demux artifact here:
wget -O 'demux.qza' \
'https://amf-tutorial.readthedocs.io/en/latest/data/amf-tutorial/demux.qza'
url = 'https://amf-tutorial.readthedocs.io/en/latest/data/amf-tutorial/demux.qza'
fn = 'demux.qza'
request.urlretrieve(url, fn)
demux = Artifact.load(fn)
- Using the
Upload Datatool: - On the first tab (Regular), press the
Paste/Fetchdata button at the bottom.- Set "Name" (first text-field) to:
demux.qza - In the larger text-area, copy-and-paste: https://
amf -tutorial .readthedocs .io /en /latest /data /amf -tutorial /demux .qza - ("Type", "Genome", and "Settings" can be ignored)
- Set "Name" (first text-field) to:
- Press the
Startbutton at the bottom.
- On the first tab (Regular), press the
url <- 'https://amf-tutorial.readthedocs.io/en/latest/data/amf-tutorial/demux.qza'
fn <- 'demux.qza'
request$urlretrieve(url, fn)
demux <- Artifact$load(fn)
demux = use.init_artifact_from_url('demux',
'https://www.dropbox.com/scl/fi/94eglwqvn3noifxgc1lnt/subsampled.qza?rlkey=kof7j05xwy02bqeh6ym6qiwof&st=l997ie53&dl=1')Now, let’s visualize our data using demux summarize to assess sequencing quality.
qiime demux summarize \
--i-data demux.qza \
--o-visualization demux.qzvimport qiime2.plugins.demux.actions as demux_actions
demux_viz, = demux_actions.summarize(
data=demux,
)- Using the
qiime2 demux summarizetool: - Set "data" to
#: demux.qza - Press the
Executebutton.
- Set "data" to
- Once completed, for the new entry in your history, use the
Editbutton to set the name as follows: - (Renaming is optional, but it will make any subsequent steps easier to complete.)
History Name "Name" to set (be sure to press [Save]) #: qiime2 demux summarize [...] : visualization.qzvdemux.qzv
demux_actions <- import("qiime2.plugins.demux.actions")
action_results <- demux_actions$summarize(
data=demux,
)
demux_viz <- action_results$visualizationuse.action(
use.UsageAction(plugin_id='demux',
action_id='summarize'),
use.UsageInputs(data=demux),
use.UsageOutputNames(visualization='demux'))Understanding the Data¶
If you downloaded your data from NCBI-SRA, or received it from a sequencing facility, you will typically need three key files:
Metadata file – This mapping file provides contextual information about your experiment, including hypotheses, treatments, and sample details.
Classifier file – Used for assigning taxonomy during analysis.
Sequence files – These are usually in FASTQ format or already imported into QIIME 2 as .qza files.
To begin exploring your data and assessing its quality, open the demux.qzv file in QIIME 2 View. This visualization helps you evaluate read quality, which is critical for determining appropriate trimming parameters in downstream steps.
Revision Questions¶
What is the minimum and maximum number of reads in our samples?
Do any of the samples have fewer than 1,000 sequences?
At which position does the median quality score drop below 30?
Note: If any of the samples have very few sequences (e.g., fewer than 1,000), you may want to omit them from downstream analysis, as they could negatively affect data interpretation.
Denoising Using DADA2¶
Denoising is the process of correcting errors in the sequencing data and delimitating ASVs (amplicon sequence variants). The Non-biological sequences (e.g., adapters, primers, linker pads, etc.) and errors created by sequencing machines, such as incorrect base calls or random noise which can lead to inaccurate results if not corrected. For a more detailed lecture on this process, watch this video.
qiime dada2 denoise-paired \
--i-demultiplexed-seqs demux.qza \
--p-trunc-len-f 240 \
--p-trunc-len-r 220 \
--o-table table.qza \
--o-denoising-stats denoising-stats.qza \
--o-representative-sequences representative-sequences.qzaimport qiime2.plugins.dada2.actions as dada2_actions
table, representative_sequences, denoising_stats = dada2_actions.denoise_paired(
demultiplexed_seqs=demux,
trunc_len_f=240,
trunc_len_r=220,
)- Using the
qiime2 dada2 denoise-pairedtool: - Set "demultiplexed_seqs" to
#: demux.qza - Set "trunc_len_f" to
240 - Set "trunc_len_r" to
220 - Press the
Executebutton.
- Set "demultiplexed_seqs" to
dada2_actions <- import("qiime2.plugins.dada2.actions")
action_results <- dada2_actions$denoise_paired(
demultiplexed_seqs=demux,
trunc_len_f=240L,
trunc_len_r=220L,
)
table <- action_results$table
denoising_stats <- action_results$denoising_stats
representative_sequences <- action_results$representative_sequencestable, denoising_stats, representative_sequences = use.action(
use.UsageAction(plugin_id='dada2', action_id='denoise_paired'),
use.UsageInputs(
demultiplexed_seqs=demux,
trunc_len_f=240,
trunc_len_r=220,
),
use.UsageOutputNames(
table='table',
denoising_stats='denoising_stats',
representative_sequences='representative_sequences'
)
)Revision Questions¶
- How did we decide the truncation parameters, --p-trunc-len-f 240 --p-trunc-len-r 220? Hint: At what base pair does the median quality drop below 30?
qiime metadata tabulate \
--m-input-file denoising-stats.qza \
--o-visualization stats-dada2.qzvdenoising_stats_md_md = denoising_stats.view(Metadata)
stats_dada2_viz, = metadata_actions.tabulate(
input=denoising_stats_md_md,
)- Using the
qiime2 metadata tabulatetool: - For "input":
- Perform the following steps.
- Change to
Metadata from Artifact - Set "Metadata Source" to
denoising-stats.qza
- Change to
- Perform the following steps.
- Press the
Executebutton.
- For "input":
- Once completed, for the new entry in your history, use the
Editbutton to set the name as follows: - (Renaming is optional, but it will make any subsequent steps easier to complete.)
History Name "Name" to set (be sure to press [Save]) #: qiime2 metadata tabulate [...] : visualization.qzvstats-dada2.qzv
denoising_stats_md_md <- denoising_stats$view(Metadata)
action_results <- metadata_actions$tabulate(
input=denoising_stats_md_md,
)
stats_dada2_viz <- action_results$visualizationdenoising_stats_md = use.view_as_metadata('denoising_stats_md', denoising_stats)
dada2_stats_viz = use.action(
use.UsageAction(plugin_id='metadata', action_id='tabulate'),
use.UsageInputs(
input=denoising_stats_md),
use.UsageOutputNames(visualization='stats-dada2'))Note- If a large number (e.g. >50%) of sequences are lost during denoising/filtering the settings may be too stringent.
qiime feature-table tabulate-seqs \
--i-data representative-sequences.qza \
--o-visualization rep-seqs.qzvimport qiime2.plugins.feature_table.actions as feature_table_actions
rep_seqs_viz, = feature_table_actions.tabulate_seqs(
data=representative_sequences,
)- Using the
qiime2 feature-table tabulate-seqstool: - Set "data" to
#: representative-sequences.qza - Press the
Executebutton.
- Set "data" to
- Once completed, for the new entry in your history, use the
Editbutton to set the name as follows: - (Renaming is optional, but it will make any subsequent steps easier to complete.)
History Name "Name" to set (be sure to press [Save]) #: qiime2 feature-table tabulate-seqs [...] : visualization.qzvrep-seqs.qzv
feature_table_actions <- import("qiime2.plugins.feature_table.actions")
action_results <- feature_table_actions$tabulate_seqs(
data=representative_sequences,
)
rep_seqs_viz <- action_results$visualizationrep_seqs_viz = use.action(
use.UsageAction(plugin_id='feature_table', action_id='tabulate_seqs'),
use.UsageInputs(
data=representative_sequences),
use.UsageOutputNames(visualization='rep-seqs'))Revision Questions¶
- Do BLAST searches of the representative sequences make sense? Are the features what you would expect like AMF or not?
- How many features (ASVs) were generated? Are the communities high or low diversity?
qiime feature-table summarize \
--i-table table.qza \
--o-visualization table.qzvtable_viz, = feature_table_actions.summarize(
table=table,
)- Using the
qiime2 feature-table summarizetool: - Set "table" to
#: table.qza - Press the
Executebutton.
- Set "table" to
- Once completed, for the new entry in your history, use the
Editbutton to set the name as follows: - (Renaming is optional, but it will make any subsequent steps easier to complete.)
History Name "Name" to set (be sure to press [Save]) #: qiime2 feature-table summarize [...] : visualization.qzvtable.qzv
action_results <- feature_table_actions$summarize(
table=table,
)
table_viz <- action_results$visualizationtable_summary = use.action(
use.UsageAction(plugin_id='feature_table', action_id='summarize'),
use.UsageInputs(
table=table),
use.UsageOutputNames(visualization='table'))Taxonomic assignment¶
In order to understand which microbes are in the environment we sampled, we need to taxonomically annotate our sequences. More information on this process may be found here.
Classifications with fit-classifier-naive-bayes¶
To construct a taxonomic classifier using the MaarjAM database, two primary input files are required:
- A FASTA file containing the reference sequences
- A taxonomy file mapping those sequences to their taxonomic lineages
These resources can be downloaded from the official MaarjAM database website. Alternatively, pre-imported .qza files are also be downloaded from here:
wget -O 'maarjam-ref-seq.qza' \
'https://amf-tutorial.readthedocs.io/en/latest/data/amf-tutorial/maarjam-ref-seq.qza'
url = 'https://amf-tutorial.readthedocs.io/en/latest/data/amf-tutorial/maarjam-ref-seq.qza'
fn = 'maarjam-ref-seq.qza'
request.urlretrieve(url, fn)
maarjam_ref_seq = Artifact.load(fn)
- Using the
Upload Datatool: - On the first tab (Regular), press the
Paste/Fetchdata button at the bottom.- Set "Name" (first text-field) to:
maarjam-ref-seq.qza - In the larger text-area, copy-and-paste: https://
amf -tutorial .readthedocs .io /en /latest /data /amf -tutorial /maarjam -ref -seq .qza - ("Type", "Genome", and "Settings" can be ignored)
- Set "Name" (first text-field) to:
- Press the
Startbutton at the bottom.
- On the first tab (Regular), press the
url <- 'https://amf-tutorial.readthedocs.io/en/latest/data/amf-tutorial/maarjam-ref-seq.qza'
fn <- 'maarjam-ref-seq.qza'
request$urlretrieve(url, fn)
maarjam_ref_seq <- Artifact$load(fn)
def maarjam_refseq_factory():
from urllib import request
from qiime2 import Artifact
# Download the FASTA file
fp, _ = request.urlretrieve(
'https://www.dropbox.com/scl/fi/degicmkcyidve4qc3z3jh/maarjam_ref_seq.qza?rlkey=klzt244f0jylqeloxwqp61tb2&st=v6vpxfr0&dl=1')
# Import as a QIIME 2 artifact
return Artifact.load(fp)
maarjam_ref_seq = use.init_artifact('maarjam_ref_seq', maarjam_refseq_factory)wget -O 'ref-taxonomy-maarjam.qza' \
'https://amf-tutorial.readthedocs.io/en/latest/data/amf-tutorial/ref-taxonomy-maarjam.qza'
url = 'https://amf-tutorial.readthedocs.io/en/latest/data/amf-tutorial/ref-taxonomy-maarjam.qza'
fn = 'ref-taxonomy-maarjam.qza'
request.urlretrieve(url, fn)
ref_taxonomy_maarjam = Artifact.load(fn)
- Using the
Upload Datatool: - On the first tab (Regular), press the
Paste/Fetchdata button at the bottom.- Set "Name" (first text-field) to:
ref-taxonomy-maarjam.qza - In the larger text-area, copy-and-paste: https://
amf -tutorial .readthedocs .io /en /latest /data /amf -tutorial /ref -taxonomy -maarjam .qza - ("Type", "Genome", and "Settings" can be ignored)
- Set "Name" (first text-field) to:
- Press the
Startbutton at the bottom.
- On the first tab (Regular), press the
url <- 'https://amf-tutorial.readthedocs.io/en/latest/data/amf-tutorial/ref-taxonomy-maarjam.qza'
fn <- 'ref-taxonomy-maarjam.qza'
request$urlretrieve(url, fn)
ref_taxonomy_maarjam <- Artifact$load(fn)
def maarjam_taxonomy_factory():
from urllib import request
from qiime2 import Artifact
# Download the taxonomy TSV file
fp, _ = request.urlretrieve(
'https://www.dropbox.com/scl/fi/93gm5lfsn8kli2elemigs/ref-taxonomy.qza?rlkey=afvwcqdjgotn21ermz9rx015c&st=1fhecg2i&dl=1')
# Import as a QIIME 2 artifact
return Artifact.load(fp)
ref_taxonomy_maarjam = use.init_artifact('ref_taxonomy_maarjam', maarjam_taxonomy_factory)Next step is building the classifier file. Building an accurate classifier file is crucial for reliable taxonomic analysis, as it can significantly influence your results. An incorrect or poorly trained classifier may lead to unassigned or misclassified sequences. It’s recommended to run your data using both the vsearch and sklearn methods for comparison.
qiime feature-classifier fit-classifier-naive-bayes \
--i-reference-reads maarjam-ref-seq.qza \
--i-reference-taxonomy ref-taxonomy-maarjam.qza \
--o-classifier classifier-maarjam.qzawget -O 'classifier-maarjam.qza' \
'https://amf-tutorial.readthedocs.io/en/latest/data/amf-tutorial/classifier-maarjam.qza'
url = 'https://amf-tutorial.readthedocs.io/en/latest/data/amf-tutorial/classifier-maarjam.qza'
fn = 'classifier-maarjam.qza'
request.urlretrieve(url, fn)
classifier_maarjam = Artifact.load(fn)
- Using the
Upload Datatool: - On the first tab (Regular), press the
Paste/Fetchdata button at the bottom.- Set "Name" (first text-field) to:
classifier-maarjam.qza - In the larger text-area, copy-and-paste: https://
amf -tutorial .readthedocs .io /en /latest /data /amf -tutorial /classifier -maarjam .qza - ("Type", "Genome", and "Settings" can be ignored)
- Set "Name" (first text-field) to:
- Press the
Startbutton at the bottom.
- On the first tab (Regular), press the
url <- 'https://amf-tutorial.readthedocs.io/en/latest/data/amf-tutorial/classifier-maarjam.qza'
fn <- 'classifier-maarjam.qza'
request$urlretrieve(url, fn)
classifier_maarjam <- Artifact$load(fn)
classifier_maarjam = use.init_artifact_from_url('classifier_maarjam',
'https://www.dropbox.com/scl/fi/r9w35jljgnwi77tkaj7xz/classifier-maarjam.qza?rlkey=knhwft4ywkmf1dets1rzh5ehp&st=r4czsbzq&dl=1')qiime feature-classifier classify-sklearn \
--i-reads representative-sequences.qza \
--i-classifier classifier-maarjam.qza \
--p-confidence 0.7 \
--o-classification taxonomy-maarjam.qzawget -O 'taxonomy-maarjam.qza' \
'https://amf-tutorial.readthedocs.io/en/latest/data/amf-tutorial/taxonomy-maarjam.qza'
url = 'https://amf-tutorial.readthedocs.io/en/latest/data/amf-tutorial/taxonomy-maarjam.qza'
fn = 'taxonomy-maarjam.qza'
request.urlretrieve(url, fn)
taxonomy_maarjam = Artifact.load(fn)
- Using the
Upload Datatool: - On the first tab (Regular), press the
Paste/Fetchdata button at the bottom.- Set "Name" (first text-field) to:
taxonomy-maarjam.qza - In the larger text-area, copy-and-paste: https://
amf -tutorial .readthedocs .io /en /latest /data /amf -tutorial /taxonomy -maarjam .qza - ("Type", "Genome", and "Settings" can be ignored)
- Set "Name" (first text-field) to:
- Press the
Startbutton at the bottom.
- On the first tab (Regular), press the
url <- 'https://amf-tutorial.readthedocs.io/en/latest/data/amf-tutorial/taxonomy-maarjam.qza'
fn <- 'taxonomy-maarjam.qza'
request$urlretrieve(url, fn)
taxonomy_maarjam <- Artifact$load(fn)
taxonomy_maarjam = use.init_artifact_from_url('taxonomy_maarjam',
'https://www.dropbox.com/scl/fi/bo3pswfh65rl6339c9adt/taxonomy-maarjam.qza?rlkey=xpkqu5xrml40woq9cassl9kxf&st=jbkmmrf7&dl=1')qiime metadata tabulate \
--m-input-file taxonomy-maarjam.qza \
--o-visualization taxonomy-maarjam-md.qzvtaxonomy_maarjam_md_md = taxonomy_maarjam.view(Metadata)
taxonomy_maarjam_md_viz, = metadata_actions.tabulate(
input=taxonomy_maarjam_md_md,
)- Using the
qiime2 metadata tabulatetool: - For "input":
- Perform the following steps.
- Change to
Metadata from Artifact - Set "Metadata Source" to
taxonomy-maarjam.qza
- Change to
- Perform the following steps.
- Press the
Executebutton.
- For "input":
- Once completed, for the new entry in your history, use the
Editbutton to set the name as follows: - (Renaming is optional, but it will make any subsequent steps easier to complete.)
History Name "Name" to set (be sure to press [Save]) #: qiime2 metadata tabulate [...] : visualization.qzvtaxonomy-maarjam-md.qzv
taxonomy_maarjam_md_md <- taxonomy_maarjam$view(Metadata)
action_results <- metadata_actions$tabulate(
input=taxonomy_maarjam_md_md,
)
taxonomy_maarjam_md_viz <- action_results$visualizationtaxonomy_maarjam_md = use.view_as_metadata('taxonomy_maarjam_md', taxonomy_maarjam)
use.action(
use.UsageAction(plugin_id='metadata', action_id='tabulate'),
use.UsageInputs(
input=taxonomy_maarjam_md),
use.UsageOutputNames(
visualization='taxonomy_maarjam_md'))For convenience value of p-confidence is kept 0.7; however, it would be ideal to keep this at 0.97.
Revision Questions¶
How many of your ASVs were taxonomically assigned? note :view your taxonomy.qzv file
What was the difference in the number of ASVs when you used
p-confidenceof 0.97
Classifications with classify-consensus-vsearch¶
Classification with maarjAM¶
qiime feature-classifier classify-consensus-vsearch \
--i-query representative-sequences.qza \
--i-reference-reads maarjam-ref-seq.qza \
--i-reference-taxonomy ref-taxonomy-maarjam.qza \
--p-maxaccepts 1 \
--p-perc-identity 0.7 \
--p-strand both \
--p-top-hits-only \
--p-unassignable-label Unassigned \
--o-classification rice-taxonomy-vsearch.qza \
--o-search-results rice-search-results-vsearch.qzaimport qiime2.plugins.feature_classifier.actions as feature_classifier_actions
rice_taxonomy_vsearch, rice_search_results_vsearch = feature_classifier_actions.classify_consensus_vsearch(
query=representative_sequences,
reference_reads=maarjam_ref_seq,
reference_taxonomy=ref_taxonomy_maarjam,
maxaccepts=1,
perc_identity=0.7,
strand='both',
top_hits_only=True,
unassignable_label='Unassigned',
)- Using the
qiime2 feature-classifier classify-consensus-vsearchtool: - Set "query" to
#: representative-sequences.qza - Set "reference_reads" to
#: maarjam-ref-seq.qza - Set "reference_taxonomy" to
#: ref-taxonomy-maarjam.qza - Expand the
additional optionssection- Set "maxaccepts" to
1 - Set "perc_identity" to
0.7 - Leave "strand" as its default value of
both - Set "top_hits_only" to
Yes - Leave "unassignable_label" as its default value of
Unassigned
- Set "maxaccepts" to
- Press the
Executebutton.
- Set "query" to
- Once completed, for each new entry in your history, use the
Editbutton to set the name as follows: - (Renaming is optional, but it will make any subsequent steps easier to complete.)
History Name "Name" to set (be sure to press [Save]) #: qiime2 feature-classifier classify-consensus-vsearch [...] : classification.qzarice-taxonomy-vsearch.qza#: qiime2 feature-classifier classify-consensus-vsearch [...] : search_results.qzarice-search-results-vsearch.qza
feature_classifier_actions <- import("qiime2.plugins.feature_classifier.actions")
action_results <- feature_classifier_actions$classify_consensus_vsearch(
query=representative_sequences,
reference_reads=maarjam_ref_seq,
reference_taxonomy=ref_taxonomy_maarjam,
maxaccepts=1L,
perc_identity=0.7,
strand='both',
top_hits_only=TRUE,
unassignable_label='Unassigned',
)
rice_taxonomy_vsearch <- action_results$classification
rice_search_results_vsearch <- action_results$search_resultsrice_taxonomy_vsearch, rice_search_results_vsearch = use.action(
use.UsageAction(plugin_id='feature_classifier', action_id='classify_consensus_vsearch'),
use.UsageInputs(
query=representative_sequences,
reference_reads=maarjam_ref_seq,
reference_taxonomy=ref_taxonomy_maarjam,
maxaccepts=1,
perc_identity=0.7,
strand='both',
top_hits_only=True,
unassignable_label='Unassigned'),
use.UsageOutputNames(
classification='rice_taxonomy_vsearch',
search_results='rice_search_results_vsearch'))qiime metadata tabulate \
--m-input-file rice-taxonomy-vsearch.qza \
--o-visualization rice-taxonomy-vsearch.qzvrice_taxonomy_vsearch_md = rice_taxonomy_vsearch.view(Metadata)
rice_taxonomy_vsearch_viz, = metadata_actions.tabulate(
input=rice_taxonomy_vsearch_md,
)- Using the
qiime2 metadata tabulatetool: - For "input":
- Perform the following steps.
- Change to
Metadata from Artifact - Set "Metadata Source" to
rice-taxonomy-vsearch.qza
- Change to
- Perform the following steps.
- Press the
Executebutton.
- For "input":
- Once completed, for the new entry in your history, use the
Editbutton to set the name as follows: - (Renaming is optional, but it will make any subsequent steps easier to complete.)
History Name "Name" to set (be sure to press [Save]) #: qiime2 metadata tabulate [...] : visualization.qzvrice-taxonomy-vsearch.qzv
rice_taxonomy_vsearch_md <- rice_taxonomy_vsearch$view(Metadata)
action_results <- metadata_actions$tabulate(
input=rice_taxonomy_vsearch_md,
)
rice_taxonomy_vsearch_viz <- action_results$visualizationrice_taxonomy_vsearch = use.view_as_metadata('rice_taxonomy_vsearch', rice_taxonomy_vsearch)
use.action(
use.UsageAction(plugin_id='metadata', action_id='tabulate'),
use.UsageInputs(
input=rice_taxonomy_vsearch),
use.UsageOutputNames(
visualization='rice_taxonomy_vsearch'))Revision Questions¶
- How many of your ASVs were taxonomically assigned by this method. Is there a difference in output between fit-classifier-naive-bayes and classify-consensus-vsearch?
Taxonomy Bar Plot¶
The output of of feature-classifier classify-sklearn is used for the rest of the tutorial over the vsearch output.
qiime taxa barplot \
--i-table table.qza \
--i-taxonomy taxonomy-maarjam.qza \
--m-metadata-file metadata.tsv \
--o-visualization taxa-bar-plots.qzvimport qiime2.plugins.taxa.actions as taxa_actions
taxa_bar_plots_viz, = taxa_actions.barplot(
table=table,
taxonomy=taxonomy_maarjam,
metadata=metadata_md,
)- Using the
qiime2 taxa barplottool: - Set "table" to
#: table.qza - Expand the
additional optionssection- Set "taxonomy" to
#: taxonomy-maarjam.qza - For "metadata":
- Press the
+ Insert metadatabutton to set up the next steps.- Leave as
Metadata from TSV - Set "Metadata Source" to
metadata.tsv
- Leave as
- Press the
- Set "taxonomy" to
- Press the
Executebutton.
- Set "table" to
- Once completed, for the new entry in your history, use the
Editbutton to set the name as follows: - (Renaming is optional, but it will make any subsequent steps easier to complete.)
History Name "Name" to set (be sure to press [Save]) #: qiime2 taxa barplot [...] : visualization.qzvtaxa-bar-plots.qzv
taxa_actions <- import("qiime2.plugins.taxa.actions")
action_results <- taxa_actions$barplot(
table=table,
taxonomy=taxonomy_maarjam,
metadata=metadata_md,
)
taxa_bar_plots_viz <- action_results$visualizationtaxa_bar_plots = use.action(
use.UsageAction(plugin_id='taxa', action_id='barplot'),
use.UsageInputs(
table=table,
taxonomy=taxonomy_maarjam,
metadata=metadata),
use.UsageOutputNames(visualization='taxa_bar_plots'))Revision Questions¶
- What are the dominant phyla in each in each group ?
Visualize the samples at Level 6 (which corresponds to the genus of AMF in this analysis), and then sort the samples by env_broad_level, You can add as many taxonomic levels levels you want. If it’s hard to visualize the dominant phyla in each in each group, download the csv file on left hand side and use this to plot a relative abundance chart.
Filtering Tables¶
You can filter table if you want to work with specific group of taxa. You can create separate files for traditional and modern varieties if you want to.
qiime feature-table filter-samples \
--i-table table.qza \
--m-metadata-file metadata.tsv \
--p-where '[env_broad_scale]='"'"'Traditional rice root'"'"'' \
--o-filtered-table traditional-rice-table.qzatraditional_rice_table, = feature_table_actions.filter_samples(
table=table,
metadata=metadata_md,
where="[env_broad_scale]='Traditional rice root'",
)- Using the
qiime2 feature-table filter-samplestool: - Set "table" to
#: table.qza - Expand the
additional optionssection- For "metadata":
- Press the
+ Insert metadatabutton to set up the next steps.- Leave as
Metadata from TSV - Set "Metadata Source" to
metadata.tsv
- Leave as
- Press the
- Set "where" to
[env_broad_scale]='Traditional rice root'
- For "metadata":
- Press the
Executebutton.
- Set "table" to
- Once completed, for the new entry in your history, use the
Editbutton to set the name as follows: - (Renaming is optional, but it will make any subsequent steps easier to complete.)
History Name "Name" to set (be sure to press [Save]) #: qiime2 feature-table filter-samples [...] : filtered_table.qzatraditional-rice-table.qza
action_results <- feature_table_actions$filter_samples(
table=table,
metadata=metadata_md,
where="[env_broad_scale]='Traditional rice root'",
)
traditional_rice_table <- action_results$filtered_tabletraditional_rice_table, = use.action(
use.UsageAction(plugin_id='feature_table', action_id='filter_samples'),
use.UsageInputs(
table=table,
metadata=metadata,
where="[env_broad_scale]='Traditional rice root'"),
use.UsageOutputNames(filtered_table='traditional_rice_table'))qiime feature-table summarize \
--i-table traditional-rice-table.qza \
--o-visualization traditional-rice-table.qzvtraditional_rice_table_viz, = feature_table_actions.summarize(
table=traditional_rice_table,
)- Using the
qiime2 feature-table summarizetool: - Set "table" to
#: traditional-rice-table.qza - Press the
Executebutton.
- Set "table" to
- Once completed, for the new entry in your history, use the
Editbutton to set the name as follows: - (Renaming is optional, but it will make any subsequent steps easier to complete.)
History Name "Name" to set (be sure to press [Save]) #: qiime2 feature-table summarize [...] : visualization.qzvtraditional-rice-table.qzv
action_results <- feature_table_actions$summarize(
table=traditional_rice_table,
)
traditional_rice_table_viz <- action_results$visualizationtraditional_rice_table_viz = use.action(
use.UsageAction(plugin_id='feature_table', action_id='summarize'),
use.UsageInputs(
table=traditional_rice_table),
use.UsageOutputNames(visualization='traditional_rice_table'))qiime feature-table filter-samples \
--i-table table.qza \
--m-metadata-file metadata.tsv \
--p-where '[env_broad_scale]='"'"'Modern rice root'"'"'' \
--o-filtered-table modern-rice-table.qzamodern_rice_table, = feature_table_actions.filter_samples(
table=table,
metadata=metadata_md,
where="[env_broad_scale]='Modern rice root'",
)- Using the
qiime2 feature-table filter-samplestool: - Set "table" to
#: table.qza - Expand the
additional optionssection- For "metadata":
- Press the
+ Insert metadatabutton to set up the next steps.- Leave as
Metadata from TSV - Set "Metadata Source" to
metadata.tsv
- Leave as
- Press the
- Set "where" to
[env_broad_scale]='Modern rice root'
- For "metadata":
- Press the
Executebutton.
- Set "table" to
- Once completed, for the new entry in your history, use the
Editbutton to set the name as follows: - (Renaming is optional, but it will make any subsequent steps easier to complete.)
History Name "Name" to set (be sure to press [Save]) #: qiime2 feature-table filter-samples [...] : filtered_table.qzamodern-rice-table.qza
action_results <- feature_table_actions$filter_samples(
table=table,
metadata=metadata_md,
where="[env_broad_scale]='Modern rice root'",
)
modern_rice_table <- action_results$filtered_tablemodern_rice_table, = use.action(
use.UsageAction(plugin_id='feature_table', action_id='filter_samples'),
use.UsageInputs(
table=table,
metadata=metadata,
where="[env_broad_scale]='Modern rice root'"),
use.UsageOutputNames(filtered_table='modern_rice_table'))qiime feature-table summarize \
--i-table modern-rice-table.qza \
--o-visualization modern-rice-table.qzvmodern_rice_table_viz, = feature_table_actions.summarize(
table=modern_rice_table,
)- Using the
qiime2 feature-table summarizetool: - Set "table" to
#: modern-rice-table.qza - Press the
Executebutton.
- Set "table" to
- Once completed, for the new entry in your history, use the
Editbutton to set the name as follows: - (Renaming is optional, but it will make any subsequent steps easier to complete.)
History Name "Name" to set (be sure to press [Save]) #: qiime2 feature-table summarize [...] : visualization.qzvmodern-rice-table.qzv
action_results <- feature_table_actions$summarize(
table=modern_rice_table,
)
modern_rice_table_viz <- action_results$visualizationmodern_rice_table_viz = use.action(
use.UsageAction(plugin_id='feature_table', action_id='summarize'),
use.UsageInputs(
table=modern_rice_table),
use.UsageOutputNames(visualization='modern_rice_table'))Differential abundance (ANCOM-BC)¶
Accurately identifying features that are differentially abundant across sample types in microbiome data is a challenging problem and an open area of research. Analysis of Compositions of Microbiomes with Bias Correction (ANCOM-BC) is a methodology for differential abundance (DA) testing that corrects bias in microbiome data. Here we will use ANCOM-BC to identify taxa that are differentially abundant in modern or traditional rice varieties. For more information on this process watch this video.
We need to filter our table so we can investigate only Glomeromycetes class features.
qiime taxa filter-table \
--i-table table.qza \
--i-taxonomy taxonomy-maarjam.qza \
--p-include c__Glomeromycetes \
--o-filtered-table glomeromycetes-table.qzaglomeromycetes_table, = taxa_actions.filter_table(
table=table,
taxonomy=taxonomy_maarjam,
include='c__Glomeromycetes',
)- Using the
qiime2 taxa filter-tabletool: - Set "table" to
#: table.qza - Set "taxonomy" to
#: taxonomy-maarjam.qza - Expand the
additional optionssection- Set "include" to
c__Glomeromycetes
- Set "include" to
- Press the
Executebutton.
- Set "table" to
- Once completed, for the new entry in your history, use the
Editbutton to set the name as follows: - (Renaming is optional, but it will make any subsequent steps easier to complete.)
History Name "Name" to set (be sure to press [Save]) #: qiime2 taxa filter-table [...] : filtered_table.qzaglomeromycetes-table.qza
action_results <- taxa_actions$filter_table(
table=table,
taxonomy=taxonomy_maarjam,
include='c__Glomeromycetes',
)
glomeromycetes_table <- action_results$filtered_tableglomeromycetes_table, = use.action(
use.UsageAction(plugin_id='taxa', action_id='filter_table'),
use.UsageInputs(
table=table,
taxonomy=taxonomy_maarjam,
include='c__Glomeromycetes'),
use.UsageOutputNames(filtered_table='glomeromycetes_table'))qiime taxa collapse \
--i-table glomeromycetes-table.qza \
--i-taxonomy taxonomy-maarjam.qza \
--p-level 6 \
--o-collapsed-table collapsed-table-level-6.qzacollapsed_table_level_6, = taxa_actions.collapse(
table=glomeromycetes_table,
taxonomy=taxonomy_maarjam,
level=6,
)- Using the
qiime2 taxa collapsetool: - Set "table" to
#: glomeromycetes-table.qza - Set "taxonomy" to
#: taxonomy-maarjam.qza - Set "level" to
6 - Press the
Executebutton.
- Set "table" to
- Once completed, for the new entry in your history, use the
Editbutton to set the name as follows: - (Renaming is optional, but it will make any subsequent steps easier to complete.)
History Name "Name" to set (be sure to press [Save]) #: qiime2 taxa collapse [...] : collapsed_table.qzacollapsed-table-level-6.qza
action_results <- taxa_actions$collapse(
table=glomeromycetes_table,
taxonomy=taxonomy_maarjam,
level=6L,
)
collapsed_table_level_6 <- action_results$collapsed_tablecollapsed_table_level_6, = use.action(
use.UsageAction(plugin_id='taxa', action_id='collapse'),
use.UsageInputs(
table=glomeromycetes_table,
taxonomy=taxonomy_maarjam,
level=6),
use.UsageOutputNames(collapsed_table='collapsed_table_level_6'))qiime composition ancombc \
--i-table collapsed-table-level-6.qza \
--m-metadata-file metadata.tsv \
--p-formula env_broad_scale \
--o-differentials l6-ancombc-differentials.qzaimport qiime2.plugins.composition.actions as composition_actions
l6_ancombc_differentials, = composition_actions.ancombc(
table=collapsed_table_level_6,
metadata=metadata_md,
formula='env_broad_scale',
)- Using the
qiime2 composition ancombctool: - Set "table" to
#: collapsed-table-level-6.qza - For "metadata":
- Perform the following steps.
- Leave as
Metadata from TSV - Set "Metadata Source" to
metadata.tsv
- Leave as
- Perform the following steps.
- Set "formula" to
env_broad_scale - Press the
Executebutton.
- Set "table" to
- Once completed, for the new entry in your history, use the
Editbutton to set the name as follows: - (Renaming is optional, but it will make any subsequent steps easier to complete.)
History Name "Name" to set (be sure to press [Save]) #: qiime2 composition ancombc [...] : differentials.qzal6-ancombc-differentials.qza
composition_actions <- import("qiime2.plugins.composition.actions")
action_results <- composition_actions$ancombc(
table=collapsed_table_level_6,
metadata=metadata_md,
formula='env_broad_scale',
)
l6_ancombc_differentials <- action_results$differentialsl6_ancombc_differentials, = use.action(
use.UsageAction(plugin_id='composition', action_id='ancombc'),
use.UsageInputs(
table=collapsed_table_level_6,
metadata=metadata,
formula='env_broad_scale'),
use.UsageOutputNames(differentials='l6_ancombc_differentials'))qiime composition da-barplot \
--i-data l6-ancombc-differentials.qza \
--p-significance-threshold 0.05 \
--p-level-delimiter ';' \
--o-visualization l6-da-barplot.qzvl6_da_barplot_viz, = composition_actions.da_barplot(
data=l6_ancombc_differentials,
significance_threshold=0.05,
level_delimiter=';',
)- Using the
qiime2 composition da-barplottool: - Set "data" to
#: l6-ancombc-differentials.qza - Expand the
additional optionssection- Set "significance_threshold" to
0.05 - Set "level_delimiter" to
;
- Set "significance_threshold" to
- Press the
Executebutton.
- Set "data" to
- Once completed, for the new entry in your history, use the
Editbutton to set the name as follows: - (Renaming is optional, but it will make any subsequent steps easier to complete.)
History Name "Name" to set (be sure to press [Save]) #: qiime2 composition da-barplot [...] : visualization.qzvl6-da-barplot.qzv
action_results <- composition_actions$da_barplot(
data=l6_ancombc_differentials,
significance_threshold=0.05,
level_delimiter=';',
)
l6_da_barplot_viz <- action_results$visualizationl6_da_barplot = use.action(
use.UsageAction(plugin_id='composition', action_id='da_barplot'),
use.UsageInputs(
data=l6_ancombc_differentials,
significance_threshold=0.05,
level_delimiter=';'),
use.UsageOutputNames(visualization='l6_da_barplot'))Revision Questions¶
- Which taxa are enriched in traditional varieties? Note: try changing sample_name to column ‘env_broad_scale’; try with significance threshold of 0.01 also.
Diversity Analysis¶
Now let’s investigate community richness i.e. alpha diversity and the compositional differences of the AMF communities associates with different rice varieties i.e. beta diversity. Watch this video for more information.
Phylogenetic tree¶
Both rooted and unrooted trees can be generated by this command.
qiime phylogeny align-to-tree-mafft-fasttree \
--i-sequences representative-sequences.qza \
--o-rooted-tree rooted-tree.qza \
--o-tree unrooted-tree.qza \
--o-alignment aligned-rep-seqs.qza \
--o-masked-alignment masked-aligned-rep-seqs.qzaimport qiime2.plugins.phylogeny.actions as phylogeny_actions
aligned_rep_seqs, masked_aligned_rep_seqs, unrooted_tree, rooted_tree = phylogeny_actions.align_to_tree_mafft_fasttree(
sequences=representative_sequences,
)- Using the
qiime2 phylogeny align-to-tree-mafft-fasttreetool: - Set "sequences" to
#: representative-sequences.qza - Press the
Executebutton.
- Set "sequences" to
- Once completed, for each new entry in your history, use the
Editbutton to set the name as follows: - (Renaming is optional, but it will make any subsequent steps easier to complete.)
History Name "Name" to set (be sure to press [Save]) #: qiime2 phylogeny align-to-tree-mafft-fasttree [...] : alignment.qzaaligned-rep-seqs.qza#: qiime2 phylogeny align-to-tree-mafft-fasttree [...] : masked_alignment.qzamasked-aligned-rep-seqs.qza#: qiime2 phylogeny align-to-tree-mafft-fasttree [...] : tree.qzaunrooted-tree.qza#: qiime2 phylogeny align-to-tree-mafft-fasttree [...] : rooted_tree.qzarooted-tree.qza
phylogeny_actions <- import("qiime2.plugins.phylogeny.actions")
action_results <- phylogeny_actions$align_to_tree_mafft_fasttree(
sequences=representative_sequences,
)
rooted_tree <- action_results$rooted_tree
unrooted_tree <- action_results$tree
aligned_rep_seqs <- action_results$alignment
masked_aligned_rep_seqs <- action_results$masked_alignmentrooted_tree, unrooted_tree, aligned_rep_seqs, masked_aligned_rep_seqs = use.action(
use.UsageAction(plugin_id='phylogeny', action_id='align_to_tree_mafft_fasttree'),
use.UsageInputs(
sequences=representative_sequences,
),
use.UsageOutputNames(
rooted_tree='rooted_tree',
tree='unrooted_tree',
alignment='aligned_rep_seqs',
masked_alignment='masked_aligned_rep_seqs'))Alpha rarefaction Plot¶
qiime diversity alpha-rarefaction \
--i-table table.qza \
--i-phylogeny rooted-tree.qza \
--p-max-depth 1321 \
--m-metadata-file metadata.tsv \
--p-steps 4 \
--p-iterations 4 \
--o-visualization alpha-rarefaction.qzvimport qiime2.plugins.diversity.actions as diversity_actions
alpha_rarefaction_viz, = diversity_actions.alpha_rarefaction(
table=table,
phylogeny=rooted_tree,
max_depth=1321,
metadata=metadata_md,
steps=4,
iterations=4,
)- Using the
qiime2 diversity alpha-rarefactiontool: - Set "table" to
#: table.qza - Set "max_depth" to
1321 - Expand the
additional optionssection- Set "phylogeny" to
#: rooted-tree.qza - For "metadata":
- Press the
+ Insert metadatabutton to set up the next steps.- Leave as
Metadata from TSV - Set "Metadata Source" to
metadata.tsv
- Leave as
- Press the
- Set "steps" to
4 - Set "iterations" to
4
- Set "phylogeny" to
- Press the
Executebutton.
- Set "table" to
- Once completed, for the new entry in your history, use the
Editbutton to set the name as follows: - (Renaming is optional, but it will make any subsequent steps easier to complete.)
History Name "Name" to set (be sure to press [Save]) #: qiime2 diversity alpha-rarefaction [...] : visualization.qzvalpha-rarefaction.qzv
diversity_actions <- import("qiime2.plugins.diversity.actions")
action_results <- diversity_actions$alpha_rarefaction(
table=table,
phylogeny=rooted_tree,
max_depth=1321L,
metadata=metadata_md,
steps=4L,
iterations=4L,
)
alpha_rarefaction_viz <- action_results$visualizationalpha_rarefaction_plot = use.action(
use.UsageAction(plugin_id='diversity', action_id='alpha_rarefaction'),
use.UsageInputs(
table=table,
phylogeny=rooted_tree,
max_depth=1321,
metadata=metadata,
steps=4,
iterations=4
),
use.UsageOutputNames(visualization='alpha_rarefaction'))Revision Questions¶
- How did we decide as maximum depth 1321 ?
The max depth setting will depend on the number of sequences in your samples. The value that you provide for –p-max-depth should be determined by reviewing the OTU Frequency per sample information presented in the table.qzv file that was created above. Also observe that, do the refraction curves for each sample plateau? If they don’t, the samples haven’t been sequenced deeply enough to capture the full diversity of the AM fungal communities, which is shown on the y-axis. At what sequencing depth (x-axis) do your curves plateau? This value will be important for downstream analyses, particularly for alpha diversity analyses. Considering both features and samples retained is very important.
You may want to increase that value if the lines in the resulting rarefaction plot don’t appear to be leveling out, or decrease that value if you seem to be losing many of your samples due to low total frequencies closer to the minimum sampling depth than the maximum sampling depth.
qiime diversity core-metrics-phylogenetic \
--i-table table.qza \
--i-phylogeny rooted-tree.qza \
--p-sampling-depth 401 \
--m-metadata-file metadata.tsv \
--output-dir diversity-core-metrics-phylogeneticaction_results = diversity_actions.core_metrics_phylogenetic(
table=table,
phylogeny=rooted_tree,
sampling_depth=401,
metadata=metadata_md,
)
evenness_vector = action_results.evenness_vector
faith_pd_vector = action_results.faith_pd_vector
unweighted_unifrac_distance_matrix = action_results.unweighted_unifrac_distance_matrix
bray_curtis_pcoa_results = action_results.bray_curtis_pcoa_results
shannon_vector = action_results.shannon_vector
rarefied_table = action_results.rarefied_table
weighted_unifrac_distance_matrix = action_results.weighted_unifrac_distance_matrix
jaccard_pcoa_results = action_results.jaccard_pcoa_results
unweighted_unifrac_emperor_viz = action_results.unweighted_unifrac_emperor
weighted_unifrac_pcoa_results = action_results.weighted_unifrac_pcoa_results
observed_features_vector = action_results.observed_features_vector
jaccard_distance_matrix = action_results.jaccard_distance_matrix
jaccard_emperor_viz = action_results.jaccard_emperor
bray_curtis_emperor_viz = action_results.bray_curtis_emperor
weighted_unifrac_emperor_viz = action_results.weighted_unifrac_emperor
bray_curtis_distance_matrix = action_results.bray_curtis_distance_matrix
unweighted_unifrac_pcoa_results = action_results.unweighted_unifrac_pcoa_results- Using the
qiime2 diversity core-metrics-phylogenetictool: - Set "table" to
#: table.qza - Set "phylogeny" to
#: rooted-tree.qza - Set "sampling_depth" to
401 - For "metadata":
- Perform the following steps.
- Leave as
Metadata from TSV - Set "Metadata Source" to
metadata.tsv
- Leave as
- Perform the following steps.
- Press the
Executebutton.
- Set "table" to
- Once completed, for each new entry in your history, use the
Editbutton to set the name as follows: - (Renaming is optional, but it will make any subsequent steps easier to complete.)
History Name "Name" to set (be sure to press [Save]) #: qiime2 diversity core-metrics-phylogenetic [...] : rarefied_table.qzararefied-table.qza#: qiime2 diversity core-metrics-phylogenetic [...] : faith_pd_vector.qzafaith-pd-vector.qza#: qiime2 diversity core-metrics-phylogenetic [...] : observed_features_vector.qzaobserved-features-vector.qza#: qiime2 diversity core-metrics-phylogenetic [...] : shannon_vector.qzashannon-vector.qza#: qiime2 diversity core-metrics-phylogenetic [...] : evenness_vector.qzaevenness-vector.qza#: qiime2 diversity core-metrics-phylogenetic [...] : unweighted_unifrac_distance_matrix.qzaunweighted-unifrac-distance-matrix.qza#: qiime2 diversity core-metrics-phylogenetic [...] : weighted_unifrac_distance_matrix.qzaweighted-unifrac-distance-matrix.qza#: qiime2 diversity core-metrics-phylogenetic [...] : jaccard_distance_matrix.qzajaccard-distance-matrix.qza#: qiime2 diversity core-metrics-phylogenetic [...] : bray_curtis_distance_matrix.qzabray-curtis-distance-matrix.qza#: qiime2 diversity core-metrics-phylogenetic [...] : unweighted_unifrac_pcoa_results.qzaunweighted-unifrac-pcoa-results.qza#: qiime2 diversity core-metrics-phylogenetic [...] : weighted_unifrac_pcoa_results.qzaweighted-unifrac-pcoa-results.qza#: qiime2 diversity core-metrics-phylogenetic [...] : jaccard_pcoa_results.qzajaccard-pcoa-results.qza#: qiime2 diversity core-metrics-phylogenetic [...] : bray_curtis_pcoa_results.qzabray-curtis-pcoa-results.qza#: qiime2 diversity core-metrics-phylogenetic [...] : unweighted_unifrac_emperor.qzvunweighted-unifrac-emperor.qzv#: qiime2 diversity core-metrics-phylogenetic [...] : weighted_unifrac_emperor.qzvweighted-unifrac-emperor.qzv#: qiime2 diversity core-metrics-phylogenetic [...] : jaccard_emperor.qzvjaccard-emperor.qzv#: qiime2 diversity core-metrics-phylogenetic [...] : bray_curtis_emperor.qzvbray-curtis-emperor.qzv
action_results <- diversity_actions$core_metrics_phylogenetic(
table=table,
phylogeny=rooted_tree,
sampling_depth=401L,
metadata=metadata_md,
)
evenness_vector <- action_results$evenness_vector
faith_pd_vector <- action_results$faith_pd_vector
unweighted_unifrac_distance_matrix <- action_results$unweighted_unifrac_distance_matrix
bray_curtis_pcoa_results <- action_results$bray_curtis_pcoa_results
shannon_vector <- action_results$shannon_vector
rarefied_table <- action_results$rarefied_table
weighted_unifrac_distance_matrix <- action_results$weighted_unifrac_distance_matrix
jaccard_pcoa_results <- action_results$jaccard_pcoa_results
unweighted_unifrac_emperor_viz <- action_results$unweighted_unifrac_emperor
weighted_unifrac_pcoa_results <- action_results$weighted_unifrac_pcoa_results
observed_features_vector <- action_results$observed_features_vector
jaccard_distance_matrix <- action_results$jaccard_distance_matrix
jaccard_emperor_viz <- action_results$jaccard_emperor
bray_curtis_emperor_viz <- action_results$bray_curtis_emperor
weighted_unifrac_emperor_viz <- action_results$weighted_unifrac_emperor
bray_curtis_distance_matrix <- action_results$bray_curtis_distance_matrix
unweighted_unifrac_pcoa_results <- action_results$unweighted_unifrac_pcoa_resultscore_metrics_outputs = use.action(
use.UsageAction(plugin_id='diversity', action_id='core_metrics_phylogenetic'),
use.UsageInputs(
table=table,
phylogeny=rooted_tree,
sampling_depth=401,
metadata=metadata,
),
use.UsageOutputNames(
evenness_vector='evenness_vector',
faith_pd_vector='faith_pd_vector',
unweighted_unifrac_distance_matrix='unweighted_unifrac_distance_matrix',
bray_curtis_pcoa_results='bray-curtis-pcoa-results',
shannon_vector='shannon_vector',
rarefied_table='rarefied-table',
weighted_unifrac_distance_matrix='weighted-unifrac-distance-matrix',
jaccard_pcoa_results='jaccard-pcoa-results',
unweighted_unifrac_emperor='unweighted-unifrac-emperor',
weighted_unifrac_pcoa_results='weighted-unifrac-pcoa-results',
observed_features_vector='observed-features-vector',
jaccard_distance_matrix='jaccard-distance-matrix',
jaccard_emperor='jaccard-emperor',
bray_curtis_emperor='bray-curtis-emperor',
weighted_unifrac_emperor='weighted-unifrac-emperor',
bray_curtis_distance_matrix='bray-curtis-distance-matrix',
unweighted_unifrac_pcoa_results='unweighted-unifrac-pcoa-results'))diversity-core-metrics-phylogenetic/evenness_vector.qza| download | viewdiversity-core-metrics-phylogenetic/faith_pd_vector.qza| download | viewdiversity-core-metrics-phylogenetic/unweighted_unifrac_distance_matrix.qza| download | viewdiversity-core-metrics-phylogenetic/bray_curtis_pcoa_results.qza| download | viewdiversity-core-metrics-phylogenetic/shannon_vector.qza| download | viewdiversity-core-metrics-phylogenetic/rarefied_table.qza| download | viewdiversity-core-metrics-phylogenetic/weighted_unifrac_distance_matrix.qza| download | viewdiversity-core-metrics-phylogenetic/jaccard_pcoa_results.qza| download | viewdiversity-core-metrics-phylogenetic/unweighted_unifrac_emperor.qzv| download | viewdiversity-core-metrics-phylogenetic/weighted_unifrac_pcoa_results.qza| download | viewdiversity-core-metrics-phylogenetic/observed_features_vector.qza| download | viewdiversity-core-metrics-phylogenetic/jaccard_distance_matrix.qza| download | viewdiversity-core-metrics-phylogenetic/jaccard_emperor.qzv| download | viewdiversity-core-metrics-phylogenetic/bray_curtis_emperor.qzv| download | viewdiversity-core-metrics-phylogenetic/weighted_unifrac_emperor.qzv| download | viewdiversity-core-metrics-phylogenetic/bray_curtis_distance_matrix.qza| download | viewdiversity-core-metrics-phylogenetic/unweighted_unifrac_pcoa_results.qza| download | view
Alpha Diversity and Community Richness¶
qiime diversity alpha-group-significance \
--i-alpha-diversity diversity-core-metrics-phylogenetic/shannon_vector.qza \
--m-metadata-file metadata.tsv \
--o-visualization shannon-group-significance.qzvshannon_group_significance_viz, = diversity_actions.alpha_group_significance(
alpha_diversity=shannon_vector,
metadata=metadata_md,
)- Using the
qiime2 diversity alpha-group-significancetool: - Set "alpha_diversity" to
#: shannon-vector.qza - For "metadata":
- Perform the following steps.
- Leave as
Metadata from TSV - Set "Metadata Source" to
metadata.tsv
- Leave as
- Perform the following steps.
- Press the
Executebutton.
- Set "alpha_diversity" to
- Once completed, for the new entry in your history, use the
Editbutton to set the name as follows: - (Renaming is optional, but it will make any subsequent steps easier to complete.)
History Name "Name" to set (be sure to press [Save]) #: qiime2 diversity alpha-group-significance [...] : visualization.qzvshannon-group-significance.qzv
action_results <- diversity_actions$alpha_group_significance(
alpha_diversity=shannon_vector,
metadata=metadata_md,
)
shannon_group_significance_viz <- action_results$visualizationshannon_group_significance = use.action(
use.UsageAction(plugin_id='diversity', action_id='alpha_group_significance'),
use.UsageInputs(
alpha_diversity=core_metrics_outputs.shannon_vector,
metadata=metadata),
use.UsageOutputNames(visualization='shannon_group_significance'))qiime diversity alpha-group-significance \
--i-alpha-diversity diversity-core-metrics-phylogenetic/evenness_vector.qza \
--m-metadata-file metadata.tsv \
--o-visualization evenness-group-significance.qzvevenness_group_significance_viz, = diversity_actions.alpha_group_significance(
alpha_diversity=evenness_vector,
metadata=metadata_md,
)- Using the
qiime2 diversity alpha-group-significancetool: - Set "alpha_diversity" to
#: evenness-vector.qza - For "metadata":
- Perform the following steps.
- Leave as
Metadata from TSV - Set "Metadata Source" to
metadata.tsv
- Leave as
- Perform the following steps.
- Press the
Executebutton.
- Set "alpha_diversity" to
- Once completed, for the new entry in your history, use the
Editbutton to set the name as follows: - (Renaming is optional, but it will make any subsequent steps easier to complete.)
History Name "Name" to set (be sure to press [Save]) #: qiime2 diversity alpha-group-significance [...] : visualization.qzvevenness-group-significance.qzv
action_results <- diversity_actions$alpha_group_significance(
alpha_diversity=evenness_vector,
metadata=metadata_md,
)
evenness_group_significance_viz <- action_results$visualizationevenness_group_significance = use.action(
use.UsageAction(plugin_id='diversity', action_id='alpha_group_significance'),
use.UsageInputs(
alpha_diversity=core_metrics_outputs.evenness_vector,
metadata=metadata),
use.UsageOutputNames(visualization='evenness_group_significance'))qiime diversity alpha-group-significance \
--i-alpha-diversity diversity-core-metrics-phylogenetic/faith_pd_vector.qza \
--m-metadata-file metadata.tsv \
--o-visualization faith-group.qzvfaith_group_viz, = diversity_actions.alpha_group_significance(
alpha_diversity=faith_pd_vector,
metadata=metadata_md,
)- Using the
qiime2 diversity alpha-group-significancetool: - Set "alpha_diversity" to
#: faith-pd-vector.qza - For "metadata":
- Perform the following steps.
- Leave as
Metadata from TSV - Set "Metadata Source" to
metadata.tsv
- Leave as
- Perform the following steps.
- Press the
Executebutton.
- Set "alpha_diversity" to
- Once completed, for the new entry in your history, use the
Editbutton to set the name as follows: - (Renaming is optional, but it will make any subsequent steps easier to complete.)
History Name "Name" to set (be sure to press [Save]) #: qiime2 diversity alpha-group-significance [...] : visualization.qzvfaith-group.qzv
action_results <- diversity_actions$alpha_group_significance(
alpha_diversity=faith_pd_vector,
metadata=metadata_md,
)
faith_group_viz <- action_results$visualizationfaith_pd_group_significance = use.action(
use.UsageAction(plugin_id='diversity', action_id='alpha_group_significance'),
use.UsageInputs(
alpha_diversity=core_metrics_outputs.faith_pd_vector,
metadata=metadata),
use.UsageOutputNames(visualization='faith_group'))Revision Questions¶
- Is species richness same as number of ASVs ?
Beta Diversity¶
qiime diversity beta-group-significance \
--i-distance-matrix diversity-core-metrics-phylogenetic/unweighted_unifrac_distance_matrix.qza \
--m-metadata-file metadata.tsv \
--m-metadata-column env_broad_scale \
--p-method permanova \
--p-pairwise \
--p-permutations 999 \
--o-visualization unweighted-unifrac-env-broad-scale-significance.qzvenv_broad_scale_mdc = metadata_md.get_column('env_broad_scale')
unweighted_unifrac_env_broad_scale_significance_viz, = diversity_actions.beta_group_significance(
distance_matrix=unweighted_unifrac_distance_matrix,
metadata=env_broad_scale_mdc,
method='permanova',
pairwise=True,
permutations=999,
)- Using the
qiime2 diversity beta-group-significancetool: - Set "distance_matrix" to
#: unweighted-unifrac-distance-matrix.qza - For "metadata":
- Leave as
Metadata from TSV - Set "Metadata Source" to
metadata.tsv - Set "Column Name" to
env_broad_scale
- Leave as
- Expand the
additional optionssection- Leave "method" as its default value of
permanova - Set "pairwise" to
Yes - Leave "permutations" as its default value of
999
- Leave "method" as its default value of
- Press the
Executebutton.
- Set "distance_matrix" to
- Once completed, for the new entry in your history, use the
Editbutton to set the name as follows: - (Renaming is optional, but it will make any subsequent steps easier to complete.)
History Name "Name" to set (be sure to press [Save]) #: qiime2 diversity beta-group-significance [...] : visualization.qzvunweighted-unifrac-env-broad-scale-significance.qzv
env_broad_scale_mdc <- metadata_md$get_column('env_broad_scale')
action_results <- diversity_actions$beta_group_significance(
distance_matrix=unweighted_unifrac_distance_matrix,
metadata=env_broad_scale_mdc,
method='permanova',
pairwise=TRUE,
permutations=999L,
)
unweighted_unifrac_env_broad_scale_significance_viz <- action_results$visualizationenv_broad_col = use.get_metadata_column('env_broad_scale', 'env_broad_scale', metadata)
beta_group_significance_simple = use.action(
use.UsageAction(plugin_id='diversity', action_id='beta_group_significance'),
use.UsageInputs(
distance_matrix=core_metrics_outputs.unweighted_unifrac_distance_matrix,
metadata=env_broad_col,
method='permanova',
pairwise=True,
permutations=999),
use.UsageOutputNames(visualization='unweighted_unifrac_env_broad_scale_significance'))qiime diversity beta-group-significance \
--i-distance-matrix diversity-core-metrics-phylogenetic/unweighted_unifrac_distance_matrix.qza \
--m-metadata-file metadata.tsv \
--m-metadata-column Sample_Name \
--p-method permanova \
--p-pairwise \
--p-permutations 999 \
--o-visualization unweighted-unifrac-sample-name-significance.qzvSample_Name_mdc = metadata_md.get_column('Sample_Name')
unweighted_unifrac_sample_name_significance_viz, = diversity_actions.beta_group_significance(
distance_matrix=unweighted_unifrac_distance_matrix,
metadata=Sample_Name_mdc,
method='permanova',
pairwise=True,
permutations=999,
)- Using the
qiime2 diversity beta-group-significancetool: - Set "distance_matrix" to
#: unweighted-unifrac-distance-matrix.qza - For "metadata":
- Leave as
Metadata from TSV - Set "Metadata Source" to
metadata.tsv - Set "Column Name" to
Sample_Name
- Leave as
- Expand the
additional optionssection- Leave "method" as its default value of
permanova - Set "pairwise" to
Yes - Leave "permutations" as its default value of
999
- Leave "method" as its default value of
- Press the
Executebutton.
- Set "distance_matrix" to
- Once completed, for the new entry in your history, use the
Editbutton to set the name as follows: - (Renaming is optional, but it will make any subsequent steps easier to complete.)
History Name "Name" to set (be sure to press [Save]) #: qiime2 diversity beta-group-significance [...] : visualization.qzvunweighted-unifrac-sample-name-significance.qzv
Sample_Name_mdc <- metadata_md$get_column('Sample_Name')
action_results <- diversity_actions$beta_group_significance(
distance_matrix=unweighted_unifrac_distance_matrix,
metadata=Sample_Name_mdc,
method='permanova',
pairwise=TRUE,
permutations=999L,
)
unweighted_unifrac_sample_name_significance_viz <- action_results$visualizationsample_name_col = use.get_metadata_column('Sample_Name', 'Sample_Name', metadata)
beta_group_significance = use.action(
use.UsageAction(plugin_id='diversity', action_id='beta_group_significance'),
use.UsageInputs(
distance_matrix=core_metrics_outputs.unweighted_unifrac_distance_matrix,
metadata=sample_name_col,
method='permanova',
pairwise=True,
permutations=999),
use.UsageOutputNames(visualization='unweighted_unifrac_sample_name_significance'))