fitConstImpulseGene: Fit an impulse and constant model to a single gene

View source: R/srcImpulseDE2_fitImpulse.R

fitConstImpulseGeneR Documentation

Fit an impulse and constant model to a single gene

Description

[Model fitting function hierarchy: 3 out of 4] This tertiary fitting wrapper calls the optimisation wrappers for the individual fitting operations to be performed on the observations of this gene. Structure of this function:

  • Fit impulse model

    • Initialise impulse model parameters (peak and valley)

    • Fit impulse model (peak initialisation)

    • Fit impulse model (valley initialisation)

  • Select best impulse model fit from initialisations,

  • Fit constant model (if constant model is to be fit).

Usage

fitConstImpulseGene(vecCounts, scaDisp, vecSizeFactors,
  vecTimepointsUnique, vecidxTimepoint, lsvecidxBatch, boolFitConst,
  MAXIT = 1000)

Arguments

vecCounts

(numeric vector number of samples) Read count data.

scaDisp

(scalar) Gene-wise negative binomial dispersion hyper-parameter.

vecSizeFactors

(numeric vector number of samples) Model scaling factors for each sample which take sequencing depth into account (size factors).

vecTimepointsUnique

(numeric vector length number of unique timepoints) Vector of unique time coordinates observed in this condition.

vecidxTimepoint

(numeric vector length number of samples) Index of the time coordinates of each sample (reference is vecTimepointsUnique).

lsvecidxBatch

(idx list length number of confounding variables) List of vectors. One vector per confounding variable. Each vector has one entry per sample with the index of the batch ID within the given confounding variable of the given sample. Reference is the list of unique batch ids for each confounding variable.

boolFitConst

(bool) Whether to fit a constant model.

MAXIT

(scalar) [Default 1000] Maximum number of BFGS iterations for model fitting with optim.

Value

(list length 2) Impulse and constant model fit to gene observations.

  • lsImpulseFit (list) List of impulse fit parameters and results.

    • vecImpulseParam (numeric vector length 6) {beta, h0, h1, h2, t1, t2} Maximum likelihood estimators of impulse model parameters.

    • vecImpulseValue (numeric vector length number of time points) Values of impulse model fit at time points used for fit.

    • lsvecBatchFactors (list length number of confounders) List of vectors of scalar batch correction factors for each sample. These are also maximum likelihood estimators. NULL if no confounders given.

    • scaDispParam (scalar) Dispersion parameter estimate used in fitting (hyper-parameter).

    • scaLL (scalar) Loglikelihood of data under maximum likelihood estimator model.

    • scaConvergence (scalar) Convergence status of optim on impulse model.

  • lsConstFit (list) List of constant fit parameters and results.

    • scaMu (scalar) Maximum likelihood estimator of negative binomial mean parameter.

    • lsvecBatchFactors (list length number of confounders) List of vectors of scalar batch correction factors for each sample. These are also maximum likelihood estimators. NULL if no confounders given.

    • scaDispParam (scalar) Dispersion parameter estimate used in fitting (hyper-parameter).

    • scaLL (scalar) Loglikelihood of data under maximum likelihood estimator model.

    • scaConvergence (scalar) Convergence status of optim on constant model.

Author(s)

David Sebastian Fischer

See Also

Called by fitConstImpulseGene to fit constant and impulse model to samples of one condition and one gene. Calls impulse parameter initialisation function estimateImpulseParam and optimisation wrappers fitImpulseModel and fitConstModel.


YosefLab/ImpulseDE2 documentation built on Sept. 17, 2022, 2:45 a.m.