{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Normalizing a cancer contact count matrix with\u00a0CAIC\n\n\nCAIC is a normalization method to remove copy-number biases present in a\nmatrix. This example showcases how to perform such a normalization on\nsimulated data with `iced`.\n\n\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Loading the data and normalizing\n--------------------------------\n\nThe normalization is done in three step:\n\n 1. Normalize the data using LOIC, to remove GC, mappability, and other\n biases\n 2. Estimate the block biases due to copy number.\n 3. Remove the block biases from the LOIC-normalized contact counts\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from iced import datasets\nfrom iced import normalization\nimport matplotlib.pyplot as plt\nfrom matplotlib import colors\n\n\ncounts, lengths, cnv = datasets.load_sample_cancer()\n\nloic_normed = normalization.ICE_normalization(counts, counts_profile=cnv)\nblock_biases = normalization.estimate_block_biases(counts, lengths, cnv)\ncaic_normed = loic_normed / block_biases" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Visualizing the results using Matplotlib\n----------------------------------------\n\nThe following code visualizes the raw original data, the estimated block\nbiases, and the normalized matrix using the CAIC method.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "chromosomes = [\"I\", \"II\", \"III\", \"IV\", \"V\", \"VI\"]\n\nfig, axes = plt.subplots(ncols=3, figsize=(14, 3))\n\naxes[0].imshow(counts, cmap=\"RdBu_r\", norm=colors.SymLogNorm(1),\n origin=\"bottom\",\n extent=(0, len(counts), 0, len(counts)))\n\n[axes[0].axhline(i, linewidth=1, color=\"#000000\") for i in lengths.cumsum()]\n[axes[0].axvline(i, linewidth=1, color=\"#000000\") for i in lengths.cumsum()]\naxes[0].set_title(\"Raw contact counts\", fontweight=\"bold\")\n\nm = axes[1].imshow(block_biases, cmap=\"RdBu_r\", norm=colors.SymLogNorm(1),\n origin=\"bottom\",\n extent=(0, len(counts), 0, len(counts)))\n[axes[1].axhline(i, linewidth=1, color=\"#000000\") for i in lengths.cumsum()]\n[axes[1].axvline(i, linewidth=1, color=\"#000000\") for i in lengths.cumsum()]\naxes[1].set_title(\"Estimated block biases\", fontweight=\"bold\")\n\nm = axes[2].imshow(caic_normed,\n cmap=\"RdBu_r\", norm=colors.SymLogNorm(1),\n origin=\"bottom\",\n extent=(0, len(counts), 0, len(counts)))\n[axes[2].axhline(i, linewidth=1, color=\"#000000\") for i in lengths.cumsum()]\n[axes[2].axvline(i, linewidth=1, color=\"#000000\") for i in lengths.cumsum()]\ncb = fig.colorbar(m)\naxes[2].set_title(\"Normalized contact counts with CAIC\", 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 }