{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Yeast sample data\n\n\nThis example showcases how to load the yeast sample data, plot it and plot the\nlocation of the chromosomes.\n\nThis data set corresponds to the first 5 chromosomes of the budding yeast *S.\ncerevisiae*, from Duan et al.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from iced import datasets" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Start by loading the data.\nThe data is composed of a counts ndarray matrix and a corresponding length\nvector. The size of each much match\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "counts, lengths = datasets.load_sample_yeast()\nassert(counts.shape[0] == lengths.sum())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We are then going to plot the data. The contact counts are typically very\nenriched close to the diagonal. Thus, we use a Log normalization on the\ncontact count data in order to see all the details of the plot.\nThe data here is very noisy : it corresponds to raw data. We plot the\nchromosome boundaries in white and add a colorbar.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\nfrom matplotlib import colors\n\nfig, ax = plt.subplots()\n# Add 0.5 to the contact count matrix to avoid taking the log of 0\nm = ax.matshow(counts+0.5, cmap=\"RdBu_r\", norm=colors.LogNorm(),\n origin=\"bottom\",\n extent=(0, counts.shape[0], 0, counts.shape[0]))\nchromosomes = [\"I\", \"II\", \"III\", \"IV\", \"V\", \"VI\"]\n\n# Now plot the chromosomes boundaries and set the title\n[ax.axhline(i, linewidth=1, color=\"#ffffff\") for i in lengths.cumsum()]\n[ax.axvline(i, linewidth=1, color=\"#ffffff\") for i in lengths.cumsum()]\ncb = fig.colorbar(m)\ncb.set_label(\"Contact counts\")\nax.set_title(\"Raw contact counts\", fontweight=\"bold\")" ] } ], "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.6.1" } }, "nbformat": 4, "nbformat_minor": 0 }