How to output metadata as an artifact

Long story short, I’m interested in creating some tools that can allow for different types of metadata to be merged together. Here are some use cases (for biplots)

  • Visualizing a biplot with feature metadata such the taxonomies. Doing so requires that you merge / create a metadata table of features.
  • Visualizing genome presence / absence on a biplot, but to do so requires you to have something like genome prediction from picrust to be converted to metadata.
  • Visualizing differential abundance values (from something like DEseq2, aldex2, stray, …) directly on a biplot.
  • Any of the above tasks also apply to phylogenetic tree visualization

I know that Metadata object are now Artifacts. However, I have not seen any examples of plugins outputting metadata. Do these examples exist, or is there additional infrastructure required to make this happen?

3 Likes

TLDR, any format/view type that is viewable as metadata can be used as metadata. So, for example, PCoAResults (represented as OrdinationFormat) can be used as metadata (for example, metadata tabulate). This is because the format is viewable as metadata, which means, there is a transformer defined to go from OrdinationFormat to qiime2.Metadata:

@plugin.register_transformer
def _3(ff: OrdinationFormat) -> qiime2.Metadata:
    df = _ordination_format_to_dataframe(ff)
    return qiime2.Metadata(df)

So, for a point by point breakdown:

This is already supported (--m-feature-metadata-file) — you can provide a FeatureData[Taxonomy] artifact here, because, it is viewable as Metadata.

This would need a transformer defined to go to qiime2.Metadata.

This would need a transformer defined to go to qiime2.Metadata.

Let us know if you have any questions. Thanks! :qiime2:

2 Likes

Ok very cool - I didn’t know that you can just pass in FeatureData[Taxonomy] as Metadata!
Now it makes more sense why the new differential type needed a Metadata transformer – so maybe this should just work out of the box??

Glad to see that the infrastructure is in place :slight_smile:

1 Like

Is there a way to have a plugin output metadata? I am working on a plugin that would filter and match samples and want to output the modified sample metadata.

Unfortunately not at this time (we are still trying to figure out how to handle provenance tracking for this case). One workaround is to return a visualization that contains the metadata.

One tactic we take in many actions is to allow the table to be a subset of the metadata, that way metadata doesn’t need to be updated.

Hi, you may want to take a look at this plugin which generate metadata through folder structure:
https://library.qiime2.org/plugins/qiime2-manifest-metadata-generator/23/