Learn R Programming

DeLorean

R package to model time series accounting for noise in the temporal dimension. Specifically designed for single cell transcriptome experiments.

Requirements

To render the vignettes you will need a working version (> 1.12.3) of pandoc on your machine with the pandoc-citeproc filter. On Ubuntu do:

sudo apt-get install pandoc pandoc-citeproc

Installation from CRAN

Just run the following in an R session:

install.packages('DeLorean')

Installation from source

If you prefer to have the very latest version you can install DeLorean from source. If you do not already have devtools installed, then install it by running:

install.packages('devtools')

Now you can install the development version of DeLorean with:

devtools::install_github('JohnReid/DeLorean')

Documentation

Read the vignette:

vignette('DeLorean')

Copy Link

Version

Install

install.packages('DeLorean')

Version

1.5.0

License

MIT + file LICENSE

Maintainer

Last Published

October 17th, 2018

Functions in DeLorean (1.5.0)

anders.huber.cell.sizes

Estimate the cell sizes according to Anders & Huber Differential expression analysis for sequence count data
cov.matern.32

Matern 3/2 covariance function
adjust.by.cell.sizes

Adjust the expression by the estimated cell sizes.
alpha.for.rug

Calculate a suitable value for a rug plot given the number of points
cov.periodise

Makes a distance periodic
cmp.profiles.plot

Plot a comparison of the profiles from several de.lorean objects
de.lorean.stylesheet

The filename of the R markdown stylesheet
cov.all.genes.conditioned

Calculate covariances for all genes when conditioned on data at estimated pseudotimes.
create.ordering.ll.fn

Calculate the covariance structure of evenly spread tau and create a function that calculates the log likelihood of orderings.
default.num.cores

Default number of cores to use.
gaussian.condition

Condition a Gaussian on another. See Eqn. A.6 on page 200 of Rasmussen and Williams' book.
de.lorean

Initialise DeLorean object
fit.model.sample

Fit the model using Stan sampler
gene.covariances

Calculate the covariance structure of the tau
fit.model.vb

Fit the model using Stan variational Bayes
filter_cells

Filter cells
filter_genes

Filter genes
gp.predictions.df

Convert the output of gp.predict() into a data.frame.
held.out.posterior.by.variation

Order the genes by the variation of their posterior mean
kouno.expr

Kouno et al. investigated the transcriptional network controlling how THP-1 human myeloid monocytic leukemia cells differentiate into macrophages. They provide expression values for 45 genes in 960 single cells captured across 8 distinct time points.
held.out.posterior.filter

Filter the genes
make.fit.valid

Make a fit valid by running one iteration of the sampler.
make.init.fn

Returns a function that constructs parameter settings with good tau.
guo.expr

Single cell expression data and meta data from Guo et al. (2012). They investigated the expression of 48 genes in 500 mouse embryonic cells.
mutate.profile.data

Mutate the profile data into shape compatible with GP plot function
is.de.lorean

Is a DeLorean object?
knit.report

Knit a report, the file inst/Rmd/<report.name>.Rmd must exist in the package directory.
make.predictions

Make predictions
optimise.best.sample

Optimise the best sample and update the best.sample index.
ordering.maximise

Find a good ordering in the sense that some function is locally maximised.
ordering.random.move

Randomly move one item in an ordering to another location
marg.like.plot

Plot posterior for marginal log likelihoods of individual gene's expression profiles
ordering.test.score

Test ordering score: sum every time consecutive items are in order.
avg.par.samples

Average across a parameters samples.
test.fit

Test fit for log normal and gamma
melt.expr

Melt an expression matrix.
orderings.plot

Plot likelihoods of orderings against elapsed times taken to generate them
ordering.metropolis.hastings

Metropolis-Hastings on orderings.
test.mh

Test ordering Metropolis-Hastings sampler.
analyse.noise.levels

Analyse noise levels and assess which genes have the greatest ratio of temporal variance to noise. This are labelled as the 'gene.high.psi' genes.
process.posterior

Process the posterior, that is extract and reformat the samples from Stan. We also determine which sample has the highest likelihood, this is labelled as the 'best' sample.
partition.de.lorean

Partition de.lorean object by cells
cov.calc.gene

Calculate covariance structure for gene over pseudotimes and test inputs.
analyse.variance

Analyse variance of expression between and within capture times.
calc.inducing.pseudotimes

Calculate inducing pseudotimes for sparse approximation
pseudotime.plot

Plot pseudotime (tau) against observed capture time.
DeLorean-package

The 'DeLorean' package.
cov.calc.gene.conditioned

Calculate covariance for gene over test inputs when conditioned on data at estimated pseudotimes.
calc.roughness

Calculate the roughness of the vector. The roughness is the RMS of the differences between consecutive points.
profiles.plot

Plot best sample predicted expression.
Rhat.plot

Plot the Rhat convergence statistics. examine.convergence must be called before this plot can be made.
roughness.test

Calculate roughnesses under fit samples and also under random permutations
cov.calc.dists

Calculate distances between vectors of time points
cov.calc.dl.dists

Calculate distances over estimated pseudotimes and test inputs.
estimate.hyper

Estimate hyperparameters for model using empirical Bayes.
expected.sample.var

The expected within sample variance of a Gaussian with the given covariance.
centralise

Centralises a periodic position into [period/2, period) by shifting by n*period, where n is an integer
fit.held.out

Fit held out genes
examine.convergence

Analyse the samples and gather the convergence statistics. Note this only makes sense if a sampling method was used to fit the model as opposed to variational Bayes.
dim.de.lorean

Dimensions of DeLorean object
fit.model

Fit the model using specified method (sampling or variational Bayes).
pseudotimes.from.orderings

Convert best orderings into initialisations
pseudotimes.pair.plot

Plot two sets of pseudotimes against each other.
roughnesses.plot

Plot results of roughness test
report.file

The filename of the R markdown report.
gp.log.marg.like

The log marginal likelihood. See "2.3 Varying the Hyperparameters" on page 19 of Rasmussen and Williams' book.
expr.data.plot

Plot the expression data by the capture points
gp.predict

Predictive mean, variance and log marginal likelihood of a GP. See "2.3 Varying the Hyperparameters" on page 19 of Rasmussen and Williams' book.
find.best.tau

Find best tau to initialise chains with by sampling tau from the prior and using empirical Bayes parameter estimates for the other parameters.
estimate.cell.sizes

Estimate the cell sizes. We only consider genes that are expressed in a certain proportion of cells.
find.smooth.tau

Find best order of the samples assuming some smooth GP prior on the expression profiles over this ordering.
ordering.invert

Invert the ordering
permute.df

Permute a data frame, x. If group.col is given it should name an ordered factor that the order of the permutation should respect.
permuted.roughness

Permute cells and test roughness of expression.
ordering.is.valid

Check that it is a valid ordering
get.posterior.mean

Get posterior mean of samples
find.good.ordering

Run a find good ordering method and append results to existing orderings
plot.de.lorean

Various DeLorean object plots
fit.dl

Perform all the steps necessary to fit the model:
  1. prepare the data

  2. find suitable initialisations

  3. fit the model using the specified method (sampling or variational Bayes)

  4. process the posterior

held.out.melt

Melt held out genes
get_model

Get the Stan model for a DeLorean object.
plot.held.out.posterior

Plot the posterior of held out genes
held.out.posterior

Calculate posterior covariance and estimate parameters for held out genes given pseudotimes estimated by DeLorean model.
test.robustness.de.lorean

Test robustness of pseudotime estimation on subsets of de.lorean object
inducing.covariance

Calculate the covariance structure of the inducing points
windram.expr

Windram et al. investigated the defense response in Arabidopsis thaliana to the necrotrophic fungal pathogen Botrytis cinerea. They collected data at 24 time points in two conditions for 30336 genes.
init.orderings.vs.pseudotimes.plot

Plot the orderings for initialisation against the estimated pseudotime.
held.out.posterior.join

Join with another data frame. Useful for adding gene names etc..
ordering.block.move

Move a block in an ordering and shift the other items.
held.out.select.genes

Select held out genes by those with highest variance
prepare.for.stan

Prepare for Stan
print.de.lorean

Print details of DeLorean object
seriation.find.orderings

Use seriation package to find good orderings
tau.offsets.plot

Plot the tau offsets, that is how much the pseudotimes (tau) differ from their prior means over the full posterior.
ordering.improve

Improve the ordering in the sense that some function is maximised.
ordering.random.block.move

Randomly move a block in an ordering to another location
ordering.move

Move one item in an ordering and shift the other items.
plot.add.expr

Add expression data to a plot
plot.add.mean.and.variance

Add posterior representation to a plot.
roughness.of.permutations

Apply permutation based roughness test to held out genes
roughness.of.sample

Calculate the roughness of the held out genes given the sample.
aov.dl

Perform an analysis of variance to select genes for the DeLorean model.