Title: | Model-based Analysis of Single Cell Transcriptomics |
---|---|
Description: | Methods and models for handling zero-inflated single cell assay data. |
Authors: | Andrew McDavid [aut, cre], Greg Finak [aut], Masanao Yajima [aut] |
Maintainer: | Andrew McDavid <[email protected]> |
License: | GPL(>= 2) |
Version: | 1.33.0 |
Built: | 2024-11-18 03:45:36 UTC |
Source: | https://github.com/bioc/MAST |
Methods for analysing single cell assay data using hurdle models.
This packages provides data structures and functions for statistical analysis of single-cell assay data such as Fluidigm single cell gene expression assays.
Maintainer: Andrew McDavid [email protected]
Authors:
Greg Finak [email protected]
Masanao Yajima [email protected]
Finak, et al. MAST: a flexible statistical framework for assessing transcriptional changes and characterizing heterogeneity in single-cell RNA sequencing data. Genome Biology (2015).
Useful links:
When x is an array of order K, and y is an array of order K-1, whose dimensions otherwise agree, apply FUN by recycling y as necessary over dimension K of x.
applyFlat(x, y, FUN = "-")
applyFlat(x, y, FUN = "-")
x |
array, order K |
y |
array, order K-1 |
FUN |
vectorized binary operation |
array, order K equal to FUN(x,y)
##Dumb example, could be done with scale(...,scale=FALSE) x0 = matrix(1:10, nrow=2) y0 = rowMeans(x0) dim(y0) = c(1, 2) x1 = MAST:::applyFlat(x0,y0) stopifnot(rowMeans(x1)==0)
##Dumb example, could be done with scale(...,scale=FALSE) x0 = matrix(1:10, nrow=2) y0 = rowMeans(x0) dim(y0) = c(1, 2) x1 = MAST:::applyFlat(x0,y0) stopifnot(rowMeans(x1)==0)
Wrapper for bayesian GLM
prior
numeric
optional 3d array used to specify prior for coefficients
useContinuousBayes
logical
should bayesglm
be used to fit the continuous component as well?
The Z or T statistics may be reported by component (discrete/continuous) when combined='no'
or combined by Fisher's or Stouffer's method (combined='fisher'
or combined='stouffer'
.
Fisher's method uses the product of the p-values, while Stouffer's method uses the sum of the Z/T scores.
The "Z" score returned by Fisher is the normal quantile that would yield the observed Fisher P-value, whose sign is derived from the sign of the maximum component Z score.
The "Z" score returned by Stouffer when testType='normal'
is the sum of the Z scores, over sqrt(2).
When testType='t'
it is a weighted combination of the Z scores, with weights correponding to the degrees of freedom in each of the t statistics.
A t-approximation to this sum of t-variables is derived by matching moments. It seems to be fairly accurate in practice.
calcZ(gseaObj, testType = "t", combined = "none")
calcZ(gseaObj, testType = "t", combined = "none")
gseaObj |
output from |
testType |
either 'normal' or 't'. The 't' test adjusts for excess kurtosis due to the finite number of bootstrap replicates used to estimate the variance of the statistics. This will result in more conservative inference. |
combined |
|
3D array with dimensions set (modules) comp ('cont'inuous or 'disc'rete) and metric ('Z' stat and two sided 'P' value that P(z>|Z|)) if combined='no'
, otherwise just a matrix.
gseaAfterBoot
## See the examples in gseaAfterBoot example(gseaAfterBoot)
## See the examples in gseaAfterBoot example(gseaAfterBoot)
colData
Replace colData
with a DataFrame
.
Checks to make sure that row.names(value)
match colnames{x}
, in contrast to the parent method
Checks for a wellKey column, as well.
## S4 replacement method for signature 'SingleCellAssay,DataFrame' colData(x) <- value
## S4 replacement method for signature 'SingleCellAssay,DataFrame' colData(x) <- value
x |
|
value |
|
modified SingleCellAssay
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.
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)
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 |
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, Y-E(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 , where
is a treatment effect (being left in) and
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 log-likelihood.
It's also possible to consider partial residuals, in which the contribution of a particular covariate is added back into the model.
zlm
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')
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')
Computes the Et value from the Ct value in an existing data frame and returns a new data frame with the Et column appended
computeEtFromCt(df, column = "Ct", Cmax = 40)
computeEtFromCt(df, column = "Ct", Cmax = 40)
df |
a |
column |
The name of the |
Cmax |
the maximum number of cycles performed. 40 by default. |
A copy of df
with the 'Et' column appended
Greg Finak
data(vbeta) vbeta <- computeEtFromCt(vbeta)
data(vbeta) vbeta <- computeEtFromCt(vbeta)
Convert a SingleCellAssay object created with the MASTClassic package to an object recognized by the new MAST package
convertMASTClassicToSingleCellAssay(object = NULL)
convertMASTClassicToSingleCellAssay(object = NULL)
object |
of class |
The function will extract the relevant information from the attributes of the old object and construct a new SingleCellAssay that is recognized by MAST. This function checks that the object is a MASTClassic SingleCellAssay object. It will stop if it is not a SingleCellAssay, return a converted SingleCellAssay if object was created by MASTClassic, and return the original object if the object is already compatible.
A MAST SingleCellAssay object.
Type checking for old object is not performed.
data(vbetaFA) convertMASTClassicToSingleCellAssay(vbetaFA)
data(vbetaFA) convertMASTClassicToSingleCellAssay(vbetaFA)
Computes the genewise covariance for a model coefficient from bootstrap replicates from 'MAST::bootVcov1()'. If coefficients are unestimable (i.e. NA) for a gene, that row/column in the covariance matrix will be NA. Returns a list with components "C" and "D" containing the covariance matrices for the "C"ontinuous and "D"iscrete components of the MAST model.
CovFromBoots(boots = NULL, coefficient = NULL)
CovFromBoots(boots = NULL, coefficient = NULL)
boots |
a multidimensional array returned by 'bootVcov1' or 'pbootVcov1'. |
coefficient |
'character' the name of the model coefficient for which to return the inter-gene covariance matrices. |
list with components "C" and "D" containing covariance matrices for the continuous and discrete components of the model.
Initialize a prior to be used a prior for BayeGLMlike/BayesGLMlike2
defaultPrior(names)
defaultPrior(names)
names |
character vector of coefficients. The '(Intercept)' will be ignored. |
3d array, with leading dimension giving the prior 'loc'ation, 'scale' and degrees of freedom (df), second dimension giving the component ('C'ontinuous or 'D'iscrete) and trailing dimension giving the coefficient to which the prior applies. The location is initialized to be 0, the scale to 2, and degrees of freedom of 1, following the default of bayesglm.
dp <- defaultPrior('Stim.ConditionUnstim') ## Not run: data(vbetaFA) zlmVbeta <- zlm(~ Stim.Condition, vbetaFA, method='bayesglm', coefPrior=dp) ## End(Not run)
dp <- defaultPrior('Stim.ConditionUnstim') ## Not run: data(vbetaFA) zlmVbeta <- zlm(~ Stim.Condition, vbetaFA, method='bayesglm', coefPrior=dp) ## End(Not run)
Degrees of freedom of Zero inflated model
dof(object)
dof(object)
object |
LMlike or subclass |
vector giving the model degrees of freedom for continuous and discrete
Like drop(x) but only dropping specified dimensions. There is no testing that the specified dimensions are actually singletons.
Drop(x, d)
Drop(x, d)
x |
array of at least d dimensions |
d |
dimension(s) to drop |
array x
x = array(1:4, dim=c(1, 2, 1, 2)) dx = MAST:::Drop(x, 1) stopifnot(all(dim(dx)==c(2,1,2)))
x = array(1:4, dim=c(1, 2, 1, 2)) dx = MAST:::Drop(x, 1) stopifnot(all(dim(dx)==c(2,1,2)))
ebayesControl
is a named list with (optional) components 'method' (one of 'MOM' or 'MLE') and 'model' (one of 'H0' or 'H1')
method MOM uses a method-of-moments estimator, while MLE using the marginal likelihood.
H0 model estimates the precisions using the intercept alone in each gene, while H1 fits the full model specified by mm
ebayes(assay_t, ebayesControl, mm, truncate = Inf)
ebayes(assay_t, ebayesControl, mm, truncate = Inf)
assay_t |
cells X genes matrix |
ebayesControl |
list with (optional) components 'method', 'model'. See details. |
mm |
a model matrix, used when |
truncate |
Genes with sample precisions exceeding this value are discarded when estimating the hyper parameters |
numeric
of length two, giving the hyperparameters in terms of a variance (v
) and prior observations (df
), inside a structure
, with component hess
, giving the Fisher Information of the hyperparameters.
Puts log transformed values onto natural scale and takes mean of vector. Calculates mean(2^x - 1)
expavg(x)
expavg(x)
x |
|
numeric
x <- 1:10 logmean(expavg(x))
x <- 1:10 logmean(expavg(x))
Filter out genes that have less than some percent threshold expression across all libraries
filterLowExpressedGenes(assay, threshold = 0.1)
filterLowExpressedGenes(assay, threshold = 0.1)
assay |
a |
threshold |
a |
SingleCellAssay
data(vbetaFA) filterLowExpressedGenes(vbetaFA)
data(vbetaFA) filterLowExpressedGenes(vbetaFA)
Given a design and formula, fit the zero inflated regression, storing the fits in slots
fitC
and fitD
fit(object, response, ...) ## S4 method for signature 'LMERlike,missing' fit(object, response, silent = TRUE, ...)
fit(object, response, ...) ## S4 method for signature 'LMERlike,missing' fit(object, response, silent = TRUE, ...)
object |
inheriting from |
response |
a vector, same length as the design, or if missing then use the current response |
... |
currently ignored |
silent |
mute some warnings emitted from the underlying modeling functions |
LMlike or subclass
freq
returns the frequency of expression, i.e., the proportion of non-zero values in sc
.
NAs can be optionally removed
freq(sc, na.rm = TRUE) condmean(sc) condSd(sc) numexp(sc)
freq(sc, na.rm = TRUE) condmean(sc) condSd(sc) numexp(sc)
sc |
SingleCellAssay |
na.rm |
should NAs be removed, or carried through? |
vector of proportions
condmean()
: Report the mean non-zero expression value for each gene. NAs are always removed.
condSd()
: Report standard deviation of expression, for positive et for each gene. NAs are always removed.
numexp()
: Report number of expressing cells ($>0$) per gene. NAs are removed.
data(vbetaFA) freq(vbetaFA) condmean(vbetaFA)
data(vbetaFA) freq(vbetaFA) condmean(vbetaFA)
SingleCellAssay are a generic container for such data and are simple wrappers around SummarizedExperiment objects. Subclasses exist that embue the container with additional attributes, eg FluidigmAssay.
FromFlatDF( dataframe, idvars, primerid, measurement, id = numeric(0), cellvars = NULL, featurevars = NULL, phenovars = NULL, class = "SingleCellAssay", check_sanity = TRUE, ... )
FromFlatDF( dataframe, idvars, primerid, measurement, id = numeric(0), cellvars = NULL, featurevars = NULL, phenovars = NULL, class = "SingleCellAssay", check_sanity = TRUE, ... )
dataframe |
A 'flattened' |
idvars |
character vector naming columns that uniquely identify a cell |
primerid |
character vector of length 1 that names the column that identifies what feature (i.e. gene) was measured |
measurement |
character vector of length 1 that names the column containing the measurement |
id |
An identifier (eg, experiment name) for the resulting object |
cellvars |
Character vector naming columns containing additional cellular metadata |
featurevars |
Character vector naming columns containing additional feature metadata |
phenovars |
Character vector naming columns containing additional phenotype metadata |
class |
desired subclass of object. Default |
check_sanity |
(default: |
... |
additional arguments are ignored |
SingleCellAssay, or derived, object
data(vbeta) colnames(vbeta) vbeta <- computeEtFromCt(vbeta) vbeta.fa <- FromFlatDF(vbeta, idvars=c("Subject.ID", "Chip.Number", "Well"), primerid='Gene', measurement='Et', ncells='Number.of.Cells', geneid="Gene",cellvars=c('Number.of.Cells', 'Population'), phenovars=c('Stim.Condition','Time'), id='vbeta all', class='FluidigmAssay') show(vbeta.fa) nrow(vbeta.fa) ncol(vbeta.fa) head(mcols(vbeta.fa)$primerid) table(colData(vbeta.fa)$Subject.ID) vbeta.sub <- subset(vbeta.fa, Subject.ID=='Sub01') show(vbeta.sub)
data(vbeta) colnames(vbeta) vbeta <- computeEtFromCt(vbeta) vbeta.fa <- FromFlatDF(vbeta, idvars=c("Subject.ID", "Chip.Number", "Well"), primerid='Gene', measurement='Et', ncells='Number.of.Cells', geneid="Gene",cellvars=c('Number.of.Cells', 'Population'), phenovars=c('Stim.Condition','Time'), id='vbeta all', class='FluidigmAssay') show(vbeta.fa) nrow(vbeta.fa) ncol(vbeta.fa) head(mcols(vbeta.fa)$primerid) table(colData(vbeta.fa)$Subject.ID) vbeta.sub <- subset(vbeta.fa, Subject.ID=='Sub01') show(vbeta.sub)
If the gene expression measurements are already in a rectangular form, then this function allows an easy way to construct a SingleCellAssay object while still doing some sanity checking of inputs.
FromMatrix( exprsArray, cData, fData, class = "SingleCellAssay", check_sanity = TRUE, check_logged = check_sanity )
FromMatrix( exprsArray, cData, fData, class = "SingleCellAssay", check_sanity = TRUE, check_logged = check_sanity )
exprsArray |
matrix, or a list of matrices, or an array. Columns are cells, rows are genes. |
cData |
cellData an object that can be coerced to a DataFrame, ie, data.frame, AnnotatedDataFrame. Must have as many rows as |
fData |
featureData an object that can be coerced to a DataFrame, ie, data.frame, AnnotatedDataFrame. Must have as many rows as |
class |
desired subclass of object. Default |
check_sanity |
(default: |
check_logged |
alias for |
an object of class class
defaultAssay
ncells <- 10 ngenes <- 5 fData <- data.frame(primerid=LETTERS[1:ngenes]) cData <- data.frame(wellKey=seq_len(ncells)) mat <- matrix(rnorm(ncells*ngenes), nrow=ngenes) sca <- FromMatrix(mat, cData, fData) stopifnot(inherits(sca, 'SingleCellAssay')) stopifnot(inherits(sca, 'SummarizedExperiment')) ##If there are mandatory keywords expected by a class, you'll have to manually set them yourself cData$ncells <- 1 fd <- FromMatrix(mat, cData, fData) stopifnot(inherits(fd, 'SingleCellAssay'))
ncells <- 10 ngenes <- 5 fData <- data.frame(primerid=LETTERS[1:ngenes]) cData <- data.frame(wellKey=seq_len(ncells)) mat <- matrix(rnorm(ncells*ngenes), nrow=ngenes) sca <- FromMatrix(mat, cData, fData) stopifnot(inherits(sca, 'SingleCellAssay')) stopifnot(inherits(sca, 'SummarizedExperiment')) ##If there are mandatory keywords expected by a class, you'll have to manually set them yourself cData$ncells <- 1 fd <- FromMatrix(mat, cData, fData) stopifnot(inherits(fd, 'SingleCellAssay'))
Return the concordance between two assays (i.e. single cell and hundred cell).
The "average" of singleCellRef
(after adjusting for the number of cells) and
singleCellComp
are taken per gene, per groups
.
A data.frame
with one row per gene-groups
is returned with some additional columns.
getConcordance( singleCellRef, singleCellcomp, groups = NULL, fun.natural = expavg, fun.cycle = logmean ) getwss(concord, nexp) getss(concord) getrc(concord)
getConcordance( singleCellRef, singleCellcomp, groups = NULL, fun.natural = expavg, fun.cycle = logmean ) getwss(concord, nexp) getss(concord) getrc(concord)
singleCellRef |
"reference" SingleCellAssay |
singleCellcomp |
"comparison" SingleCellAssay |
groups |
character vector giving variable(s) on which the comparison is conditioned |
fun.natural |
function to transform the SingleCellAssays to a mRNA proportional level |
fun.cycle |
inverse function of fun.natural |
concord |
data.frame returned by getConcordance |
nexp |
number of expressed cells per row in |
concordance between two assays
getwss()
: getrc the sum of squares, weighted by nexp
getss()
: return the sum of squares
getrc()
: Return Lin's (1989) concordance correlation coefficient
Andrew McDavid
data(vbetaFA) sca1 <- subset(vbetaFA, ncells==1) sca100 <- subset(vbetaFA, ncells==100) concord <- getConcordance(sca1, sca100) getss(concord) getrc(concord)
data(vbetaFA) sca1 <- subset(vbetaFA, ncells==1) sca100 <- subset(vbetaFA, ncells==100) concord <- getConcordance(sca1, sca100) getss(concord) getrc(concord)
This returns the wellKey, which is a unique identifier generated by idvars
in the mapping
getwellKey(sc)
getwellKey(sc)
sc |
An object with a |
integer
giving the unique id generated
data(vbetaFA) getwellKey(vbetaFA) colData(vbetaFA)$wellKey
data(vbetaFA) getwellKey(vbetaFA) colData(vbetaFA)$wellKey
Wrapper for regular glm/lm
## S4 method for signature 'GLMlike' vcov(object, which, ...)
## S4 method for signature 'GLMlike' vcov(object, which, ...)
object |
|
which |
|
... |
ignored |
covariance matrix
vcov(GLMlike)
: return the variance/covariance of component which
weightFun
function to map expression values to probabilities of expression. Currently unused.
Modules defined in sets
are tested for average differences in expression from the "average" gene.
By using bootstraps, the between-gene covariance of terms in the hurdle model is found, and is used to adjust for coexpression between genes.
We drop genes if the coefficient we are testing was not estimible in original model fit in zFit
or in any of the bootstrap replicates (evidenced an NA
in the bootstrap array). This might yield overly conservative inference.
Since bootstrapping is a randomized procedure, the degrees of freedom of a module (and its variance parameters) might differ from run-to-run.
You might try setting var_estimate='modelbased'
to relax this requirement by assuming independence between genes and then using the asymptotic covariance estimates, which are deterministic, but may result in overly-generous inference.
gseaAfterBoot( zFit, boots, sets, hypothesis, control = gsea_control(n_randomize = Inf, var_estimate = "bootall") ) gsea_control(n_randomize = Inf, var_estimate = "bootall")
gseaAfterBoot( zFit, boots, sets, hypothesis, control = gsea_control(n_randomize = Inf, var_estimate = "bootall") ) gsea_control(n_randomize = Inf, var_estimate = "bootall")
zFit |
object of class ZlmFit |
boots |
bootstraps of zFit |
sets |
list of indices of genes |
hypothesis |
a |
control |
parameters as provided by |
n_randomize |
the number of genes to sample to approximate the non-module average expression. Set to |
var_estimate |
the method used to estimate the variance of the modules, one of |
Object of class GSEATests
, containing slots tests
, 4D array and bootR
, the number of boostrap replicates.
gsea_control()
: set control parameters. See Details.
control
control
is a list with elements:
n_randomize
, giving the number of genes to sample to approximate the non-module average expression. Set to Inf
to turn off the approximation (the default).
var_estimate
, giving the method used to estimate the variance of the modules. bootall
uses the bootstrapped covariance matrices. bootdiag
uses only the diagonal of the bootstrapped covariance matrix (so assuming independence across genes). modelbased
assumes independence across genes and uses the variance estimated from the model.
A 4D array is returned, with dimensions "set" (each module), "comp" ('disc'rete or 'cont'inuous), "metric" ('stat' gives the average of the coefficient, 'var' gives the variance of that average, 'dof' gives the number of genes that were actually tested in the set), "group" ('test' for the genes in test-set, "null" for all genes outside the test-set).
summary,GSEATests-method
data(vbetaFA) vb1 = subset(vbetaFA, ncells==1) vb1 = vb1[,freq(vb1)>.1][1:15,] zf = zlm(~Stim.Condition, vb1) boots = bootVcov1(zf, 5) sets = list(A=1:5, B=3:10, C=15, D=1:5) gsea = gseaAfterBoot(zf, boots, sets, CoefficientHypothesis('Stim.ConditionUnstim')) ## Use a model-based estimate of the variance/covariance. gsea_mb = gseaAfterBoot(zf, boots, sets, CoefficientHypothesis('Stim.ConditionUnstim'), control = gsea_control(var_estimate = 'modelbased')) calcZ(gsea) summary(gsea)
data(vbetaFA) vb1 = subset(vbetaFA, ncells==1) vb1 = vb1[,freq(vb1)>.1][1:15,] zf = zlm(~Stim.Condition, vb1) boots = bootVcov1(zf, 5) sets = list(A=1:5, B=3:10, C=15, D=1:5) gsea = gseaAfterBoot(zf, boots, sets, CoefficientHypothesis('Stim.ConditionUnstim')) ## Use a model-based estimate of the variance/covariance. gsea_mb = gseaAfterBoot(zf, boots, sets, CoefficientHypothesis('Stim.ConditionUnstim'), control = gsea_control(var_estimate = 'modelbased')) calcZ(gsea) summary(gsea)
This holds output from a call to gseaAfterBoot. It primarily provides a summary method.
tests
array: gene sets X discrete,continuous X stat, variance, degrees of freedom, avg correlation X test, null
bootR
number of bootstrap replicates
gseaAfterBoot
calcZ
summary,GSEATests-method
Selectively muffle warnings based on output
hushWarning(expr, regexp)
hushWarning(expr, regexp)
expr |
an expression |
regexp |
a regexp to be matched (with str_detect) |
the result of expr
hushWarning(warning('Beware the rabbit'), 'rabbit') hushWarning(warning('Beware the rabbit'), 'hedgehog')
hushWarning(warning('Beware the rabbit'), 'rabbit') hushWarning(warning('Beware the rabbit'), 'hedgehog')
A Hypothesis
can be any linear combination of coefficients, compared to zero. Specify it as a character vector that can be parsed to yield the desired equalities ala makeContrasts
.
A CoefficientHypothesis
is a hypothesis for which terms are singly or jointly tested to be zero (generally the case in a t-test or F-test), by dropping coefficients from the model.
Hypothesis(hypothesis, terms)
Hypothesis(hypothesis, terms)
hypothesis |
a character vector specifying a hypothesis, following makeContrasts, or a character vector naming coefficients to be dropped. |
terms |
an optional character vector giving the terms (column names from the |
a Hypothesis with a "transformed" component
zlm waldTest lrTest
h <- Hypothesis('Stim.ConditionUnstim', c('(Intercept)', 'Stim.ConditionUnstim')) h@contrastMatrix
h <- Hypothesis('Stim.ConditionUnstim', c('(Intercept)', 'Stim.ConditionUnstim')) h@contrastMatrix
If there are no positive observations for a contrast, it is generally not estimible. However, for the purposes of testing we can replace it with the least favorable value with respect to the contrasts that are defined.
impute(object, groupby)
impute(object, groupby)
object |
Output of predict |
groupby |
Variables (column names in predict) to group by for imputation (facets of the plot) |
data.table
##See stat_ell example(stat_ell)
##See stat_ell example(stat_ell)
The influence function
## S3 method for class 'bayesglm' influence(model, do.coef = TRUE, ...)
## S3 method for class 'bayesglm' influence(model, do.coef = TRUE, ...)
model |
|
do.coef |
see influence.glm |
... |
ignored |
see influence.glm
Inverse of logistic transformation
invlogit(x)
invlogit(x)
x |
numeric |
numeric
x <- 1:5 invlogit(log(x/(1-x)))
x <- 1:5 invlogit(log(x/(1-x)))
A horrendous hack is employed in order to do arbitrary likelihood ratio tests: the model matrix is built, the names possibly mangled, then fed in as a symbolic formula to glmer/lmer. This is necessary because there is no (easy) way to specify an arbitrary fixed-effect model matrix in glmer.
## S4 method for signature 'LMERlike' update(object, formula., design, keepDefaultCoef = FALSE, ...) ## S4 method for signature 'LMERlike' vcov(object, which, ...) ## S4 method for signature 'LMERlike' coef(object, which, singular = TRUE, ...) ## S4 method for signature 'LMERlike' logLik(object)
## S4 method for signature 'LMERlike' update(object, formula., design, keepDefaultCoef = FALSE, ...) ## S4 method for signature 'LMERlike' vcov(object, which, ...) ## S4 method for signature 'LMERlike' coef(object, which, singular = TRUE, ...) ## S4 method for signature 'LMERlike' logLik(object)
object |
|
formula. |
|
design |
something coercible to a |
keepDefaultCoef |
|
... |
In the case of |
which |
|
singular |
|
see the section "Methods (by generic)"
update(LMERlike)
: update the formula or design matrix
vcov(LMERlike)
: return the variance/covariance of component which
coef(LMERlike)
: return the coefficients. The horrendous hack is attempted to be undone.
logLik(LMERlike)
: return the log-likelihood
pseudoMM
part of this horrendous hack.
strictConvergence
logical
(default: TRUE
) return results even when the optimizer or *lmer complains about convergence
optimMsg
character
record warnings from lme. NA_character_
means no warnings.
Wrapper around modeling function to make them behave enough alike that Wald tests and Likelihood ratio are easy to do.
To implement a new type of zero-inflated model, extend this class.
Depending on how different the method is, you will definitely need to override the fit
method, and possibly the model.matrix
, model.matrix<-
, update
, coef
, vcov
, and logLik
methods.
## S4 method for signature 'LMlike' summary(object) ## S4 method for signature 'LMlike' update(object, formula., design, keepDefaultCoef = FALSE, ...) ## S4 method for signature 'LMlike,CoefficientHypothesis' waldTest(object, hypothesis) ## S4 method for signature 'LMlike,matrix' waldTest(object, hypothesis) ## S4 method for signature 'LMlike,character' lrTest(object, hypothesis) ## S4 method for signature 'LMlike,CoefficientHypothesis' lrTest(object, hypothesis) ## S4 method for signature 'LMlike,Hypothesis' lrTest(object, hypothesis) ## S4 method for signature 'LMlike,matrix' lrTest(object, hypothesis) ## S4 method for signature 'GLMlike' logLik(object)
## S4 method for signature 'LMlike' summary(object) ## S4 method for signature 'LMlike' update(object, formula., design, keepDefaultCoef = FALSE, ...) ## S4 method for signature 'LMlike,CoefficientHypothesis' waldTest(object, hypothesis) ## S4 method for signature 'LMlike,matrix' waldTest(object, hypothesis) ## S4 method for signature 'LMlike,character' lrTest(object, hypothesis) ## S4 method for signature 'LMlike,CoefficientHypothesis' lrTest(object, hypothesis) ## S4 method for signature 'LMlike,Hypothesis' lrTest(object, hypothesis) ## S4 method for signature 'LMlike,matrix' lrTest(object, hypothesis) ## S4 method for signature 'GLMlike' logLik(object)
object |
|
formula. |
|
design |
something coercible to a |
keepDefaultCoef |
|
... |
passed to |
hypothesis |
one of a |
see section "Methods (by generic)"
summary(LMlike)
: Print a summary of the coefficients in each component.
update(LMlike)
: update the formula or design from which the model.matrix
is constructed
waldTest(object = LMlike, hypothesis = CoefficientHypothesis)
: Wald test dropping single term specified by CoefficientHypothesis
hypothesis
waldTest(object = LMlike, hypothesis = matrix)
: Wald test of contrast specified by contrast matrix hypothesis
lrTest(object = LMlike, hypothesis = character)
: Likelihood ratio test dropping entire term specified by character
hypothesis
naming a term in the symbolic formula.
lrTest(object = LMlike, hypothesis = CoefficientHypothesis)
: Likelihood ratio test dropping single term specified by CoefficientHypothesis
hypothesis
lrTest(object = LMlike, hypothesis = Hypothesis)
: Likelihood ratio test dropping single term specified by Hypothesis
hypothesis
lrTest(object = LMlike, hypothesis = matrix)
: Likelihood ratio test dropping single term specified by contrast matrix hypothesis
logLik(GLMlike)
: return the log-likelihood of a fitted model
a data.frame from which variables are taken for the right hand side of the regression
The continuous fit
The discrete fit
The left hand side of the regression
A logical
with components "C" and "D", TRUE if the respective component has converged
A formula
for the regression
Both list
s giving arguments that will be passed to the fitter (such as convergence criteria or case weights)
coef
lrTest
waldTest
vcov
logLik
Using the delta method, estimate the log-fold change from a state given by a vector contrast0 and the state(s) given by contrast1.
logFC(zlmfit, contrast0, contrast1) getLogFC(zlmfit, contrast0, contrast1)
logFC(zlmfit, contrast0, contrast1) getLogFC(zlmfit, contrast0, contrast1)
zlmfit |
ZlmFit output |
contrast0 |
vector of coefficients giving baseline contrast, or a |
contrast1 |
matrix of coefficients giving comparison contrasts, or a |
The log-fold change is defined as follows. For each gene, let be the expected value of the continuous component, given a covariate x and the estimated coefficients
coefC
, ie,
crossprod(x, coefC)
.
Likewise, Let
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
Note that for this to be a log-fold 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 log-fold-changes 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 p-value 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 non-zero 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
data(vbetaFA) zz <- zlm( ~ Stim.Condition+Population, vbetaFA[1:5,]) ##log-fold 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) ##log-fold change with itself is 0 stopifnot(all(lfcUnstim$logFC[,2]==0)) ##inverse of log-fold change with Stim as reference stopifnot(all(lfcStim$logFC[,1]==(-lfcUnstim$logFC[,1]))) ##As a data.table: getLogFC(zz)
data(vbetaFA) zz <- zlm( ~ Stim.Condition+Population, vbetaFA[1:5,]) ##log-fold 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) ##log-fold change with itself is 0 stopifnot(all(lfcUnstim$logFC[,2]==0)) ##inverse of log-fold change with Stim as reference stopifnot(all(lfcStim$logFC[,1]==(-lfcUnstim$logFC[,1]))) ##As a data.table: getLogFC(zz)
Tests for a change in ET binomial proportion or mean of positive ET Likelihood Ratio Test for SingleCellAssay objects
LRT(sca, comparison, ...) ## S4 method for signature 'SingleCellAssay,character' LRT(sca, comparison, referent = NULL, groups = NULL, returnall = FALSE)
LRT(sca, comparison, ...) ## S4 method for signature 'SingleCellAssay,character' LRT(sca, comparison, referent = NULL, groups = NULL, returnall = FALSE)
sca |
A |
comparison |
A |
... |
ignored |
referent |
A |
groups |
A optional |
returnall |
A |
Combined Likelihood ratio test (binomial and normal) for SingleCellAssay and derived objects. This function is deprecated, please use lrTest instead.
data.frame
zlm ZlmFit
data(vbetaFA) LRT(vbetaFA, 'Stim.Condition', 'Unstim')
data(vbetaFA) LRT(vbetaFA, 'Stim.Condition', 'Unstim')
Compares the change in likelihood between the current model and one subject to contrasts tested in hypothesis
.
hypothesis
can be one of a character
giving complete factors or terms to be dropped from the model, CoefficientHypothesis
giving names of coefficients to be dropped, Hypothesis
giving contrasts using the symbolically, or a contrast matrix
, with one row for each coefficient in the full model, and one column for each contrast being tested.
lrTest(object, hypothesis, ...)
lrTest(object, hypothesis, ...)
object |
LMlike or subclass |
hypothesis |
the hypothesis to be tested. See details. |
... |
optional arguments, passed to fitting functions |
array giving test statistics
fit
waldTest
Hypothesis
CoefficientHypothesis
#see ZlmFit-class for examples example('ZlmFit-class')
#see ZlmFit-class for examples example('ZlmFit-class')
A 3D array with first dimension being the genes, next dimension giving information about the test (the degrees of freedom, Chisq statistic, and P value), and final dimension being the value of these quantities on the discrete, continuous and hurdle (combined) levels.
## S4 method for signature 'ZlmFit,character' lrTest(object, hypothesis, ...)
## S4 method for signature 'ZlmFit,character' lrTest(object, hypothesis, ...)
object |
ZlmFit |
hypothesis |
See Details |
... |
Arguments passed on to
|
3D array
assay
returnedMethods in this package operate on log-transformed (multiplicative scale) expression.
We attempt to check for this at construction, and then over-ride the assay
method to return the "layer" containing such log-transformed data.
magic_assay_names() assay_idx(x) ## S4 method for signature 'SingleCellAssay,missing' assay(x, i, withDimnames = TRUE, ...)
magic_assay_names() assay_idx(x) ## S4 method for signature 'SingleCellAssay,missing' assay(x, i, withDimnames = TRUE, ...)
x |
|
i |
must be |
withDimnames |
A Setting Note that assays(x, withDimnames=FALSE) <- assays(x, withDimnames=FALSE) is guaranteed to always work and be a no-op. This is not the case
if |
... |
passed to parent method |
By default we return the assay whose names, as given by assayNames(x)
, matches the first element in the vector c('thresh', 'et', 'Et', 'lCount', 'logTPM', 'logCounts', 'logcounts')
.
magic_assay_names()
: list of names assumed to represent log-transformed data, in order of usage preference
assay_idx()
: what index is returned by default by 'assay'
data(vbetaFA) assay(vbetaFA)[1:3,1:3] assay(vbetaFA, 'thresh', withDimnames = FALSE) = assay(vbetaFA)*0 - 9 assay(vbetaFA)[1:3, 1:3]
data(vbetaFA) assay(vbetaFA)[1:3,1:3] assay(vbetaFA, 'thresh', withDimnames = FALSE) = assay(vbetaFA)*0 - 9 assay(vbetaFA)[1:3, 1:3]
MAITs data set, RNASeq
a list
containing an expression matrix (expressionmat
), cell cdat
and feature fdat
.
Remove, or flag wells that are outliers in discrete or continuous space.
mast_filter(sc, groups = NULL, filt_control = NULL, apply_filter = TRUE) burdenOfFiltering(sc, groups, byGroup = FALSE, filt_control = NULL)
mast_filter(sc, groups = NULL, filt_control = NULL, apply_filter = TRUE) burdenOfFiltering(sc, groups, byGroup = FALSE, filt_control = NULL)
sc |
The |
groups |
An optional |
filt_control |
The |
apply_filter |
|
byGroup |
in the case of |
The function filters wells that don't pass filtering criteria described in filt_control.
filt_control is a list with named elements nOutlier
(minimum nmber of outlier cells for a cell to be filtered [default = 2]
sigmaContinuous
(the z-score outlier threshold for the continuous part of the signal) [default = 7]
and sigmaProportion
(the z-score outlier threshold for the discrete part of the signal) [default = 7].
If groups
is provided, the filtering is calculated within each level of the group, then combined again as output.
A filtered result
burdenOfFiltering()
: plot the proportions of wells are filtered due to different criteria
Andrew McDavid
burdenOfFiltering
data(vbetaFA) ## Split by 'ncells', apply to each component, then recombine vbeta.filtered <- mast_filter(vbetaFA, groups='ncells') ## Returned as boolean matrix was.filtered <- mast_filter(vbetaFA, apply_filter=FALSE) ## Wells filtered for being discrete outliers head(subset(was.filtered, pctout)) burdenOfFiltering(vbetaFA, groups='ncells', byGroup=TRUE) burdenOfFiltering(vbetaFA, groups='ncells')
data(vbetaFA) ## Split by 'ncells', apply to each component, then recombine vbeta.filtered <- mast_filter(vbetaFA, groups='ncells') ## Returned as boolean matrix was.filtered <- mast_filter(vbetaFA, apply_filter=FALSE) ## Wells filtered for being discrete outliers head(subset(was.filtered, pctout)) burdenOfFiltering(vbetaFA, groups='ncells', byGroup=TRUE) burdenOfFiltering(vbetaFA, groups='ncells')
These functions are defunct or have been renamed.
mast_filter
cData
fData
exprs
zlm.SingleCellAssay
combine
deviance_residuals_hook
No replacement available, underlying API changed
Combine lists, preferentially taking elements from x if there are duplicate names
meld_list_left(x, y)
meld_list_left(x, y)
x |
list |
y |
list |
MAST:::meld_list_left(list(A=1, B=2), list(A = 0))
MAST:::meld_list_left(list(A=1, B=2), list(A = 0))
SingleCellAssay
matrixReturn a molten (flat) representation, taking the
cross-product of the expression values, the colData
(column meta data),
and the feature data (mcols
).
## S3 method for class 'SingleCellAssay' melt(data, ..., na.rm = FALSE, value.name = "value")
## S3 method for class 'SingleCellAssay' melt(data, ..., na.rm = FALSE, value.name = "value")
data |
|
... |
ignored |
na.rm |
ignored |
value.name |
name of 'values' column in returned value |
A data.table
, with the cartesian product of the
row and column attributes and the expression values
data(vbetaFA) melt.SingleCellAssay(vbetaFA[1:10,]) as(vbetaFA[1:10,], 'data.table')
data(vbetaFA) melt.SingleCellAssay(vbetaFA[1:10,]) as(vbetaFA[1:10,], 'data.table')
Model matrix accessor
model.matrix(object, ...) ## S4 method for signature 'LMlike' model.matrix(object, ...)
model.matrix(object, ...) ## S4 method for signature 'LMlike' model.matrix(object, ...)
object |
LMlike or subclass |
... |
ignored |
model.matrix if present
model.matrix(LMlike)
: return the model.matrix
Replace model matrix
model.matrix(object) <- value
model.matrix(object) <- value
object |
LMlike or subclass |
value |
matrix |
modify object
Creates a custom BiPlot for visualizing the results of PCA
myBiplot(pc, colorfactor, scaling = 100, nudge = 1.2, N = 10, dims = 1:2, ...)
myBiplot(pc, colorfactor, scaling = 100, nudge = 1.2, N = 10, dims = 1:2, ...)
pc |
output of |
colorfactor |
a |
scaling |
|
nudge |
|
N |
number of variables with longest |
dims |
|
... |
passed to plot |
printed plot
Instantiate a class, but warn rather than error for badly named slots
new_with_repaired_slots(classname, ..., extra)
new_with_repaired_slots(classname, ..., extra)
classname |
'character' naming a class |
... |
slots in 'classname' |
extra |
named list giving other slots in 'classname' |
'new(classname)'
MAST:::new_with_repaired_slots("SimpleList", listData = list(x = LETTERS), extra = list(elementType = 'character', food = "tasty", beer = "cold"))
MAST:::new_with_repaired_slots("SimpleList", listData = list(x = LETTERS), extra = list(elementType = 'character', food = "tasty", beer = "cold"))
Sample cells with replacement to find bootstrapped distribution of coefficients
pbootVcov1(cl, zlmfit, R = 99) bootVcov1(zlmfit, R = 99, boot_index = NULL)
pbootVcov1(cl, zlmfit, R = 99) bootVcov1(zlmfit, R = 99, boot_index = NULL)
cl |
a |
zlmfit |
class |
R |
number of bootstrap replicates |
boot_index |
list of indices to resample. Only one of R or boot_index can be offered. |
array of bootstrapped coefficients
array of bootstrapped coefficients
pbootVcov1()
: parallel version of bootstrapping
data(vbetaFA) zlmVbeta <- zlm(~ Stim.Condition, subset(vbetaFA, ncells==1)[1:5,]) #Only run 3 boot straps, which you wouldn't ever want to do in practice... bootVcov1(zlmVbeta, R=3)
data(vbetaFA) zlmVbeta <- zlm(~ Stim.Condition, subset(vbetaFA, ncells==1)[1:5,]) #Only run 3 boot straps, which you wouldn't ever want to do in practice... bootVcov1(zlmVbeta, R=3)
Plot cutpoints and densities for thresholding
## S3 method for class 'thresholdSCRNACountMatrix' plot(x, ask = FALSE, wait.time = 0, type = "bin", indices = NULL, ...)
## S3 method for class 'thresholdSCRNACountMatrix' plot(x, ask = FALSE, wait.time = 0, type = "bin", indices = NULL, ...)
x |
output of |
ask |
if TRUE then will prompt before displaying each plot |
wait.time |
pause (in seconds) between each plot |
type |
one or more of the following: 'bin' (plot the genes by the binning used for thresholding), or 'gene' (plot thresholding by gene – see next argument) |
indices |
if |
... |
further arguments passed to |
displays plots
## See thresholdSCRNACountMatrix example(thresholdSCRNACountMatrix)
## See thresholdSCRNACountMatrix example(thresholdSCRNACountMatrix)
Constructs a forest-like plot of signed log10 p-values, possibly adjusted for multiple comparisons
adjust
can be one of "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none".
plotlrt(lr, adjust = "fdr", thres = 0.1, trunc = 1e-06, groups = NULL)
plotlrt(lr, adjust = "fdr", thres = 0.1, trunc = 1e-06, groups = NULL)
lr |
output from lrtest, with returnall=FALSE |
adjust |
|
thres |
|
trunc |
|
groups |
|
Constructs a dotplot
andrew
Plot the average expression value of two subsets of the data.
Generally these might be 1 cell and multiple-cell replicates,
in which case if the mcols
column ncells
is
set then the averages will be adjusted accordingly.
But it could be any grouping.
plotSCAConcordance( SCellAssay, NCellAssay, filterCriteria = list(nOutlier = 2, sigmaContinuous = 9, sigmaProportion = 9), groups = NULL, ... )
plotSCAConcordance( SCellAssay, NCellAssay, filterCriteria = list(nOutlier = 2, sigmaContinuous = 9, sigmaProportion = 9), groups = NULL, ... )
SCellAssay |
is a FluidigmAssay for the 1-cell per well assay |
NCellAssay |
is a FluidigmAssay for the n-cell per well assay |
filterCriteria |
is a list of filtering criteria to apply to the SCellAssay and NCellAssay |
groups |
is a character vector naming the group within which to perform filtering. NULL by default. |
... |
passed to |
printed plot
getConcordance
data(vbetaFA) sca1 <- subset(vbetaFA, ncells==1) sca100 <- subset(vbetaFA, ncells==100) plotSCAConcordance(sca1, sca100)
data(vbetaFA) sca1 <- subset(vbetaFA, ncells==1) sca100 <- subset(vbetaFA, ncells==100) plotSCAConcordance(sca1, sca100)
Return predictions from a ZlmFit object.
## S3 method for class 'ZlmFit' predict(object, newdata = NULL, modelmatrix = NULL, ...)
## S3 method for class 'ZlmFit' predict(object, newdata = NULL, modelmatrix = NULL, ...)
object |
A |
newdata |
The data to predict from. Currently ignored, will use the data in the object. |
modelmatrix |
The model matrix specifying the linear combination of coefficients. |
... |
ignored |
Predictions (on the link scale) and standard errors.
##See stat_ell example(stat_ell)
##See stat_ell example(stat_ell)
Predicted signatures
A data frame of predicted gene expresion signatures for stimulated and unstimulated cells.
Takes an average, potentially on a different scale given by fun.natural
of some genes. The average is then transformed with fun.cycle
.
primerAverage(fd, geneGroups, fun.natural = expavg, fun.cycle = logshift)
primerAverage(fd, geneGroups, fun.natural = expavg, fun.cycle = logshift)
fd |
|
geneGroups |
|
fun.natural |
transformation to be used to collapse the duplicate expression values |
fun.cycle |
transformation to be used after collapsing |
averaged version of fd
.
This code needs to be tested more extensively after a refactoring. Caveat calculator.
Shows the top 'n' genes by z score on 'by'
## S3 method for class 'summaryZlmFit' print(x, n = 2, by = "logFC", ...)
## S3 method for class 'summaryZlmFit' print(x, n = 2, by = "logFC", ...)
x |
output from summary(ZlmFit) |
n |
number of genes to show |
by |
one of 'C' , 'D' or 'logFC' for continuous, discrete and log fold change z-scores for each contrast |
... |
ignored |
prints a pretty table and invisibly returns a data.table
representing the table.
summary,ZlmFit-method
This function reads a raw Fluidigm Biomark data file or set of files and constructs a SingleCellAssay (or FluigidmAssay) object. This was written c. 2011 and has not been tested lately. The Biomark format may have changed.
read.fluidigm( files = NULL, metadata = NULL, header.size = 2, skip = 8, cycle.threshold = 40, metadataColClasses = NULL, meta.key = NULL, idvars = NULL, splitby = NULL, unique.well.id = "Chamber.ID", raw = TRUE, assay = NULL, geneid = "Assay.Name", sample = NULL, well = "Well", measurement = "X40.Ct", measurement.processed = "Ct", ncells = "SampleRConc" )
read.fluidigm( files = NULL, metadata = NULL, header.size = 2, skip = 8, cycle.threshold = 40, metadataColClasses = NULL, meta.key = NULL, idvars = NULL, splitby = NULL, unique.well.id = "Chamber.ID", raw = TRUE, assay = NULL, geneid = "Assay.Name", sample = NULL, well = "Well", measurement = "X40.Ct", measurement.processed = "Ct", ncells = "SampleRConc" )
files |
A |
metadata |
A |
header.size |
A |
skip |
|
cycle.threshold |
The maximum number of PCR cycles performed (default 40) |
metadataColClasses |
Optional |
meta.key |
Optional |
idvars |
Optional |
splitby |
Optional |
unique.well.id |
The column that uniquely identifies a sample well in the data. Default is "Chamber.ID". |
raw |
|
assay |
|
geneid |
|
sample |
|
well |
|
measurement |
|
measurement.processed |
|
ncells |
The column with the number of cells in this well. |
list of SingleCellAssay
holding the data.
Greg Finak
The order of terms will be rearrange to suit R's liking for hierarchy but otherwise the function should be idempotent for
removeResponse(Formula, warn = TRUE)
removeResponse(Formula, warn = TRUE)
Formula |
formula |
warn |
Issue a warning if a response variable is found? |
formula
Andrew
rstandard bayesglm object S3 method
## S3 method for class 'bayesglm' rstandard( model, infl = influence(model, do.coef = FALSE), type = c("deviance", "pearson"), ... )
## S3 method for class 'bayesglm' rstandard( model, infl = influence(model, do.coef = FALSE), type = c("deviance", "pearson"), ... )
model |
|
infl |
see rstandard |
type |
see rstandard |
... |
ignored |
numeric
residuals
Coerce a SingleCellExperiment to some class defined in MAST
SceToSingleCellAssay(sce, class = "SingleCellAssay", check_sanity = TRUE)
SceToSingleCellAssay(sce, class = "SingleCellAssay", check_sanity = TRUE)
sce |
object inheriting from |
class |
|
check_sanity |
(default: |
object of the indicated class.
Given a fitted model, return the standard errors of the coefficient
se.coef(object, ...)
se.coef(object, ...)
object |
a model implementing |
... |
passed to methods |
vector or matrix
ZlmFit-class
#see ZlmFit-class for examples example('ZlmFit-class')
#see ZlmFit-class for examples example('ZlmFit-class')
Display info
## S4 method for signature 'LMlike' show(object) ## S4 method for signature 'ZlmFit' show(object)
## S4 method for signature 'LMlike' show(object) ## S4 method for signature 'ZlmFit' show(object)
object |
an object of some type |
Prints information on a LMlike object
side effect of printing to console
show(ZlmFit)
: print info on ZlmFit
list
Splits a SingleCellAssay
into a list
by a factor (or something coercible into a factor) or a character giving a column of colData(x)
## S4 method for signature 'SingleCellAssay,character' split(x, f, drop = FALSE, ...)
## S4 method for signature 'SingleCellAssay,character' split(x, f, drop = FALSE, ...)
x |
SingleCellAssay |
f |
length-1 character, or atomic of length ncol(x) |
drop |
drop unused factor levels |
... |
ignored |
List
data(vbetaFA) split(vbetaFA, 'ncells') fa <- as.factor(colData(vbetaFA)$ncells) split(vbetaFA, fa)
data(vbetaFA) split(vbetaFA, 'ncells') fa <- as.factor(colData(vbetaFA)$ncells) split(vbetaFA, fa)
The focus of the ellipse will be the point (x, y) and semi-major axes aligned with the coordinate axes and scaled by xse, yse and the level.
stat_ell( mapping = NULL, data = NULL, geom = "polygon", position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, fill = NA, level = 0.95, lty = 2, invert = FALSE, alpha = 1, ... )
stat_ell( mapping = NULL, data = NULL, geom = "polygon", position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, fill = NA, level = 0.95, lty = 2, invert = FALSE, alpha = 1, ... )
mapping |
Set of aesthetic mappings created by aes or aes_. If specified and inherit.aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping. |
data |
The data to be displayed in this layer. There are three options: If NULL, the default, the data is inherited from the plot data as specified in the call to ggplot. A data.frame, or other object, will override the plot data. All objects will be fortified to produce a data frame. See fortify for which variables will be created. A function will be called with a single argument, the plot data. The return value must be a data.frame., and will be used as the layer data. |
geom |
The geometric object to use display the data |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
na.rm |
If FALSE (the default), removes missing values with a warning. If TRUE silently removes missing values. |
show.legend |
logical. Should this layer be included in the legends? NA, the default, includes if any aesthetics are mapped. FALSE never includes, and TRUE always includes. |
inherit.aes |
If FALSE, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from the default plot specification, e.g. borders. |
fill |
A color or aesthetic mapping to fill color. Defaults to NA for empty ellipses. |
level |
The confidence level at which to draw an ellipse (default is level=0.95). |
lty |
The linetype to use. Can map to a variable. Defaults to 2 (dashed line) |
invert |
vector of length 1 that should either be |
alpha |
transparency |
... |
other arguments passed on to layer. These are often aesthetics, used to set an aesthetic to a fixed value, like color = "red" or size = 3. They may also be parameters to the paired geom/stat. |
ggplot layer
data(vbetaFA) library(ggplot2) zlmCond <- zlm(~Stim.Condition, vbetaFA[1:10,]) MM <- model.matrix(~Stim.Condition,unique(colData(vbetaFA)[,c("Stim.Condition"),drop=FALSE])) predicted <- predict(zlmCond,modelmatrix=MM) plt <- ggplot(predicted)+aes(x=invlogit(etaD),y=muC,xse=seD,yse=seC,col=sample)+ facet_wrap(~primerid,scales="free_y")+theme_linedraw()+ geom_point(size=0.5)+scale_x_continuous("Proportion expression")+ scale_y_continuous("Estimated Mean")+ stat_ell(aes(x=etaD,y=muC),level=0.95, invert='x') ## plot with inverse logit transformed x-axis print(plt) # doesn't do anything in this case because there are no inestimable coefficients predictI <- impute(predicted, groupby='primerid')
data(vbetaFA) library(ggplot2) zlmCond <- zlm(~Stim.Condition, vbetaFA[1:10,]) MM <- model.matrix(~Stim.Condition,unique(colData(vbetaFA)[,c("Stim.Condition"),drop=FALSE])) predicted <- predict(zlmCond,modelmatrix=MM) plt <- ggplot(predicted)+aes(x=invlogit(etaD),y=muC,xse=seD,yse=seC,col=sample)+ facet_wrap(~primerid,scales="free_y")+theme_linedraw()+ geom_point(size=0.5)+scale_x_continuous("Proportion expression")+ scale_y_continuous("Estimated Mean")+ stat_ell(aes(x=etaD,y=muC),level=0.95, invert='x') ## plot with inverse logit transformed x-axis print(plt) # doesn't do anything in this case because there are no inestimable coefficients predictI <- impute(predicted, groupby='primerid')
SingleCellAssay
by cells (columns)Evaluates the expression in ...
in the context of colData(x)
and returns a subsetted version of x
## S4 method for signature 'SingleCellAssay' subset(x, ...)
## S4 method for signature 'SingleCellAssay' subset(x, ...)
x |
|
... |
expression |
SingleCellAssay
data(vbetaFA) subset(vbetaFA, ncells==1)
data(vbetaFA) subset(vbetaFA, ncells==1)
Return programmatically useful summary of a fit
summarize(object, ...)
summarize(object, ...)
object |
LMlike or subclass |
... |
other arguments |
list of parameters characterizing fit
Returns a data.table
with one row per gene set.
This data.table
contains columns:
name of gene set
Z statistic for continuous component
wald P value
difference in continuous regression coefficients between null and test sets (ie, the numerator of the Z-statistic.)
Z statistic for discrete
wald P value
difference in discrete regression coefficients between null and test sets.
combined discrete and continuous Z statistic using Stouffer's method
combined P value
FDR adjusted combined P value
## S4 method for signature 'GSEATests' summary(object, ...)
## S4 method for signature 'GSEATests' summary(object, ...)
object |
A |
... |
passed to |
data.table
gseaAfterBoot
## See the examples in gseaAfterBoot example(gseaAfterBoot)
## See the examples in gseaAfterBoot example(gseaAfterBoot)
ZlmFit
objectReturns a data.table
with a special print method that shows the top 2 most significant genes by contrast.
This data.table
contains columns:
the gene
C=continuous, D=discrete, logFC=log fold change, S=combined using Stouffer's method, H=combined using hurdle method
the coefficient/contrast of interest
upper bound of confidence interval
lower bound of confidence interval
point estimate
z score (coefficient divided by standard error of coefficient)
likelihood ratio test p-value (only if doLRT=TRUE
)
Some of these columns will contain NAs if they are not applicable for a particular component or contrast.
## S4 method for signature 'ZlmFit' summary( object, logFC = TRUE, doLRT = FALSE, level = 0.95, parallel = FALSE, ... )
## S4 method for signature 'ZlmFit' summary( object, logFC = TRUE, doLRT = FALSE, level = 0.95, parallel = FALSE, ... )
object |
A |
logFC |
If TRUE, calculate log-fold changes, or output from a call to |
doLRT |
if TRUE, calculate lrTests on each coefficient, or a character vector of such coefficients to consider. |
level |
what level of confidence coefficient to return. Defaults to 95 percent. |
parallel |
If TRUE and |
... |
ignored |
data.table
print.summaryZlmFit
data(vbetaFA) z <- zlm(~Stim.Condition, vbetaFA[1:5,]) zs <- summary(z) names(zs) print(zs) ##Select `datatable` copmonent to get normal print method zs$datatable ## Can use parallel processing for LRT now summary(z, doLRT = TRUE, parallel = TRUE)
data(vbetaFA) z <- zlm(~Stim.Condition, vbetaFA[1:5,]) zs <- summary(z) names(zs) print(zs) ##Select `datatable` copmonent to get normal print method zs$datatable ## Can use parallel processing for LRT now summary(z, doLRT = TRUE, parallel = TRUE)
Returns the proportion of (putative) expression, the variance of expressed cells, and -log10 shapiro-wilk tests for normality on the expressed cells
## S3 method for class 'thresholdSCRNACountMatrix' summary(object, ...) ## S3 method for class 'summaryThresholdSCRNA' print(x, ...)
## S3 method for class 'thresholdSCRNACountMatrix' summary(object, ...) ## S3 method for class 'summaryThresholdSCRNA' print(x, ...)
object |
a |
... |
currently ignored |
x |
a |
a list of statistics on the original data, and thresholded data
print(summaryThresholdSCRNA)
: prints five-number distillation of the statistics and invisibly returns the table used to generate the summary
An adaptive threshold is calculated from the conditional mean of expression, based on 10 bins of the genes with similar expression levels. Thresholds are chosen by estimating cutpoints in the bimodal density estimates of the binned data. These density estimates currently exclude the zeros due to complications with how the bandwidth is selected. (If the bandwith is too small, then extra peaks/modes are found and everything goes haywire). If the diagnostic plots don't reveal any bimodal bins, this is probably the reason, and you may not need to threshold since background in the data are exact zeros.
thresholdSCRNACountMatrix( data_all, conditions = NULL, cutbins = NULL, nbins = 10, bin_by = "median", qt = 0.975, min_per_bin = 50, absolute_min = 0, data_log = TRUE, adj = 1 )
thresholdSCRNACountMatrix( data_all, conditions = NULL, cutbins = NULL, nbins = 10, bin_by = "median", qt = 0.975, min_per_bin = 50, absolute_min = 0, data_log = TRUE, adj = 1 )
data_all |
|
conditions |
Bins are be determined per gene and per condition. Typically contrasts of interest should be specified. |
cutbins |
|
nbins |
|
bin_by |
|
qt |
when |
min_per_bin |
minimum number of genes within a bin |
absolute_min |
|
data_log |
is |
adj |
bandwith adjustment, passed to |
list
of thresholded counts (on natural scale), thresholds, bins, densities estimated on each bin, and the original data
data(maits,package='MAST', envir = environment()) sca <- FromMatrix(t(maits$expressionmat[,1:1000]), maits$cdat, maits$fdat[1:1000,]) tt <- thresholdSCRNACountMatrix(assay(sca)) tt <- thresholdSCRNACountMatrix(2^assay(sca)-1, data_log=FALSE) opar <- par(no.readonly = TRUE) on.exit(par(opar)) par(mfrow=c(4,2)) plot(tt)
data(maits,package='MAST', envir = environment()) sca <- FromMatrix(t(maits$expressionmat[,1:1000]), maits$cdat, maits$fdat[1:1000,]) tt <- thresholdSCRNACountMatrix(assay(sca)) tt <- thresholdSCRNACountMatrix(2^assay(sca)-1, data_log=FALSE) opar <- par(no.readonly = TRUE) on.exit(par(opar)) par(mfrow=c(4,2)) plot(tt)
Vbeta Data Set
a data frame with 11 columns.
Column Ct
contains the cycle threshold, with NA denoting that the threshold was never crossed. So it is inversely proportional to the log2 mRNA, and should be negated (and NAs set to zero) if it is used as a expression measurement for a FluidigmAssay
.
Vbeta Data Set, FluidigmAssay
a FluidigmAssay
of the vbeta data set.
Run a Wald tests on discrete and continuous components
hypothesis
can be one of a character
giving complete factors or terms to be dropped from the model, CoefficientHypothesis
giving names of coefficients to be dropped, Hypothesis
giving contrasts using the symbolically, or a contrast matrix
, with one row for each coefficient in the full model, and one column for each contrast being tested.
waldTest(object, hypothesis)
waldTest(object, hypothesis)
object |
LMlike or subclass |
hypothesis |
the hypothesis to be tested. See details. |
array giving test statistics
fit
lrTest
lht
#see ZlmFit-class for examples example('ZlmFit-class')
#see ZlmFit-class for examples example('ZlmFit-class')
A 3D array with first dimension being the genes, next dimension giving information about the test (the degrees of freedom, Chisq statistic, and P value), and final dimension being the value of these quantities on the discrete, continuous and hurdle (combined) levels.
## S4 method for signature 'ZlmFit,matrix' waldTest(object, hypothesis)
## S4 method for signature 'ZlmFit,matrix' waldTest(object, hypothesis)
object |
ZlmFit |
hypothesis |
See Details |
3D array
This centers each column of mat
around the mean of its non-zero values.
xform(mat, scale = FALSE)
xform(mat, scale = FALSE)
mat |
matrix (such as produced by exprs) |
scale |
should the columns also be scaled to have unit variance |
matrix
For each gene in sca, fits the hurdle model in formula
(linear for et>0), logistic for et==0 vs et>0.
Return an object of class ZlmFit
containing slots giving the coefficients, variance-covariance matrices, etc.
After each gene, optionally run the function on the fit named by 'hook'
zlm( formula, sca, method = "bayesglm", silent = TRUE, ebayes = TRUE, ebayesControl = NULL, force = FALSE, hook = NULL, parallel = TRUE, LMlike, onlyCoef = FALSE, exprs_values = assay_idx(sca)$aidx, ... )
zlm( formula, sca, method = "bayesglm", silent = TRUE, ebayes = TRUE, ebayesControl = NULL, force = FALSE, hook = NULL, parallel = TRUE, LMlike, onlyCoef = FALSE, exprs_values = assay_idx(sca)$aidx, ... )
formula |
a formula with the measurement variable on the LHS and predictors present in colData on the RHS |
sca |
SingleCellAssay object |
method |
character vector, either 'glm', 'glmer' or 'bayesglm' |
silent |
Silence common problems with fitting some genes |
ebayes |
if TRUE, regularize variance using empirical bayes method |
ebayesControl |
list with parameters for empirical bayes procedure. See ebayes. |
force |
Should we continue testing genes even after many errors have occurred? |
hook |
a function called on the |
parallel |
If TRUE and |
LMlike |
if provided, then the model defined in this object will be used, rather than following the formulas. This is intended for internal use. |
onlyCoef |
If TRUE then only an array of model coefficients will be returned (probably only useful for bootstrapping). |
exprs_values |
character or integer passed to 'assay' specifying which assay to use for testing |
... |
arguments passed to the S4 model object upon construction. For example, |
a object of class ZlmFit
with methods to extract coefficients, etc.
OR, if data is a data.frame
just a list of the discrete and continuous fits.
The empirical bayes regularization of the gene variance assumes that the precision (1/variance) is drawn from a
gamma distribution with unknown parameters.
These parameters are estimated by considering the distribution of sample variances over all genes.
The procedure used for this is determined from
ebayesControl
, a named list with components 'method' (one of 'MOM' or 'MLE') and 'model' (one of 'H0' or 'H1')
method MOM uses a method-of-moments estimator, while MLE using the marginal likelihood.
H0 model estimates the precisions using the intercept alone in each gene, while H1 fits the full model specified by formula
ZlmFit-class, ebayes, GLMlike-class, BayesGLMlike-class
data(vbetaFA) zlmVbeta <- zlm(~ Stim.Condition, subset(vbetaFA, ncells==1)[1:10,]) slotNames(zlmVbeta) #A matrix of coefficients coef(zlmVbeta, 'D')['CCL2',] #An array of covariance matrices vcov(zlmVbeta, 'D')[,,'CCL2'] waldTest(zlmVbeta, CoefficientHypothesis('Stim.ConditionUnstim')) ## Can also provide just a \code{data.frame} instead data<- data.frame(x=rnorm(500), z=rbinom(500, 1, .3)) logit.y <- with(data, x*2 + z*2); mu.y <- with(data, 10+10*x+10*z + rnorm(500)) y <- (runif(500)<exp(logit.y)/(1+exp(logit.y)))*1 y[y>0] <- mu.y[y>0] data$y <- y fit <- zlm(y ~ x+z, data) summary.glm(fit$disc)
data(vbetaFA) zlmVbeta <- zlm(~ Stim.Condition, subset(vbetaFA, ncells==1)[1:10,]) slotNames(zlmVbeta) #A matrix of coefficients coef(zlmVbeta, 'D')['CCL2',] #An array of covariance matrices vcov(zlmVbeta, 'D')[,,'CCL2'] waldTest(zlmVbeta, CoefficientHypothesis('Stim.ConditionUnstim')) ## Can also provide just a \code{data.frame} instead data<- data.frame(x=rnorm(500), z=rbinom(500, 1, .3)) logit.y <- with(data, x*2 + z*2); mu.y <- with(data, 10+10*x+10*z + rnorm(500)) y <- (runif(500)<exp(logit.y)/(1+exp(logit.y)))*1 y[y>0] <- mu.y[y>0] data$y <- y fit <- zlm(y ~ x+z, data) summary.glm(fit$disc)
This holds output from a call to zlm. Many methods are defined to operate on it. See below.
## S4 method for signature 'ZlmFit,CoefficientHypothesis' lrTest(object, hypothesis, ...) ## S4 method for signature 'ZlmFit,Hypothesis' lrTest(object, hypothesis, ...) ## S4 method for signature 'ZlmFit,matrix' lrTest(object, hypothesis, ...) ## S4 method for signature 'ZlmFit,CoefficientHypothesis' waldTest(object, hypothesis) ## S4 method for signature 'ZlmFit,Hypothesis' waldTest(object, hypothesis) ## S4 method for signature 'ZlmFit' coef(object, which, ...) ## S4 method for signature 'ZlmFit' vcov(object, which, ...) ## S4 method for signature 'ZlmFit' se.coef(object, which, ...)
## S4 method for signature 'ZlmFit,CoefficientHypothesis' lrTest(object, hypothesis, ...) ## S4 method for signature 'ZlmFit,Hypothesis' lrTest(object, hypothesis, ...) ## S4 method for signature 'ZlmFit,matrix' lrTest(object, hypothesis, ...) ## S4 method for signature 'ZlmFit,CoefficientHypothesis' waldTest(object, hypothesis) ## S4 method for signature 'ZlmFit,Hypothesis' waldTest(object, hypothesis) ## S4 method for signature 'ZlmFit' coef(object, which, ...) ## S4 method for signature 'ZlmFit' vcov(object, which, ...) ## S4 method for signature 'ZlmFit' se.coef(object, which, ...)
object |
|
hypothesis |
call to Hypothesis or CoefficientHypothesis or a matrix giving such contrasts. |
... |
ignored |
which |
character vector, one of "C" (continuous) or "D" (discrete) specifying which component should be returned |
see "Methods (by generic)"
lrTest(object = ZlmFit, hypothesis = CoefficientHypothesis)
: Returns an array with likelihood-ratio tests on contrasts defined using CoefficientHypothesis()
.
lrTest(object = ZlmFit, hypothesis = Hypothesis)
: Returns an array with likelihood-ratio tests specified by Hypothesis
, which is a Hypothesis.
lrTest(object = ZlmFit, hypothesis = matrix)
: Returns an array with likelihood-ratio tests specified by Hypothesis
, which is a contrast matrix
.
waldTest(object = ZlmFit, hypothesis = CoefficientHypothesis)
: Returns an array with Wald Tests on contrasts defined using CoefficientHypothesis()
.
waldTest(object = ZlmFit, hypothesis = Hypothesis)
: Returns an array with Wald Tests on contrasts defined in Hypothesis()
coef(ZlmFit)
: Returns the matrix of coefficients for component which
.
vcov(ZlmFit)
: Returns an array of variance/covariance matrices for component which
.
se.coef(ZlmFit)
: Returns a matrix of standard error estimates for coefficients on component which
.
coefC
matrix of continuous coefficients
coefD
matrix of discrete coefficients
vcovC
array of variance/covariance matrices for coefficients
vcovD
array of variance/covariance matrices for coefficients
LMlike
the LmWrapper object used
sca
the SingleCellAssay
object used
deviance
matrix of deviances
loglik
matrix of loglikelihoods
df.null
matrix of null (intercept only) degrees of freedom
df.resid
matrix of residual DOF
dispersion
matrix of dispersions (after shrinkage)
dispersionNoShrink
matrix of dispersion (before shrinkage)
priorDOF
shrinkage weight in terms of number of psuedo-obs
priorVar
shrinkage target
converged
output that may optionally be set by the underlying modeling function
hookOut
a list of length ngenes containing output from a hook function, if zlm
was called with one
exprs_values
'character' or 'integer' with the 'assay' used.
zlm summary,ZlmFit-method
data(vbetaFA) zlmVbeta <- zlm(~ Stim.Condition+Population, subset(vbetaFA, ncells==1)[1:10,]) #Coefficients and standard errors coef(zlmVbeta, 'D') coef(zlmVbeta, 'C') se.coef(zlmVbeta, 'C') #Test for a Population effect by dropping the whole term (a 5 degree of freedom test) lrTest(zlmVbeta, 'Population') #Test only if the VbetaResponsive cells differ from the baseline group lrTest(zlmVbeta, CoefficientHypothesis('PopulationVbetaResponsive')) # Test if there is a difference between CD154+/Unresponsive and CD154-/Unresponsive. # Note that because we parse the expression # the columns must be enclosed in backquotes # to protect the \quote{+} and \quote{-} characters. lrTest(zlmVbeta, Hypothesis('`PopulationCD154+VbetaUnresponsive` - `PopulationCD154-VbetaUnresponsive`')) waldTest(zlmVbeta, Hypothesis('`PopulationCD154+VbetaUnresponsive` - `PopulationCD154-VbetaUnresponsive`'))
data(vbetaFA) zlmVbeta <- zlm(~ Stim.Condition+Population, subset(vbetaFA, ncells==1)[1:10,]) #Coefficients and standard errors coef(zlmVbeta, 'D') coef(zlmVbeta, 'C') se.coef(zlmVbeta, 'C') #Test for a Population effect by dropping the whole term (a 5 degree of freedom test) lrTest(zlmVbeta, 'Population') #Test only if the VbetaResponsive cells differ from the baseline group lrTest(zlmVbeta, CoefficientHypothesis('PopulationVbetaResponsive')) # Test if there is a difference between CD154+/Unresponsive and CD154-/Unresponsive. # Note that because we parse the expression # the columns must be enclosed in backquotes # to protect the \quote{+} and \quote{-} characters. lrTest(zlmVbeta, Hypothesis('`PopulationCD154+VbetaUnresponsive` - `PopulationCD154-VbetaUnresponsive`')) waldTest(zlmVbeta, Hypothesis('`PopulationCD154+VbetaUnresponsive` - `PopulationCD154-VbetaUnresponsive`'))