Skip to contents

Metadata that describes the samples.

Usage

sampleData(object, ...)

sampleData(object, ...) <- value

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

# S4 method for SummarizedExperiment,DFrame
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.

value

Value to assign.

...

Additional arguments.

Value

DataFrame.

Details

All columns defined in colData of the object must be named in strict lower camel case, otherwise this function will intentionally error.

Note

Updated 2021-02-22.

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.

Examples

data(RangedSummarizedExperiment, package = "AcidTest")

## SummarizedExperiment ====
object <- RangedSummarizedExperiment
sampleData(object)
#> 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(object)[["batch"]] <- 1L
## `batch` column should be now defined.
sampleData(object)
#> 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