Online Companion to Wayne’s Poster for Retreat 2016

Links and resources for Jupyter Notebook and how to launch shareable active Jupyter Notebooks from a poster presented at Upstate Medical University’s Biomedical Sciences Retreat 2016. Poster entitled: Biomedical Science on Jupyter: Comprehensible and Reproducible Scientific Workflows with Shared, Active Jupyter Notebooks

Launch Demo Binder

Go to an example repository by clicking HERE.

Once there, click on the Binder button to launch the demo.

Give the notebook a minute to load and then press SHIFT+ENTER on your keyboard or press the play button in the toolbar several times to step through and run cells.

The cells that should run will have the In [ ] on the left and they will become filled with numbers when complete. Several will have viewable output.

Go back to the repository main page. Once there, click the blue text that says Decoding translation in the cloud and at....

This will open a rendering of the notebook, but you see all the In [ ] on the left have nothing between the brackets and none of the output cells are present.

This is a static rendering of the notebook. We cannot interact with it. If I had saved the completely run notebook, the output would be there but we still would not be able to interact with it. (And so it is useful, but not as useful as an active Jupyter Notebook.)

(A richer version of the static version of the notebook can be viewed here via the nbviewer that will render any Github-hosted Jupyter Notebook. Often this works better for notebooks that have fancy plots embedded that the default Github rendering doesn’t handle.)

This was a very simple notebook that has a good mix of the features as it was meant to touch casually on some molecular biology aspects while introducing the Jupyter Notebook system to some students that visited Upstate.

The repository hosting that Jupyter Notebook can be found here. To get the launch binder button to work I had to previously tell the Freeman Lab’s Binder system found at mybinder.org to build a binder from that repository at Github. That binder then becomes available for users to spin up notebooks on-demand, essentially instantaneously.

Basic Notebooks to Illustrate Use in the Lab

These links will take you to the Github page where you’ll see links to the static notebooks as well as Binder buttons to launch the notebooks as active notebooks using the Freeman Lab’s Binder system found at mybinder.org.

Click the Binder button at any of the following repositories for an active notebook:

Notable Notebooks

See the penultimate page of this online documentation for a list of example scientific Jupyter Notebooks, entitled A sampling of scientific notebooks & extensions.

To get there, the easiest way is to click here press or Next in the bottom right of each page three times to get to the page entitled References and Resources to Match Poster Sections.

See that page as well as for the list of example notebooks using the Github/Binder approach.

Essential Resources

Annotated, Essential Resources

Poster

poster

References and Resources to Match Poster Sections

Background

A sampling of scientific notebooks & extensions

Resources for Running Active Notebooks in the Cloud

I have made a page to walk you through trying tmpnb.org or try.jupyter.org, find it here.

  • Another alternative is to click here. I have not extensively run this site through it’s paces, and so I can offer a couple points about it and beyond that your mileage may vary. It was set up by the excellent Domino Data Lab to serve as a place to run an active notebook about differences between Python 2.x and 3.x without need for signing into the Domino Data Lab service. I know the free tier for signed in users is limited to 15 minutes, and so maybe the anonymous one also has this limitation as well? Also similar to tmpnb.org unless it is already installed, you won’t have access to other modules or be able to scrape data from other sites.

The Binder/Github set-up allows you to designate other modules you need loaded when the instance is spun-up, but that does mean some set-up steps as discussed in the appendix. Contact me if you need help understanding how to set this up.

Launching Active Versions of My Notebooks

Click the Binder button at any of the following repositories for an active notebook:

Ammonium Sulfate Precipitation Screen Calculator

Cell Density Estimator

The Cell Density Estimator where only a single sample is analyzed may be easier for novices to follow, and an active notebook can be launched here.

Yeast Growth Planner

Notebook designed as an active computing exercise for young students visiting the lab

The example notebook used for the introduction section of the poster can be found here

Contrast the transparency of the Ammonium Sulfate Precipitation Screen Calculator with a form-based Django site that performs same calculation here.

Other Noteable Notebooks Using Github/Binder approach

Appendix: Using tmpnb.org or try.jupyter.org

Get an active notebook running

tmpnb.org
  • If you already have a notebook file, click upload on the upper right side of the dashboard, and then point the browser at your file.
upload and new buttons

Click okay and then the notebook will show the name of your file at the top of the dashboard. Click the upload button next to that to actually upload.

ready for upload

Once uploaded, click on it in the list of notebooks to launch.

ready to launch

In the example above, the uploaded notebook Jupyter Notebook Basics.ipynb is now ready to be clicked on to initiate launch.

  • If you have no notebook, select one from the list or click New and choose your language option.
languages

(You can acquire notebook files from many sources that you could then upload for active use using the process outlined above. Several of such sources can be found by finding the Github accounts linked to the notebooks referenced here.)

Try the notebook

  • Tips
    • hit shift-enter to run a cell.
    • the pull-down menu in the toolbar lets you switch cells from code to markdown but there are also short-cuts.
    • Fom inside the notebook you can always return to the dashboard by clicking the Jupyter logo in the upper left side.
  • REMEMBER THE ACTIVE FORM IS EPHEMERAL. If you did anything that you are happy with, be sure to save it locally by going to File > Download as > Notebook and saving the file on your drive. Later you can use the upload process covered in the first part above to resume using it as an active notebook.
tmpnb.org

Appendix: Making your first Binder

Preparation

  • Obtain a Github account if you don’t already have one

  • Items to make in preparation

    • a Jupyter Notebook. Only absolute requirement.

      I suggest developing inside a notebook spawned from someone else’s Github/Binder combination or tmpnb.org, see here. Save often and local. Or simply copy an example notebook for testing. Notebooks end in the .ipynb extension.

    • requirements.txt file to specify dependencies.

      See step #2 at http://mybinder.org/. (Technically, not absolutely required if your needs don’t extend beyond basic Python or if mybinder.org already has the needed module installed. For example, when I looked into bokeh, they already had it. The availability of modules can be confirmed by typing import followed by the module name [or what designation is used to import that module usually] in a notebook spawned via MyBinder. If there is no error, than it is already available and you don’t need to add it to requirements.txt. Alternatively, there are other way to specify dependencies, see the site.)

Readying your Github Repository

Point my binder at your Github Repository

The MyBinder site
  • Paste the address if your Github repository in the space next to the submit button.
paste next to the submit button
  • Press Submit to initiate the build process.

** It will then look something like this as it starts building the launchable Binder version of your repository.**

building
  • Let it process. Only when all three dots on the left side turn green is it built, like below.
when done building
  • Grab the code for your launch button badge. They have markdown and restructured text versions available right there.
badge code area

The launch badge button is just an image linked to an html link that will trigger deploying of your notebook immediately on-demand via mybinder.org. Because the link conforms to a certain convention, you can also build it yourself later. The link to trigger launching an active form of your notebook will look like:

http://mybinder.org/repo/user_name/repo_name

-or-

http://mybinder.org/repo/user_name/repo_name/notebooks/specific_notebook.ipynb

You can easily get the code for the badge button off the build page or edit someone else’s links to point at yours. For example, you can use my text here to make badge buttons and/or links to your launchable notebooks. (Click the raw button to see the raw code for copying.)

This is what the launch button badge looks like —> Binder

  • Paste the launch binder button code in your README.md at your repository or put the link elsewhere.

Use your Binder

  • Test by launching an active notebook using the links and/or launch binder button badge.

    The active notebook should launch close to immediately (within several seconds) and you’ll be ready to go.

  • Share the link with others or point them at the site of the button.