R/SingleCellAssay-methods.R
FromMatrix.Rd
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
)
matrix, or a list of matrices, or an array. Columns are cells, rows are genes.
cellData an object that can be coerced to a DataFrame, ie, data.frame, AnnotatedDataFrame. Must have as many rows as ncol(exprsArray)
featureData an object that can be coerced to a DataFrame, ie, data.frame, AnnotatedDataFrame. Must have as many rows as nrow(exprsArray)
.
desired subclass of object. Default SingleCellAssay
.
(default: TRUE
) Set FALSE
to override sanity checks that try to ensure that the default assay is log-transformed and has at least one exact zero. See defaultAssay for details on the "default assay" which is assumed to contain log transformed data.
alias for check_sanity
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)
#> No dimnames in `exprsArray`, assuming `fData` and `cData` are sorted according to `exprsArray`
#> Assuming data assay in position 1, with name et is log-transformed.
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)
#> No dimnames in `exprsArray`, assuming `fData` and `cData` are sorted according to `exprsArray`
#> Assuming data assay in position 1, with name et is log-transformed.
stopifnot(inherits(fd, 'SingleCellAssay'))