Metadata that describes the samples.

sampleData(object, ...)

sampleData(object, ...) <- value

# S4 method for SummarizedExperiment
sampleData(object, clean = TRUE,
  ignoreCols = c("^description$", "^genomeBuild$", "^qualityFormat$",
  "^samRef$"))

# S4 method for SingleCellExperiment
sampleData(object, clean = TRUE,
  ignoreCols = c("^description$", "^genomeBuild$", "^qualityFormat$",
  "^samRef$"), blacklistCols = c("^G2M.Score$", "^Phase$", "^S.Score$",
  "^ident$", "^old.ident$", "^orig.ident$", "^res[.0-9]+$"))

# S4 method for SummarizedExperiment,DataFrame
sampleData(object) <- value

# S4 method for SingleCellExperiment,DataFrame
sampleData(object) <- value

# S4 method for SummarizedExperiment
sampleNames(object)

Arguments

object

Object.

clean

logical(1). Only return factor columns. Useful when working with objects that contain quality control metrics in colData(). For example, bcbioRNASeq and DESeqDataSet objects often contain additional columns that aren't informative sample metadata.

ignoreCols

character or NULL. Only applies when clean = TRUE. Additional factor columns defined in colData to be ignored as sample-level metadata. Particularly useful for SingleCellExperiment objects, where cell-to-sample mappings are defined using the sampleID column.

blacklistCols

character or NULL. Column names that should not be treated as sample-level metadata. Currently applicable only to SingleCellExperiment objects, which have cell-level columns that can be difficult to distinguish, especially when processed using Seurat, scater, etc.

value

Value.

...

Additional arguments.

Value

DataFrame.

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).

All supported S4 classes

Illegal colData:

  • interestingGroups: Generated automatically, based on the criteria slotted into the object using interestingGroups(). The function will error intentionally if this column is manually defined in colData().

Recommended colData:

  • sampleName: Human readable sample names used by basejump plotting functions in favor of object column names, which should be syntactically valid (but not always very readable). See make.names() for more information on syntactically valid names. Note that if this column is not defined in the object, it will be returned automatically by sampleData().

SummarizedExperiment

Required colData:

  • None.

Illegal colData:

  • sampleID: Redundant; already defined in the object column names.

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 supporting SingleCellExperiment objects from 1 sample, but it's required for working with multiple samples in a single object.

Examples

data(rse, sce, package = "acidtest") ## SummarizedExperiment ==== x <- rse sampleData(x)
#> DataFrame with 12 rows and 3 columns #> condition sampleName interestingGroups #> <factor> <factor> <factor> #> sample01 A sample01 A #> sample02 A sample02 A #> sample03 A sample03 A #> sample04 A sample04 A #> sample05 A sample05 A #> ... ... ... ... #> sample08 B sample08 B #> sample09 B sample09 B #> sample10 B sample10 B #> sample11 B sample11 B #> sample12 B sample12 B
## Assignment support sampleData(x)[["batch"]] <- 1L ## `batch` column should be now defined. sampleData(x)
#> DataFrame with 12 rows and 3 columns #> condition sampleName interestingGroups #> <factor> <factor> <factor> #> sample01 A sample01 A #> sample02 A sample02 A #> sample03 A sample03 A #> sample04 A sample04 A #> sample05 A sample05 A #> ... ... ... ... #> sample08 B sample08 B #> sample09 B sample09 B #> sample10 B sample10 B #> sample11 B sample11 B #> sample12 B sample12 B
## SingleCellExperiment ==== x <- sce sampleData(x)
#> DataFrame with 2 rows and 2 columns #> sampleName interestingGroups #> <factor> <factor> #> sample1 sample1 sample1 #> sample2 sample2 sample2
## Assignment support. sampleData(x)[["batch"]] <- 1L ## `batch` column should be now defined. sampleData(x)
#> DataFrame with 2 rows and 2 columns #> sampleName interestingGroups #> <factor> <factor> #> sample1 sample1 sample1 #> sample2 sample2 sample2