Help with QIIME 2 2018.11 API qiime2.Metadata.from_artifact()


I was trying to run the following code:

from qiime2.plugins.metadata.visualizers import tabulate
denoising_stats_viz = tabulate(input=denoising_stats_art)                                                          

But I got the following error:

TypeError                                 Traceback (most recent call last)
<ipython-input-23-9b6d5a9c1715> in <module>
----> 1 denoising_stats_viz = tabulate(input=denoising_stats_art)

<decorator-gen-228> in tabulate(input, page_size)

/opt/conda/envs/qiime2-2018.11/lib/python3.5/site-packages/qiime2/sdk/ in bound_callable(*args, **kwargs)
    198                 # Type management
--> 199                 self.signature.check_types(**user_input)
    200                 output_types = self.signature.solve_output(**user_input)
    201                 callable_args = {}

/opt/conda/envs/qiime2-2018.11/lib/python3.5/site-packages/qiime2/core/type/ in check_types(self, **kwargs)
    299                         "Parameter %r received an argument of type %r. An "
    300                         "argument of subtype %r is required." % (
--> 301                             name, kwargs[name].type, spec.qiime_type))
    303     def solve_output(self, **input_types):

TypeError: Parameter 'input' received an argument of type SampleData[DADA2Stats]. An argument of subtype Metadata is required.

I searched and I found your post (Visualization API) that is suggesting to do:

# Since `tabulate` accepts a `Metadata` object as input
# (not an `Artifact`), we need to view the artifact as metadata.
# Create a `Metadata` object from the input artifact --
# this preserves the input artifact's provenance in the
# visualization that's created by `tabulate` too!
taxonomy_md = qiime2.Metadata.from_artifact(taxonomy)

Iā€™m running QIIME 2 2018.11 from Docker and qiime2.Metadata.from_artifact do not exists there.

Do you happen to know where that function has been moved?

Any help will be really appreciated.

Many thanks,

1 Like

Hey there @fasnicar!

You will want to view the Artifact as Metadata:

denoising_stats_viz = tabulate(input=denoising_stats_art.view(qiime2.Metadata))

Hope that helps!

1 Like