Package 'switchde'

Title: Switch-like differential expression across single-cell trajectories
Description: Inference and detection of switch-like differential expression across single-cell RNA-seq trajectories.
Authors: Kieran Campbell [aut, cre]
Maintainer: Kieran Campbell <[email protected]>
License: GPL (>= 2)
Version: 1.33.0
Built: 2024-12-18 04:25:22 UTC
Source: https://github.com/bioc/switchde

Help Index


Synthetic gene pseudotimes

Description

A vector with example pseudotimes for the synthetic gene expression data in example_gex

Usage

ex_pseudotime

Format

An object of class array of length 100.

Value

A vector of length 100


Example sigmoid plot

Description

Plot an example sigmoid function. For demonstration and documentation.

Usage

example_sigmoid()

Value

An object of class ggplot

Examples

example_sigmoid()

Extract parameters from fitted model

Description

Extract maximum likelihood parameter estimates from a call to switchde.

Usage

extract_pars(sde, gene)

Arguments

sde

The data.frame returned by switchde

gene

The gene for which to extract parameters

Value

A vector of length 3 corresonding to the parameters μ0\mu_0, kk and t0t_0

Examples

data(synth_gex)
data(ex_pseudotime)
sde <- switchde(synth_gex, ex_pseudotime)
pars <- extract_pars(sde, "Gene1")

Fit a (non-zero-inflated) model for a single gene

Description

Fits a sigmoidal expression model for a single gene vector, returning MLE model parameters and p-value.

Usage

fit_nzi_model(y, pst)

Arguments

y

Vector of gene expression values

pst

Pseudotime vector, of same length as y

Value

A vector with 5 entries: maximum likelihood estimates for μ0\mu_0, kk t0t0, σ2\sigma^2 and a p-value

Examples

data(synth_gex)
data(ex_pseudotime)
y <- synth_gex[1, ]
fit <- fit_nzi_model(y, ex_pseudotime)

Fit a zero-inflated model for a single gene

Description

Fits a zero-inflated sigmoidal model for a single gene vector, returning MLE model parameters and p-value.

Usage

fit_zi_model(y, pst, maxiter = 10000, log_lik_tol = 0.001,
  verbose = FALSE)

Arguments

y

Vector of gene expression values

pst

Pseudotime vector, of same length as y

maxiter

Maximum number of iterations for EM algorithm if zero inflation enabled. Default 100

log_lik_tol

If the change in the log-likelihood falls below this for zero inflated EM the algorithm is assumed to have converged

verbose

Print convergence update for EM algorithm

Value

A vector with 6 entries: maximum likelihood estimates for μ0\mu_0, kk t0t0, λ\lambda, σ2\sigma^2 and a p-value

Examples

data(synth_gex)
data(ex_pseudotime)
y <- synth_gex[1, ]
fit <- fit_zi_model(y, ex_pseudotime)

Switch-like model fitting and differential expression test

Description

Fit sigmoidal differential expression models to gene expression across pseudotime. Parameter estimates are returned along with a p-value for switch-like differential expression over a null model (constant expression).

Usage

switchde(object, pseudotime = NULL, zero_inflated = FALSE,
  lower_threshold = 0.01, maxiter = 1000, log_lik_tol = 0.01,
  verbose = FALSE, sce_assay = "exprs")

Arguments

object

Gene expression data that is either

  • A vector of length number of cells for a single gene

  • A matrix of dimension number of genes x number of cells

  • An object of class SingleCellExperiment from package SingleCellExperiment

pseudotime

A pseudotime vector with a pseudotime corresponding to every cell. Can be NULL if object is of class SCESet and colData(sce)$pseudotime is defined.

zero_inflated

Logical. Should zero inflation be implemented? Default FALSE

lower_threshold

The minimum threshold below which to set expression to zero to avoid numerical issues. Default is 0.01

maxiter

Maximum number of iterations for EM algorithm if zero inflation enabled. Default 100

log_lik_tol

If the change in the log-likelihood falls below this for zero inflated EM the algorithm is assumed to have converged

verbose

Print convergence update for EM algorithm

sce_assay

The assay from the SingleCellExperiment to be used as expression, defaulting to "exprs"

Value

A matrix where each column corresponds to a gene, the first row is the p-value for that gene and subsequent rows are model parameters.

Examples

data(synth_gex)
data(ex_pseudotime)
sde <- switchde(synth_gex, ex_pseudotime)

Plot gene behaviour

Description

Plot gene behaviour and MLE sigmoid as a function of pseudotime.

Usage

switchplot(x, pseudotime, pars)

Arguments

x

Gene expression vector

pseudotime

Pseudotime vector (of same length as x)

pars

Fitted model parameters

Details

This plots expression of a single gene. Fitted model parameters can either be specified manually or can be extracted from the data.frame returned by switchde using the function extract_pars.

Value

A ggplot2 plot of gene expression and MLE sigmoid

Examples

data(synth_gex)
data(ex_pseudotime)
sde <- switchde(synth_gex, ex_pseudotime)
switchplot(synth_gex[1, ], ex_pseudotime, extract_pars(sde, "Gene1"))

Synthetic gene expression matrix

Description

A matrix containing some synthetic gene expression data for 100 cells and 12 genes

Usage

synth_gex

Format

An object of class matrix with 12 rows and 100 columns.

Value

A 12 by 100 matrix