{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Visualizing an interactive ordination" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "deletable": true, "editable": true, "slideshow": { "slide_type": "slide" } }, "outputs": [], "source": [ "import pandas as pd, numpy as np\n", "from emperor import Emperor, nbinstall\n", "from skbio import OrdinationResults\n", "\n", "nbinstall()\n", "\n", "def load_mf(fn, index='#SampleID'):\n", " _df = pd.read_csv(fn, sep='\\t', dtype=str, keep_default_na=False, na_values=[])\n", " _df.set_index(index, inplace=True)\n", " return _df" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "We are going to load data from [Fierer et al. 2010](http://www.pnas.org/content/107/14/6477.full) (the data was retrieved from study [232](https://qiita.ucsd.edu/study/description/232) in [Qiita](https://qiita.ucsd.edu), remember you need to be logged in to access the study).\n", "\n", "Specifically, here we will reproduce *Figure 1 A*." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "deletable": true, "editable": true, "slideshow": { "slide_type": "slide" } }, "outputs": [], "source": [ "mf = load_mf('keyboard/mapping-file.txt')\n", "res = OrdinationResults.read('keyboard/unweighted-unifrac.even1000.txt')" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "If you want to share your notebook via GitHub use `remote=True` and make sure you share your notebook using nbviewer." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [], "source": [ "viz = Emperor(res, mf, remote=False)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [], "source": [ "viz" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.1" }, "widgets": { "state": {}, "version": "1.1.2" } }, "nbformat": 4, "nbformat_minor": 0 }