{ "cells": [ { "cell_type": "markdown", "metadata": { "toc": "true" }, "source": [ "# Table of Contents\n", "

1  Reproducible Research Using Jupyter Notebook
1.1  Jupyter Notebook
1.1.1  Installation
1.1.2  Usage
1.2  JupyterLab
1.3  Workshops at UCLA
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Reproducible Research Using Jupyter Notebook" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "> An article about computational science in a scientific publication is **not** the scholarship itself, it is merely **advertising** of the scholarship. The actual scholarship is the complete software development environment and the complete set of instructions which generated the figures.\n", "> \n", "> -- Buckheit and Donoho (1995)\n", "\n", "* For background and history of reproducible research in statistics/data science, see [lecture notes](http://hua-zhou.github.io/teaching/biostatm280-2019winter/slides/03-repres/repres.html) in 203B.\n", "\n", "* This course assumes familiarity with Git/GitHub and Jupyter Notebook. Your homework will be authored using Jupyter Notebook and submitted via Git/GitHub.\n", "\n", " For an introduction to Git/GitHub, see [lecture notes](http://hua-zhou.github.io/teaching/biostatm280-2019winter/slides/04-git/git.html) in 203B." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Jupyter Notebook\n", "\n", "* IPython notebook (precursor of Jupyter notebook) is a powerful tool for authoring dynamic document in Python, which combines code, formatted text, math, and multimedia in a single document. \n", "\n", "* [Jupyter](http://jupyter.org) is the current development that emcompasses multiple languages including **Ju**lia, **Pyt**hon, and **R**. \n", "\n", "* Julia uses Jupyter notebook through the [IJulia.jl](https://github.com/JuliaLang/IJulia.jl) package.\n", "\n", "* In this course, you are required to write your homework reports using IJulia.\n", "\n", "* For each homework, you need to submit your IJulia notebook (.e.g, `hw1.ipynb`), html (e.g., `hw1.html`), along with all code and data that are necessary to reproduce the results.\n", "\n", "* You can start with the Jupyter notebook for the lectures. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Installation\n", "\n", "Installing the IJulia.jl package will install a minimal Python/Jupyter distribution that is private to Julia.\n", "```julia\n", "using Pkg\n", "Pkg.add(\"IJulia\")\n", "```\n", "We can also tell IJulia to use a Jupyter program already installed in our system:\n", "```julia\n", "ENV[\"JUPYTER\"] = \"path_to_jupyter_executable\"\n", "Pkg.build(\"IJulia\")\n", "```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Usage\n", "\n", "* We can invoke Jupyter notebook within Julia by\n", "```julia\n", "using IJulia\n", "notebook() # using home as working directory \n", "```\n", "or, using current directory as the working directory, by\n", "```julia\n", "notebook(dir=pwd()) # using current directory as working directory \n", "```\n", "\n", "* Notebook can be stopped by hitting `Ctrl+c` in Julia REPL.\n", "\n", "* Useful to know some keyboard shortcuts. I frequently use\n", " * `shift + return`: execute current cell. \n", " * `b`: create a cell below current cell.\n", " * `a`: create a cell above current cell. \n", " * `y`: change cell to code. \n", " * `m`: change cell to Markdown. \n", " Check more shortcuts in menu `Help` -> `Keyboard Shortcuts`.\n", "\n", "* **Notebook extensions** offer many utilities for productivity. They can be installed by\n", "```julia\n", "#Pkg.add(\"Conda\")\n", "using Conda\n", "Conda.add_channel(\"conda-forge\")\n", "Conda.add(\"jupyter_contrib_nbextensions\")\n", "```\n", "\n", "* Notebook can be **converted to other formats** such as html, LaTeX, Markdown, Julia code, and many others, via menu `File` -> `Download as`. For your homework, please submit both notebook (ipynb) and html.\n", "\n", "* **Mathematical formula** can can be typeset as LaTeX in Markdown cells. For example, inline math: $e^{i \\pi} + 1 = 0$ and displayed math\n", "$$\n", " e^x = \\sum_{i=0}^\\infty \\frac{1}{i!} x^i.\n", "$$\n", "For multiline displayed math:\n", "\\begin{eqnarray*}\n", " e^x &=& \\sum_{i=0}^\\infty \\frac{1}{i!} x^i \\\\\n", " &\\approx& 1 + x + \\frac{x^2}{2}.\n", "\\end{eqnarray*}\n", "\n", "* If you have a lot of commonly used LaTeX macros, put them in a `.tex` file and load them using the notebook extension `Load TeX macros`. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JupyterLab\n", "\n", "JupyterLab (more IDE-like) is supposed to replace Jupyter Notebook after it reaches v1.0.\n", "\n", "To invoke JupyterLab:\n", "```julia\n", "jupyterlab() # use home as working directory\n", "```\n", "or\n", "```julia\n", "jupyterlab(dir=pwd()) # use current directory as working directory\n", "```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Workshops at UCLA\n", "\n", "IDRE (Institute for Digital Research and Education) at UCLA is offering seminars and workshops on computing and technology. Most are free. For example,\n", "\n", "* Introduction to Jupyter, **Apr 17**\n", "\n", "* Using Jupyter with Hoffman2 and HPC Systems, **Apr 24**\n", "\n", "See [IDRE calendar](https://idre.ucla.edu/calendar) for details." ] } ], "metadata": { "kernelspec": { "display_name": "Julia 1.1.0", "language": "julia", "name": "julia-1.1" }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "1.1.0" }, "toc": { "colors": { "hover_highlight": "#DAA520", "running_highlight": "#FF0000", "selected_highlight": "#FFD700" }, "moveMenuLeft": true, "nav_menu": { "height": "311px", "width": "252px" }, "navigate_menu": true, "number_sections": true, "sideBar": true, "skip_h1_title": true, "threshold": 4, "toc_cell": true, "toc_position": { "height": "262.5px", "left": "0px", "right": "800px", "top": "140.5px", "width": "204px" }, "toc_section_display": "block", "toc_window_display": true, "widenNotebook": false } }, "nbformat": 4, "nbformat_minor": 2 }