Description Usage Arguments Details Value Author(s) See Also Examples
Perform basic hypothesis tests with linear models in an efficient manner.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | testLinearModel(x, ...)
## S4 method for signature 'ANY'
testLinearModel(
x,
design,
coefs = ncol(design),
contrasts = NULL,
block = NULL,
equiweight = FALSE,
method = "z",
subset.row = NULL,
BPPARAM = SerialParam()
)
## S4 method for signature 'SummarizedExperiment'
testLinearModel(x, ..., assay.type = "logcounts")
|
x |
A numeric matrix-like object containing log-expression values for cells (columns) and genes (rows). Alternatively, a SummarizedExperiment containing such a matrix. |
... |
For the generic, further arguments to pass to specific methods. For the SummarizedExperiment method, further arguments to pass to the ANY method. |
design |
A numeric design matrix with number of rows equal to |
coefs |
An integer vector specifying the coefficients to drop to form the null model.
Only used if |
contrasts |
A numeric vector or matrix specifying the contrast of interest.
This should have length (if vector) or number of rows (if matrix) equal to |
block |
A factor specifying the blocking levels for each cell in |
equiweight |
A logical scalar indicating whether statistics from each block should be given equal weight.
Otherwise, each block is weighted according to its number of cells.
Only used if |
method |
String specifying how p-values should be combined when |
subset.row |
See |
BPPARAM |
A BiocParallelParam object indicating whether parallelization should be performed across genes. |
assay.type |
String or integer scalar specifying the assay containing the log-expression values. |
This function can be considered a more efficient version of lmFit
that works on a variety of matrix representations (see fitLinearModel
).
It also omits the empirical Bayes shrinkage step,
which is acceptable given the large number of residual d.f. in typical single-cell studies.
If contrasts
is specified, the null hypothesis is defined by the contrast matrix or vector in the same manner
that is used in the limma and edgeR packages.
Briefly, the contrast vector specifies a linear combination of coefficients that sums to zero under the null.
For contrast matrices, the joint null consists of the intersection of the nulls defined by each column vector.
Otherwise, if only coefs
is specified,
the null model is formed by simply dropping all of the specified coefficients from design
.
If block
is specified, a linear model is fitted separately to the cells in each level.
The results are combined across levels by averaging coefficients and combining p-values with combinePValues
.
By default, the contribution from each level is weighted by its number of cells;
if equiweight=TRUE
, each level is given equal weight instead.
A DataFrame containing test results with one row per row of x
.
It contains the estimated values of the contrasted coefficients
as well as the p-value and FDR for each gene.
Aaron Lun
fitLinearModel
, which performs the hard work of fitting the linear models.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | y <- matrix(rnorm(10000), ncol=100)
# Example with categorical factors:
A <- gl(2, 50)
design <- model.matrix(~A)
testLinearModel(y, design, contrasts=c(0, 1))
# Example with continuous variables:
u <- runif(100)
design <- model.matrix(~u)
testLinearModel(y, design, contrasts=c(0, 1))
# Example with multiple variables:
B <- gl(4, 25)
design <- model.matrix(~B)
testLinearModel(y, design, contrasts=cbind(c(0,1,0,0), c(0,0,1,-1)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.