More IPython Fun

Below is some of the code we wrote today in class to begin visualizing our transcriptomic data. To be beautified…

Notebook

<!-- Custom stylesheet, it must be in the same directory as the html file -->

<!-- Loading mathjax macro -->
<!-- Load mathjax -->
<!-- MathJax configuration -->//
<!-- End of mathjax configuration -->

&nbsp;
<div id="notebook" class="border-box-sizing">
<div id="notebook-container" class="container">
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In [1]:</div>
<div class="inner_cell">
<div class="input_area">
<div class="highlight">
<pre><span class="kn">import</span> <span class="nn">pandas</span> <span class="kn">as</span> <span class="nn">pd</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In [11]:</div>
<div class="inner_cell">
<div class="input_area">
<div class="highlight">
<pre><span class="n">jslim</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">read_csv</span><span class="p">(</span><span class="s">'GOSlim_query_P.csv'</span><span class="p">)</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In [12]:</div>
<div class="inner_cell">
<div class="input_area">
<div class="highlight">
<pre><span class="n">jslim</span><span class="o">.</span><span class="n">groupby</span><span class="p">(</span><span class="s">'GOSlim_bin'</span><span class="p">)</span><span class="o">.</span><span class="n">Column1</span><span class="o">.</span><span class="n">count</span><span class="p">()</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">kind</span><span class="o">=</span><span class="s">'bar'</span><span class="p">)</span>
</pre>
</div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt output_prompt">Out[12]:</div>
<div class="output_text output_subarea output_pyout">
<pre>&lt;matplotlib.axes.AxesSubplot at 0x108355410&gt;
</pre>
</div>
</div>
<div class="output_area"></div>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In [6]:</div>
<div class="inner_cell">
<div class="input_area">
<div class="highlight">
<pre><span class="n">pylab</span> <span class="n">inline</span> 
</pre>
</div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt"></div>
<div class="output_subarea output_stream output_stdout output_text">
<pre>Populating the interactive namespace from numpy and matplotlib

</pre>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In [13]:</div>
<div class="inner_cell">
<div class="input_area">
<div class="highlight">
<pre><span class="n">jslim</span><span class="o">.</span><span class="n">groupby</span><span class="p">(</span><span class="s">'GOSlim_bin'</span><span class="p">)</span><span class="o">.</span><span class="n">Column1</span><span class="o">.</span><span class="n">count</span><span class="p">()</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">kind</span><span class="o">=</span><span class="s">'pie'</span><span class="p">)</span>
</pre>
</div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt output_prompt">Out[13]:</div>
<div class="output_text output_subarea output_pyout">
<pre>&lt;matplotlib.axes.AxesSubplot at 0x1086652d0&gt;
</pre>
</div>
</div>
<div class="output_area"></div>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In [14]:</div>
<div class="inner_cell">
<div class="input_area">
<div class="highlight">
<pre><span class="o">!</span>ipython nbconvert <span class="o">{</span>nbloc<span class="o">}{</span>nb<span class="o">}</span> --to html --template full  --output <span class="o">{</span>nb<span class="o">}{</span>date<span class="o">}</span>
</pre>
</div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt"></div>
<div class="output_subarea output_stream output_stdout output_text">
<pre>[NbConvertApp] Using existing profile dir: u'/Users/fhlguest/.ipython/profile_default'

[NbConvertApp] WARNING | pattern u'{nbloc}{nb}' matched no files

This application is used to convert notebook files (*.ipynb) to various other

formats.



WARNING: THE COMMANDLINE INTERFACE MAY CHANGE IN FUTURE RELEASES.



Options

-------



Arguments that take values are actually convenience aliases to full

Configurables, whose aliases are listed on the help line. For more information

on full configurables, see '--help-all'.



--debug

    set log level to logging.DEBUG (maximize logging output)

--init

    Initialize profile with default config files.  This is equivalent

    to running `ipython profile create &lt;profile&gt;` prior to startup.

--quiet

    set log level to logging.CRITICAL (minimize logging output)

--stdout

    Write notebook output to stdout instead of files.

--profile=&lt;Unicode&gt; (BaseIPythonApplication.profile)

    Default: u'default'

    The IPython profile to use.

--reveal-prefix=&lt;Unicode&gt; (RevealHelpPreprocessor.url_prefix)

    Default: 'reveal.js'

    The URL prefix for reveal.js. This can be a a relative URL for a local copy

    of reveal.js, or point to a CDN.

    For speaker notes to work, a local reveal.js prefix must be used.

--ipython-dir=&lt;Unicode&gt; (BaseIPythonApplication.ipython_dir)

    Default: u''

    The name of the IPython directory. This directory is used for logging

    configuration (through profiles), history storage, etc. The default is

    usually $HOME/.ipython. This options can also be specified through the

    environment variable IPYTHONDIR.

--writer=&lt;DottedObjectName&gt; (NbConvertApp.writer_class)

    Default: 'FilesWriter'

    Writer class used to write the  results of the conversion

--log-level=&lt;Enum&gt; (Application.log_level)

    Default: 30

    Choices: (0, 10, 20, 30, 40, 50, 'DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL')

    Set the log level by value or name.

--to=&lt;CaselessStrEnum&gt; (NbConvertApp.export_format)

    Default: 'html'

    Choices: ['custom', 'html', 'latex', 'markdown', 'python', 'rst', 'slides']

    The export format to be used.

--template=&lt;Unicode&gt; (TemplateExporter.template_file)

    Default: u'default'

    Name of the template file to use

--output=&lt;Unicode&gt; (NbConvertApp.output_base)

    Default: ''

    overwrite base name use for output files. can only  be use when converting

    one notebook at a time.

--post=&lt;DottedOrNone&gt; (NbConvertApp.postprocessor_class)

    Default: u''

    PostProcessor class used to write the  results of the conversion

--config=&lt;Unicode&gt; (BaseIPythonApplication.extra_config_file)

    Default: u''

    Path to an extra config file to load.

    If specified, load this config file in addition to any other IPython config.

--profile-dir=&lt;Unicode&gt; (ProfileDir.location)

    Default: u''

    Set the profile location directly. This overrides the logic used by the

    `profile` option.



To see all available configurables, use `--help-all`



Examples

--------



    The simplest way to use nbconvert is

    

    &gt; ipython nbconvert mynotebook.ipynb

    

    which will convert mynotebook.ipynb to the default format (probably HTML).

    

    You can specify the export format with `--to`.

    Options include ['custom', 'html', 'latex', 'markdown', 'python', 'rst', 'slides']

    

    &gt; ipython nbconvert --to latex mynotebook.ipynb

    

    Both HTML and LaTeX support multiple output templates. LaTeX includes

    'base', 'article' and 'report'.  HTML includes 'basic' and 'full'. You

    can specify the flavor of the format used.

    

    &gt; ipython nbconvert --to html --template basic mynotebook.ipynb

    

    You can also pipe the output to stdout, rather than a file

    

    &gt; ipython nbconvert mynotebook.ipynb --stdout

    

    A post-processor can be used to compile a PDF

    

    &gt; ipython nbconvert mynotebook.ipynb --to latex --post PDF

    

    You can get (and serve) a Reveal.js-powered slideshow

    

    &gt; ipython nbconvert myslides.ipynb --to slides --post serve

    

    Multiple notebooks can be given at the command line in a couple of 

    different ways:

    

    &gt; ipython nbconvert notebook*.ipynb

    &gt; ipython nbconvert notebook1.ipynb notebook2.ipynb

    

    or you can specify the notebooks list in a config file, containing::

    

        c.NbConvertApp.notebooks = ["my_notebook.ipynb"]

    

    &gt; ipython nbconvert --config mycfg.py




</pre>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In []:</div>
<div class="inner_cell"></div>
</div>
</div>
</div>
</div>
&nbsp;

Leave a Reply