Python API: visualizations

Hello!

how can I visualize visualization objects in Jupyter? For example, I run
feature_table.visualizers.tabulate_seqs(deblur_sequences.representative_sequences)
and all I get is this:

Results (name = value)
-----------------------------------------------------------------------------------------
visualization = <visualization: Visualization uuid:
9486c314-d14a-4e30-b52c-ca97a68af501>

How can I get the visualization I would normally get from using qiime tools view artifact.qzv? Do I have to save it first and then visualize from a saved qzv file?

thanks,
Tomasz

Hi @tomaz, we don’t have a good workflow developed yet for viewing visualizations within Jupyter - check out this post for a little detail:

Maybe @uria can provide some more details about their workaround.

Otherwise, we are stuck working within Jupyter’s limitations, so some code like this can get you moving:

viz = feature_table.visualizers.tabulate_seqs(rep_seqs)
viz.visualization.save('foo.qzv')
!qiime tools view foo.qzv

This will open the visualization in a new tab, although YMMV depending on how Jupyter NB is configured.

2 Likes

Hey there @tomasz ,

regarding

Though I really couldn’t find a good reason to use this workaround (qiime view works just fine for me…) what I suggested in mentioned thread is to:

  1. Extract the visualization object as a directory
out_dir = "/tmp/deblur_sqs_vis"
feature_table.visualizers.tabulate_seqs(deblur_sequences\
                .representative_sequences).export_data(out_dir)

Now you should have (I hope) a directory called deblur_sqs_vis under /tmp. This directory also should contain sub-directory named data in which there’s an index.html file.
2. Use the HTML object in IPython.core.display in order to view this directory

from IPython.core.display import  HTML
HTML('<iframe height = 1000, width = 1000, src = "{}/data/index.html"> </iframe>'\
    .format(out_dir))

Hope it’ll work for you.

3 Likes

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