This notebook is not currently set up to work standalone. See @gregcaporaso's slides from SciPy 2016 for more information. See http://2.qiime.org if you'd like to try QIIME 2.
Installation steps prior to demo:
conda create -n q2-scipy2016 python=3.5 q2-diversity q2cli -c qiime2 -c biocore -c bioconda
source activate q2-scipy2016
Download example Artifacts (QIIME 1 data files can be imported as QIIME 2 Artifacts, see Importing data):
!rm -rf *.qza *.qzv feature-table-frequency q2-demo-sample-md.tsv
!curl -sO https://raw.githubusercontent.com/qiime2/q2-types/master/q2_types/tests/data/feature-table-frequency.qza
!curl -sO https://raw.githubusercontent.com/qiime2/q2-types/master/q2_types/tests/data/phylogeny.qza
!curl -sO https://dl.dropboxusercontent.com/u/2868868/q2-demo-sample-md.tsv
from qiime import Artifact
table = Artifact.load('./feature-table-frequency.qza')
table
<artifact: FeatureTable[Frequency] uuid: 1bacd8ec-65bb-4938-b413-84ec7dea0af2>
tree = Artifact.load('./phylogeny.qza')
import biom
biom_table = table.view(biom.Table)
biom_table
658 x 104 <class 'biom.table.Table'> with 5670 nonzero entries (8% dense)
import pandas as pd
table.view(pd.DataFrame)[:5]
New.CleanUp.ReferenceOTU0 | New.CleanUp.ReferenceOTU1 | New.CleanUp.ReferenceOTU3 | New.CleanUp.ReferenceOTU6 | New.CleanUp.ReferenceOTU7 | New.CleanUp.ReferenceOTU8 | New.CleanUp.ReferenceOTU9 | New.CleanUp.ReferenceOTU10 | New.CleanUp.ReferenceOTU12 | New.CleanUp.ReferenceOTU13 | ... | New.CleanUp.ReferenceOTU1502 | New.CleanUp.ReferenceOTU1503 | New.CleanUp.ReferenceOTU1504 | New.CleanUp.ReferenceOTU1507 | New.CleanUp.ReferenceOTU1508 | New.CleanUp.ReferenceOTU1509 | New.CleanUp.ReferenceOTU1510 | New.CleanUp.ReferenceOTU1512 | New.CleanUp.ReferenceOTU1514 | New.CleanUp.ReferenceOTU1516 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
K3.H | 2.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 13.0 | 0.0 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
K3.Z | 0.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | ... | 0.0 | 0.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
M2.Middle.L | 0.0 | 6.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | ... | 0.0 | 0.0 | 6.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | 0.0 | 0.0 |
K3.A | 0.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
K3.R | 0.0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
5 rows × 658 columns
!unzip feature-table-frequency.qza
Archive: feature-table-frequency.qza inflating: feature-table-frequency/VERSION inflating: feature-table-frequency/README.md inflating: feature-table-frequency/metadata.yaml inflating: feature-table-frequency/data/feature-table.biom
import qiime.plugins
import pprint
pprint.pprint(qiime.plugins.available_plugins())
{'qiime.plugins.diversity', 'qiime.plugins.feature_table', 'qiime.plugins.types'}
import qiime.plugins.feature_table
import qiime.plugins.diversity
table100 = qiime.plugins.feature_table.actions.rarefy(table, counts_per_sample=100)
dm = qiime.plugins.diversity.actions.beta_phylogenetic(table100, tree, metric='unweighted_unifrac')
(Note: alternatives to rarefaction, such as those discussed in McMurdie et al. (2014), are planned for addition as a plugin.)
dm
<artifact: DistanceMatrix % Properties(['phylogenetic']) uuid: 127b8e69-aa96-4c49-b6b3-0118b6df8c3c>
Provenance is very basic at this stage, but it is being improved in alpha (qiime2/qiime2#88).
dm.provenance
{'artifact_uuids': {'phylogeny': UUID('44b60757-effa-494d-a348-4b8a98f0084e'), 'table': UUID('bff917f6-5017-4da3-9126-1be34e90ebd8')}, 'execution_uuid': UUID('bba2b170-4806-479d-a2b7-5ff52c444e38'), 'executor_reference': 'beta_phylogenetic. Details on plugin, version, ' 'website, etc. will also be included, see ' 'https://github.com/biocore/qiime2/issues/26', 'parameter_references': {'metric': 'unweighted_unifrac'}}
table100.save('table100.qza')
dm.save('dm.qza')
Passing an incorrect type results in a TypeError
:
qiime.plugins.diversity.actions.beta_phylogenetic(table, tree, 'unweighted_unifrac')
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-14-6f0dc2091517> in <module>() ----> 1 qiime.plugins.diversity.actions.beta_phylogenetic(table, tree, 'unweighted_unifrac') <decorator-gen-125> in beta_phylogenetic(table, phylogeny, metric) /Users/caporaso/miniconda3/envs/q2-scipy2016/lib/python3.5/site-packages/qiime-2.0.1-py3.5.egg/qiime/sdk/method.py in callable_wrapper(*args, **kwargs) 256 args.update(kwargs) 257 --> 258 self.signature.check_types(**args) 259 output_types = self.signature.solve_output(**args) 260 /Users/caporaso/miniconda3/envs/q2-scipy2016/lib/python3.5/site-packages/qiime-2.0.1-py3.5.egg/qiime/core/type/signature.py in check_types(self, **kwargs) 61 if kwargs[key] not in type_: 62 raise TypeError("Argument to parameter %r is not a subtype of" ---> 63 " %r." % (key, type_)) 64 65 def solve_output(self, **input_types): TypeError: Argument to parameter 'table' is not a subtype of FeatureTable[Frequency] % Properties(['uniform-sampling']).
q2cli
) demo commands¶qiime
qiime info
qiime diversity --help
qiime diversity beta_phylogenetic --help
qiime diversity pcoa --help
qiime diversity pcoa --distance-matrix dm.qza --pcoa pc
conda install q2-emperor -c qiime2 -c biocore -c bioconda
qiime info
See Installing and using QIIME 2 documentation.
cd qiime-studio-0.0.1
npm start
Then, through the UI, change to the directory where the previous demos were run. (During alpha, we will transition so this can be started as a normal desktop application, e.g., with a QIIME icon.)
See QIIME Studio documentation.