Description Usage Arguments Details Value Functions Caveats See Also Examples
Using the delta method, estimate the logfold change from a state given by a vector contrast0 and the state(s) given by contrast1.
1 2 3 
zlmfit 
ZlmFit output 
contrast0 
vector of coefficients giving baseline contrast, or a 
contrast1 
matrix of coefficients giving comparison contrasts, or a 
The logfold change is defined as follows. For each gene, let u(x) be the expected value of the continuous component, given a covariate x and the estimated coefficients coefC
, ie, u(x)= crossprod(x, coefC)
.
Likewise, Let v(x)= 1/(1+exp(crossprod(coefD, x)))
be the expected value of the discrete component.
The log fold change from contrast0 to contrast1 is defined as
u(contrast1)v(contrast1)u(contrast0)v(contrast0).
Note that for this to be a logfold change, then the regression for u must have been fit on the log scale. This is returned in the matrix logFC
.
An approximation of the variance of logFC
(applying the delta method to formula defined above) is provided in varLogFC
.
list of matrices 'logFC' and 'varLogFC', giving the logfoldchanges for each contrast (columns) and genes (rows) and the estimated sampling variance thereof
getLogFC
: Return results as a perhaps friendlier data.table
1. When method='bayesglm'
(the default), it's no longer necessarily true that the log fold change from condition A to B will be the inverse of the log fold change from B to A if the models are fit separately.
This is due to the shrinkage in bayesglm
.
2. The log fold change can be small, but the Hurdle pvalue small and significant when the sign of the discrete and continuous model components are discordant so that the marginal log fold change cancels out. The large sample sizes present in many single cell experiments also means that there is substantial power to detect even small changes.
3. When there is no expression in a gene for a coefficient that is nonzero in either condition0
or condition1
we return NA
because there is not any information
to estimate the continuous component. Technically we might return plus or minus infinity,
but there is not a straightforward way to estimate a confidence interval in any case.
See https://support.bioconductor.org/p/99244/ for details
Hypothesis
summary,ZlmFitmethod
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18  data(vbetaFA)
zz < zlm( ~ Stim.Condition+Population, vbetaFA[1:5,])
##logfold changes in terms of intercept (which is Stim(SEB) and CD154+VbetaResponsive)
lfcStim < logFC(zz)
##If we want to compare against unstim, we can try the following
coefnames < colnames(coef(zz, 'D'))
contrast0 < setNames(rep(0, length(coefnames)), coefnames)
contrast0[c('(Intercept)', 'Stim.ConditionUnstim')] < 1
contrast1 < diag(length(coefnames))
rownames(contrast1)<colnames(contrast1)<coefnames
contrast1['(Intercept)',]<1
lfcUnstim < logFC(zz, contrast0, contrast1)
##logfold change with itself is 0
stopifnot(all(lfcUnstim$logFC[,2]==0))
##inverse of logfold change with Stim as reference
stopifnot(all(lfcStim$logFC[,1]==(lfcUnstim$logFC[,1])))
##As a data.table:
getLogFC(zz)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.