ismms-himc / clustergrammer2

"Dimensionality-increasing" data visualization tool and interactive WebGL Jupyter widget built for single-cell data.
https://clustergrammer.readthedocs.io/case_studies.html
MIT License
116 stars 20 forks source link

unable saving interactive heatmap plot in to html file #97

Open TalWac opened 3 years ago

TalWac commented 3 years ago

Dear Developers,

I'm trying to save the interactive heatmap plot into an HTML file without success so it can be served as a report file. followed the instruction to Sharing with nbviewer

To Reproduce Steps to reproduce the behavior:

  1. I check I have ipywidgets version 6 or later
  2. used the “Save Notebook with Widgets” action in the Widgets menu in the Jupyter.
  3. Uploaded the notebook to my github my repo and the environment.yml file
  4. copied the link of my notebook to the nbviewr
  5. clicked on Execute on Binder

Expected behavior to be able to download the interactive heatmap plot the HTML file.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context I'm not sure if I was doing the correct steps or if I provided enough details. If there more info needed please tell me

This is a link to the notebook on Github

Any hint \ idea will be welcome

Many thanks for your help!

cornhundred commented 3 years ago

Yes, it is possible but using the latest version of Widgets I've only been able to do this using nbconvert on the terminal "jupyter nbconvert --to html my-notebook.ipynb"

TalWac commented 3 years ago

@cornhundred - Thank you for answering, much appreciated!

it is possible but using the latest version of Widgets

I have the ipywidgets package version 7.6.3 installed and downloaded in the script - Is this what meant?

If so, is there anything else that needs to be done in the script ( since it still does not display me the interactive heatmap?

Many Thanks, Tal

TalWac commented 3 years ago

Are there any more ideas on how to make interactive heatmap work with clustergrammer2 on an HTML file? I just do not know what am I doing wrong

cornhundred commented 3 years ago

Hi @TalWac you have to run the nbconvert command in a terminal outside of Jupyter. They may have also fixed this functionality in Jupyter Lab 3 - I'll check and update

TalWac commented 3 years ago

Hi @cornhundred thank you for answering!- I did run the nbconvert command in the terminal and an HTML was created but without the part of the clustergrammer2 ( the interactive heatmap)

cornhundred commented 3 years ago

Ok, I forgot if you are running the normal Jupyter notebook (not Lab) you will also need to tell Jupyter to save the widget state after the notebook has run using the drop down described here https://clustergrammer.readthedocs.io/clustergrammer_widget.html?highlight=Save#sharing-with-nbviewer

Or a more updated version here

https://ipywidgets.readthedocs.io/en/latest/embedding.html#save-notebook-widget-state

If you are running Jupyter Lab you can tell it to aromatically save widget state.

TalWac commented 3 years ago

I did follow the steps to tell Jupyter to save the widget state using the dropdown. But, sill, I receive an HTML file without the interactive heatmap

cornhundred commented 3 years ago

Hi @TalWac that is odd. Another option is to use papermill https://papermill.readthedocs.io/en/latest/ to run your notebook. This approach has worked well for me in the past and should automatically embed widget data into the saved notebook - then you have to run nbconvert on the output notebook. I can provide more details if you run into issues.

TalWac commented 3 years ago

Thank you @cornhundred very much for your time and effort! I'll check the papermill and update if any issues appears

TalWac commented 3 years ago

Dear - @cornhundred - still it seems I'm doing something wrong. but I can not figure what

These are the steps I made the use of the papermill :

  1. Installing the papermill conda install -c conda-forge papermill

  2. Executing as written in the link Execute via the Python API:

    import papermill as pm

    pm.execute_notebook( 'D:/path/to/notebook//Report-notbook.ipynb', 'D:/path/to/notebook/to /be/created/Report-notbook-out.ipynb' )

  3. Then in the command line jupyter nbconvert --to html Report-notbook-out.ipynb.ipynb

However, the HTML file created has no interactive heatmap in it

Also tried to run the notebook using JupyterLab- but doing so, I was not able to plot the heatmap at all. only received the icon Loading widget...

Kindly your advice Regards