stuck with Parkinson Mouse tutorial using ARTIFACT API

Good evening everyone, I am new to this forum and sorry to bother you with the question

I am stuck to the Parkinson Mouse tutorial, I am trying to use the ARTIFACT API
At the step to analyze alpha diversity, here is the line I entered but it doesn’t work and I don’t understand why. May you help me?

faith_pd_vector_qzv = anova(metadata=(metadata, faith_pd_vector_qza), formula = "faith_pd ~ genotype * donor_status")

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-44-16ee66bdf4e4> in <module>
----> 1 faith_pd_vector_qzv = anova(metadata=(metadata, faith_pd_vector_qza), formula = "faith_pd ~ genotype * donor_status")

</opt/conda/envs/qiime2-2019.10/lib/python3.6/site-packages/decorator.py:decorator-gen-258> in anova(metadata, formula, sstype)

/opt/conda/envs/qiime2-2019.10/lib/python3.6/site-packages/qiime2/sdk/action.py in bound_callable(*args, **kwargs)
    201 
    202                 # Type management
--> 203                 self.signature.check_types(**user_input)
    204                 output_types = self.signature.solve_output(**user_input)
    205                 callable_args = {}

/opt/conda/envs/qiime2-2019.10/lib/python3.6/site-packages/qiime2/core/type/signature.py in check_types(self, **kwargs)
    352                         "Parameter %r received %r as an argument, which is "
    353                         "incompatible with parameter type: %r"
--> 354                         % (name, parameter, spec.qiime_type))
    355 
    356     def solve_output(self, **kwargs):

TypeError: Parameter 'metadata' received (Metadata
--------
48 IDs x 8 columns
barcode:                   ColumnProperties(type='categorical')
mouse_id:                  ColumnProperties(type='categorical')
genotype:                  ColumnProperties(type='categorical')
cage_id:                   ColumnProperties(type='categorical')
donor:                     ColumnProperties(type='categorical')
donor_status:              ColumnProperties(type='categorical')
days_post_transplant:      ColumnProperties(type='numeric')
genotype_and_donor_status: ColumnProperties(type='categorical')

Call to_dataframe() for a tabular representation., Metadata
--------
47 IDs x 1 column
faith_pd: ColumnProperties(type='numeric')

Call to_dataframe() for a tabular representation.) as an argument, which is incompatible with parameter type: Metadata

Welcome to the forum, @caroline_ng!

It looks like you are passing a tuple of Metadata objects, but should merge these first instead… so something like this:

faith_pd_vector_qzv = anova(metadata=metadata.merge(faith_pd_vector_qza), formula = "faith_pd ~ genotype * donor_status")

Are you trying to translate the Parkinson’s mouse tutorial to Artifact API or is there a website with the tutorial you are following?

Let me know if that works!

1 Like

Thank you so much ! I’ll tell you if it’s work I’ll try it tonight. Yes I am trying to translate it ! I am very new in coding or programming … I am just trying to understand the command !

And it’s the same with the beta diversity analysis. I am stuck to the « metadata column » I don’t know how to translate it in artifact API. I have tried several command but it still doesn’t work.

2 Likes

Check out this reference:
https://dev.qiime2.org/latest/api-reference/metadata/

After loading a Metadata object, you would use get_column() to get the column of interest. So something like this:

md = qiime2.Metadata.load('filepath-to-metadata.tsv')
md_column = md.get_column('name_of_metadata_column')

I hope that helps!

1 Like

THank you !
You helped me a lot for the alpha diversity command, here was the good command:
faith_pd_vector_qzv = anova(metadata= metadata.merge(faith_pd_vector_qza.view(Metadata)), formula = “faith_pd ~ genotype * donor_status”)

because faith_pd_vector_qza was not a Metadata type, it didn’t work at first, but I just had to change it to Metadata type and it worked!

For the beta diversity analysis, I am still stuck
the metadata.tsv file is already loaded and included in the variable metadata
but I can’t find a way to get the column
I typed this:

unweighted_unifrac_donor_significance_qzv = beta_group_significance(distance_matrix=unweighted_unifrac_distance_matrix_qza, metadata=metadata, md_column=metadata.get_column(“donor”))

and it didn’t work… any idea?

The method does not have separate metadata and md_column arguments — see the Artifact API docstring for this action here: https://docs.qiime2.org/2019.10/plugins/available/diversity/beta-group-significance/

metadata is looking for a MetadataColumn[Categorical] object, so you should do something like this instead:

unweighted_unifrac_donor_significance_qzv = beta_group_significance(
    distance_matrix=unweighted_unifrac_distance_matrix_qza,
    metadata=metadata.get_column(“donor”))
1 Like

Thank you again for your help. I could finish the tutorial without any problem!

2 Likes

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.