Convert Results object into Artifact

I tried to read a similar post but it didn’t give me the answer I need about how to convert a results object into an Artifact

Here is my code:
table_2k_qza=filter_samples(table=dada2_table_qza, min_frequency=2000)

I am trying to translate the Parkinson Mouse tutorial into API.

The next code is:
taxa_barplot_qzv=barplot(table_2k_qza, taxonomy=Artifact.load(“taxonomy.qza”), metadata=metadata)
The error I get in the next step is : TypeError: Parameter ‘table’ received Results (name = value)

Can someone help me convert table_2k_qza into Artifact? i am stuck

Thank you very much

Typically a command from the Artifact API such as feature_table.actions.filter_samples will return a Results object. If you print the object you should be able to see the identifier of the data contained in the Results. In the case of filter_samples I believe it is filtered_table. Try print(table_2k_qza) to confirm this is the case.

So for your example I think

taxa_barplot_qzv = barplot(table_2k_qza.filtered_table, taxonomy=Artifact.load(“taxonomy.qza”), metadata=metadata)

should work as you expect.

1 Like

That’s great! It worked!!
but then, I have the same errpr, which I don’t understand why because it is exactly the same error:

Here is the next code I used:
ancom_donor_qzv=ancom(table2k_abund_comp_qza, metadata=metadata.get_column(“donor”))

.filtered_table doesn’t work this time.

and the error : TypeError: Parameter ‘table’ received Results (name = value)

composition_table = <artifact: FeatureTable[Composition] uuid: be2a115a-ba66-4157-802b-5b95fb86a6ef> as an argument, which is incompatible with parameter type: FeatureTable[Composition]

I am sorry if my questions are stupid, I am very grateful for your help.

Hi @caroline_ng!

This is a great question - thanks for asking!

As @gibsramen mentioned above, all actions in the Artifact API will return Results objects. Every results object is essentially a python namedtuple (8.3. collections — Container datatypes — Python 3.6.15 documentation) - you can access any of the outputs from the action by calling the result.output_name (where output_name is the name of the output you wish to access).

filter_samples_results = filter_samples(table=dada2_table_qza, min_frequency=2000)

taxonomy = Artifact.load(“taxonomy.qza”)

barplot_results = barplot(filter_samples_results.filtered_table, taxonomy=taxonomy, metadata=metadata)

barplot_viz = barplot_results.visualization

Every Results object will have different output parameters (because each Action outputs different things, right?)

ancom_results = ancom(table2k_abund_comp_qza.composition_table, metadata=metadata.get_column(“donor”))

ancom_viz = ancom_results.visualization

See what I did there? The hint is right there in the error message:

(emphasis mine)

Hope that helps!


1 Like

Thank you so much for your reply ! Now I understand it very well. I will try to do it for the rest of my code. It worked !! I am so happy !! Thanks !!

1 Like

Thank you. !!! I have understood it well. That was a very clear explanation.

1 Like

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