devtools::load_all('..') rmarkdown::render('DeLorean-Guo.Rmd') ```r library(knitr) library(knitcitations) library(rmarkdown) # # knitr options # opts_chunk$set( fig.path = 'figures/Guo-', stop_on_error = TRUE, fig.width = 12.5, fig.height = 8) # # Citations # cleanbib() cite_options( # hyperlink = 'to.doc', hyperlink = TRUE, # style = 'html', # citation_format = 'text', citation_format = "pandoc", cite.style = "numeric", check.entries = TRUE) # hyperlink = TRUE) bib <- read.bibtex("DeLorean.bib") if (file.exists("config.R")) { source("config.R") }
# suppressMessages(loadfonts()) library(DeLorean) # # Stylesheet # options(markdown.HTML.stylesheet = system.file(file.path('Rmd', 'foghorn.css'), package="DeLorean")) font.family <- "Verdana" font.theme <- theme_update(text=element_text(family=font.family)) theme_set(font.theme)
r citet(bib[["guo_resolution_2010"]])
performed qPCR on mouse embryonic
cells at various stages.
Guo et al.'s data is available in the DeLorean
R package.
library(DeLorean) data(GuoDeLorean) dl <- de.lorean( guo.expr, guo.gene.meta, guo.cell.meta)
Examine data for empirical Bayes estimation of hyperparameters.
dl <- estimate.hyper(dl, sigma.tau=0.5)
Choose a few genes.
set.seed(1) num.genes <- nrow(dl$gene.meta) # All genes sampled.genes <- sample_n(dl$gene.meta, num.genes)$gene gene.filter <- function(genes) genes %in% sampled.genes dl <- filter_genes(dl, gene.filter)
Choose a few cells from each stage.
num.at.each.stage <- 9 te.sampled.cells <- ( dl$cell.meta %>% filter(capture < "32C" | "TE" == cell.type) %>% group_by(capture) %>% do(sample_n(., num.at.each.stage)) ) pe.sampled.cells <- ( dl$cell.meta %>% filter(capture < "32C" | "PE" == cell.type | "ICM" == cell.type) %>% group_by(capture) %>% do(sample_n(., num.at.each.stage)) ) epi.sampled.cells <- ( dl$cell.meta %>% filter(capture < "32C" | "EPI" == cell.type | "ICM" == cell.type) %>% group_by(capture) %>% do(sample_n(., num.at.each.stage)) ) run.model <- function(dl, cells.sampled) { cell.filter <- function(cells) cells %in% cells.sampled dl <- filter_cells(dl, cell.filter) dl <- prepare.for.stan(dl) dl <- compile.model(dl) dl <- find.best.tau(dl) system.time(dl <- fit.model(dl, num.cores=20)) dl <- examine.convergence(dl) dl <- process.posterior(dl) dl <- analyse.noise.levels(dl) dl <- make.predictions(dl) dl } dl.te <- run.model(dl, te.sampled.cells$cell) dl.pe <- run.model(dl, pe.sampled.cells$cell) dl.epi <- run.model(dl, epi.sampled.cells$cell)
Compare the profiles in the three fitted models for the TE, PE and ICM.
gp <- cmp.profiles.plot(TE=dl.te, PE=dl.pe, EPI=dl.epi, genes=dl.te$gene.map$gene) print(gp) png('Guo-fates.png', width=1400, height=900) print(gp) dev.off()
# Save DeLorean object without fit component saveRDS({dl2 <- dl; dl2$fit <- NULL; dl2}, "Data/Guo.rds")
R version and packages used:
sessionInfo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.