DE_timecourse: Run spline models and test for DE of contrasts.

Description Usage Arguments Details Value See Also Examples

Description

Run spline models and test for DE of contrasts.

Usage

1
2
3
4
5
6
7
8
## S4 method for signature 'Moanin'
DE_timecourse(
  object,
  contrasts,
  center = FALSE,
  statistic = c("ftest", "lrt"),
  use_voom_weights = TRUE
)

Arguments

object

An object of class Moanin, an object containing all related information for time course data and the splines model that will be used (if applicable). See create_moanin_model for more details.

contrasts

Contrasts, either provided as a vector of strings, or a matrix of contrasts coefficients obtained using makeContrasts from the package limma. If given as a character string, will be passed to makeContrasts to be converted into such a matrix.

center

boolean, whether to center the data matrix

statistic

Which test statistic to use, a likelihood ratio statistic or a F-test.

use_voom_weights

boolean, optional, default: TRUE. Whether to use voom weights. See details.

Details

The implementation of the spline fit and the calculation of p-values was based on code from edge, and expanded to enable handling of comparisons of groups via contrasts. The code assumes that the Moanin object was created via either a formula or a basis where a different spline was fit for each group_variable and thus the contrasts are comparisons of those spline fits. If the Moanin object was created via user-provided basis matrix or formula, then the user should take a great deal of caution in using this code, as the degrees of freedom for the tests of significance cannot be verified to be correct.

If use_voom_weights=TRUE, then before fitting splines to each gene, voom weights are calculated from assay(object):

1
2
3
4
   y <- edgeR::DGEList(counts=assay(object))
   y <- edgeR::calcNormFactors(y, method="upperquartile")
   v <- limma::voom(y, design, plot=FALSE)
   weights <- v$weights

The design matrix for the voom weights is based on the formula ~Group + Timepoint +0 where Group and Timepoint are replaced with the user-defined values where appropriate. These weights are given to the lm.fit which fits the spline coefficients. This workflow assumes that the input to the Moanin object were counts.

If the user set log_transform=TRUE in the creation of the Moanin object, the splines will be fit to the log of the input data, and not directly to the input data. This is independent of whether the user chooses use_voom_weights.

Value

A data.frame with two columns for each of the contrasts given in contrasts, corresponding to the raw p-value of the contrast for that gene (_pval) and the adjusted p-value (_qval). The adjusted p-values are FDR-adjusted based on the Benjamini-Hochberg method, as implemented in p.adjust. The adjustment is done across all p-values for all contrasts calculated.

See Also

makeContrasts, create_moanin_model, DE_timepoints, edge

Examples

1
2
3
4
5
data(exampleData)
moanin <- create_moanin_model(data=testData, meta=testMeta)
deTimecourse=DE_timecourse(moanin, 
   contrasts="K-C", use_voom_weights=FALSE)
head(deTimecourse)

NelleV/moanin documentation built on July 28, 2021, 7:34 p.m.