Metadata that describes the samples.
Usage
sampleData(object, ...)
sampleData(object, ...) <- value
# S4 method for SingleCellExperiment
sampleData(
object,
clean = TRUE,
ignoreCols = c("^description$", "^genomeBuild$", "^qualityFormat$", "^samRef$"),
denylistCols = c("^ident$", "^g2mScore$", "^sScore$", "^phase$", "^oldIdent$",
"^origIdent$", "^res[0-9]+")
)
# S4 method for SingleCellExperiment,DFrame
sampleData(object) <- value
Arguments
- object
Object.
- clean
logical(1)
. Only returnfactor
columns. Useful when working with objects that contain quality control metrics incolData()
. For example,bcbioRNASeq
andDESeqDataSet
objects often contain additional columns that aren't informative sample metadata.- ignoreCols
character
orNULL
. Only applies whenclean = TRUE
. Additional factor columns defined incolData
to be ignored as sample-level metadata. Particularly useful forSingleCellExperiment
objects, where cell-to-sample mappings are defined using thesampleId
column.- denylistCols
character
orNULL
. Column names that should not be treated as sample-level metadata. Currently applicable only toSingleCellExperiment
objects, which have cell-level columns that can be difficult to distinguish, especially when processed using Seurat, scater, etc.- value
Value to assign.
- ...
Additional arguments.
Details
This is a complement to the standard
colData()
function, but improves support
for accessing sample metadata for datasets where multiple items in the
columns map to a single sample (e.g. cells for a single-cell RNA-seq
experiment).
SingleCellExperiment
Recommended colData
:
sampleId
:factor
defining cell-to-sample mappings. These mappings should use syntactically valid names. Note that this is not currently required as we're supportingSingleCellExperiment
objects from 1 sample, but it's required for working with multiple samples in a single object.
Examples
data(SingleCellExperiment_splatter, package = "AcidTest")
## SingleCellExperiment ====
object <- SingleCellExperiment_splatter
sampleData(object)
#> DataFrame with 4 rows and 2 columns
#> sampleName interestingGroups
#> <factor> <factor>
#> sample3 sample3 sample3
#> sample4 sample4 sample4
#> sample1 sample1 sample1
#> sample2 sample2 sample2
## Assignment support.
sampleData(object)[["batch"]] <- 1L
#> DataFrame with 400 rows and 3 columns
#> sampleId sampleName batch
#> <factor> <factor> <integer>
#> cell001 sample3 sample3 1
#> cell002 sample3 sample3 1
#> cell003 sample4 sample4 1
#> cell004 sample1 sample1 1
#> cell005 sample2 sample2 1
#> ... ... ... ...
#> cell396 sample3 sample3 1
#> cell397 sample4 sample4 1
#> cell398 sample3 sample3 1
#> cell399 sample3 sample3 1
#> cell400 sample2 sample2 1
## `batch` column should be now defined.
sampleData(object)
#> DataFrame with 4 rows and 2 columns
#> sampleName interestingGroups
#> <factor> <factor>
#> sample3 sample3 sample3
#> sample4 sample4 sample4
#> sample1 sample1 sample1
#> sample2 sample2 sample2