Description Usage Arguments Value Functions Total residual types Partial residuals See Also Examples
After each gene is fit, a hook function can optionally be run and the output saved.
This allows extended computations to be done using the fitted model, without keeping it in memory.
Here this is used to calculate various residuals, though in some cases they can be done using only the information contained in the ZlmFit
class.
1 2 3 4 5 6 7 8 9 10 11 12 13  collectResiduals(x, sca, newLayerName = "Residuals")
discrete_residuals_hook(x)
continuous_residuals_hook(x)
combined_residuals_hook(x)
deviance_residuals_hook(x)
fitted_phat(x)
partialScore(x, effectRegex)

x 

sca 

newLayerName 

effectRegex 
a regular expression naming columns of the design corresponding to Z_0. Generally these should be the treatment effects of interest. 
copy of sca
with new layer
discrete_residuals_hook
: Hook to get the discrete residuals, ie, difference between expected probability of expression and observed
continuous_residuals_hook
: Hook to get the continuous residuals, ie, residuals for conditionally positive observations. If an observation is zero, it's residual is defined to be zero as well.
combined_residuals_hook
: Hook to get the combined residuals, ie, YE(U)*E(V)
deviance_residuals_hook
: Standardized deviance residuals hook. Computes the sum of the standardized deviance residuals for the discrete and continuous models (scaled to have unit variance). If the observation is zero then only the discrete component is used.
fitted_phat
: Hook to return p_hat, the predicted probability of expression.
partialScore
: Compute Y_iE(V_iX_i, Z_0)E(UX_i, Z_0), where Z_0 is a treatment effect (being left in) and X_i is a nuisance effect (being regressed out).
Each component of the model contributes several flavors of residual, which can be combined in various fashions. The discrete residual can be on the response scale (thus subtracting the predicted probability of expression from the 0/1 expression value). Or it can be a deviance residual, revealing something about the loglikelihood.
It's also possible to consider partial residuals, in which the contribution of a particular covariate is added back into the model.
zlm
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15  data(vbetaFA)
svbeta < subset(vbetaFA, ncells==1)
svbeta < svbeta[freq(svbeta)>.4,]
window < function(x1) lapply(assays(x1), function(x2) x2[1:3, 1:6])
#total residuals of the response
z1 < zlm(~ Stim.Condition, svbeta, hook=discrete_residuals_hook)
window(collectResiduals(z1, svbeta))
z2 < zlm(~ Stim.Condition, svbeta, hook=continuous_residuals_hook)
window(collectResiduals(z2, svbeta))
z3 < zlm(~ Stim.Condition, svbeta, hook=combined_residuals_hook)
window(collectResiduals(z3, svbeta))
#partial residuals
colData(svbeta)$ngeneson < colMeans(assay(svbeta)>0)
z5 < zlm(~ Stim.Condition + ngeneson, svbeta)
partialScore(z5, 'Stim.Condition')

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