Update on embedding visualizations in Jupyter

Hi,

Has there been any progress on the option of embedding visualizations within a Jupyter notebook?

I found this post: Embedding visualizations in jupyter - #3 by uria

But I'm not sure how to generate the index.html.

If you could provide instructions on using python to visualize an artifact that would be much appreciated!

Thanks
Laura

2 Likes

Hi @laura.d,

If you run via the Python API and/or load the data via the Python API into a jupyter notebook, you can view the object inline. (I do this a lot with emperor plots). If you use

qiime2 import Visualization
viz = Visualization.load(vis.qzv)
viz

I think you should be able ot view inline in Jupyter. You can also just render them directly with the commands, but TBH, I find the python API more frustrating than CLI.

Best,
Justine

2 Likes

(You may need to run jupyter serverextension enable --py qiime2 --sys-prefix first to get the visualization to show up inline, if you haven't already enabled the extension)

3 Likes

Thanks @jwdebelius and @ebolyen.

I've previously enabled the extension.

I tried the suggested code but received this error:

1 Like

Ah! Most things in QIIME 2's API which take a filepath are alternate constructors named load.

So try:

viz = Visualization.load('<file here>')
viz

instead (this is true for Artifact and Metadata (and Result if you know about it)).

1 Like

Unfortunately I'm not getting any output. Sorry to be a pain!

No worries, what version of QIIME 2 are you running, and what version of Jupyter (looks like notebook)?

I'll see if I can reproduce in the morning, the way it works is a bit of a hack, so I wouldn't be shocked if something changed underfoot.

Thanks @ebolyen. I'm running qiime2-2019.4 and Jupyter notebook.

Hi @laura.d,

Good news is it seems that the jupyter extension is still working on 2019.4 with these versions:

§ conda list jupyter
# packages in environment at /home/evan/.conda/envs/qiime2-2019.4:
#
# Name                    Version                   Build  Channel
jupyter_client            5.2.4                      py_3    conda-forge
jupyter_core              4.4.0                      py_0    conda-forge
§ conda list notebook
# packages in environment at /home/evan/.conda/envs/qiime2-2019.4:
#
# Name                    Version                   Build  Channel
notebook                  5.7.8                    py36_0    conda-forge

Bad news is it means I don't know what is going on with your machine. I was able to see the visualization in both Firefox and Chrome. What browser are you using (and what version)?

1 Like

Hmm that's strange, I'm not sure what's going on because I have the same versions as you. I'm using Firefox.

Hi @laura.d,

Hmm, we'll need to look closer at your computer then to figure out what is going on. Would you be able to open the development console and look for any errors in the Console tab (screenshot is fine), and if you don't see anything there, could you switch to the Network tab and reload the page (re-running the command in Jupyter).

There's going to be a lot of network requests, but I'm looking for one to /qiime2/view/<uuid> (pictured below).

I'm mostly interested in what the response code is, so in my case it was 200 indicating everything was fine, but you may not even have this network request happen depending on where the Jupyter repr is breaking (which we don't know yet).

Thanks and sorry for the trouble.

1 Like

Hi @ebolyen

I re-ran the command in Jupyter with the development console open but I couldn't see that network request. A screenshot of all requests is below.

Not sure if this info is of any use:

Cheers
Laura

1 Like

Ah! Those console errors do indeed explain the situation! Thank you for those screenshots.

I suspect you are on the extended support release for Firefox (ESR) which you can see in Help>About (or perhaps your version of Firefox is truly very old).

This version preserves older APIs and doesn't include new ones (like fetch). That is why nothing shows up, as it isn't able to initiate a request (since the API it uses to do that isn't in Firefox ESR). If you have permissions to do so on your system, try installing a newer Firefox (or load it in Chrome/IE) and I think you will see it start working!

Okay great! I'm using MobaXterm and that version of Firefox is the MobaXterm default browser. I'll change my jupyter default browser (using directions in this post, in case anyone else on the forum has the same issue: google chrome - How to change the default browser used by the ipython/jupyter notebook in Linux? - Stack Overflow)

Thanks for your help @ebolyen, it's much appreciated!

1 Like

The updated version is not working properly on my device. It is showing Asus Error Code 55. Please help me to fix this.

Hi @rosey12,

Could you provide a screenshot and describe what versions of software you are using?

Also, to confirm, you are having issues with the Jupyter extension for QIIME 2 visualizations? Jupyter itself? QIIME 2? Forwarding X11 over an SSH tunnel? Firefox? Or something else?

Thanks!