{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "hidden": true }, "outputs": [], "source": [ "library(IRkernel)\n", "library(IRdisplay)\n", "library(repr)\n", "library(base64enc)\n", "library(ggplot2) # would shadow Biobase::exprs\n", "\n", "suppressPackageStartupMessages({\n", " library(readxl)\n", " library(destiny)\n", " library(Biobase)\n", "})\n", "\n", "options(device = function(...) png('/dev/null', 7, 6, 'in', res = 120))\n", "options(repr.plot.width = 7, repr.plot.height = 6)\n", "options(jupyter.plot_mimetypes = c('application/pdf', 'image/png'))\n", "\n", "setHook('on.rgl.close', function(...) {\n", " name <- tempfile()\n", " par3d(windowRect = c(0, 0, 1200, 1200))\n", " Sys.sleep(1)\n", " \n", " rgl.snapshot( filename = paste0(name, '.png'))\n", " #rgl.postscript(filename = paste0(name, '.pdf'), fmt='pdf') # doesn’t work with spheres\n", " \n", " res <- getOption('repr.plot.res')\n", " \n", " publish_mimebundle(list(\n", " 'image/png' = base64encode(paste0(name, '.png'))\n", " #, 'application/pdf' = base64encode(paste0(name, '.pdf'))\n", " ), list(\n", " width = res * getOption('repr.plot.width'),\n", " height = res * getOption('repr.plot.height')\n", " ))\n", "}, 'replace')" ] }, { "cell_type": "markdown", "metadata": { "name": "introduction" }, "source": [ "Diffusion maps are spectral method for non-linear dimension reduction introduced by Coifman et al. (2005). Diffusion maps are based on a distance metric (diffusion distance) which is conceptually relevant to how differentiating cells follow noisy diffusion-like dynamics, moving from a pluripotent state towards more differentiated states.\n", "\n", "The R package **destiny** implements the formulation of diffusion maps presented in Haghverdi et al. (2015) which is especially suited for analyzing single-cell gene expression data from time-course experiments. It implicitly arranges cells along their developmental path, with bifurcations where differentiation events occur.\n", "\n", "In particular we follow Haghverdi et al. (2015) and present an implementation of diffusion maps in R that is less affected by sampling density heterogeneities and thus capable of identifying both abundant and rare cell populations. In addition, **destiny** implements complex noise models reflecting zero-inflation/censoring due to drop-out events in single-cell qPCR data and allows for missing values. Finally, we further improve on the implementation from Haghverdi et al. (2015), and implement a nearest neighbour approximation capable of handling very large data sets of up to 300.000 cells.\n", "\n", "For those familiar with R, and data preprocessing, we recommend the section [Plotting](#Plotting).\n", "\n", "All code in this vignette is accessible via `edit(vignette('destiny'))`" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Preprocessing of single qPCR data\n", "================\n", "\n", "As an example, we present in the following the preprocessing of data from Guo et al. (2010). This dataset was produced by the Biomark RT-qPCR system and contains Ct values for 48 genes of 442 mouse embryonic stem cells at 7 different developmental time points, from the zygote to blastocyst.\n", "\n", "Starting at the totipotent 1-cell stage, cells transition smoothly in the transcriptional landscape towards either the trophoectoderm lineage or the inner cell mass. Subsequently, cells transition from the inner cell mass either towards the endoderm or epiblast lineage. This smooth transition from one developmental state to another, including two bifurcation events, is reflected in the expression profiles of the cells and can be visualized using **destiny**.\n", "\n", "Import\n", "-----\n", "\n", "Downloading the table S4 from the [publication website](http://www.sciencedirect.com/science/article/pii/S1534580710001103) will give you a spreadsheet “mmc4.xls”, from which the data can be loaded:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/html": [ "
Cell | Actb | Ahcy | Aqp3 | Atp12a | Bmp4 | Cdx2 | Creb312 | Cebpa |
---|---|---|---|---|---|---|---|---|
1C 1 | 14.01 | 19.28 | 23.89 | 28 | 28 | 21.28 | 20.84 | 28.00 |
1C 2 | 13.68 | 18.56 | 28.00 | 28 | 28 | 23.43 | 20.93 | 28.00 |
1C 3 | 13.42 | 18.19 | 26.18 | 28 | 28 | 22.87 | 19.61 | 28.00 |
1C 4 | 13.69 | 18.59 | 28.00 | 28 | 28 | 23.28 | 20.72 | 28.00 |
1C 5 | 13.47 | 18.60 | 24.20 | 28 | 28 | 24.19 | 21.75 | 23.69 |
1C 6 | 12.86 | 17.37 | 25.53 | 28 | 28 | 21.87 | 21.27 | 28.00 |
1C 7 | 12.95 | 17.37 | 23.93 | 28 | 28 | 22.74 | 21.12 | 28.00 |
1C 8 | 12.77 | 18.40 | 23.68 | 28 | 28 | 24.14 | 19.80 | 28.00 |
1C 9 | 13.29 | 18.26 | 28.00 | 28 | 28 | 21.91 | 21.18 | 28.00 |