Skip to contents

These two functions provide a way to trimming down the sample or variable information tibble of an experiment() or SummarizedExperiment to only the columns of interest.

The same syntax as dplyr::select() is used. For example, to get a new experiment() with only the "sample" and "group" columns in the sample information tibble, use select_col(exp, group). Note that you don't need to (and you can't) explicitly select or deselect the sample column in sample_info. The same applies to the variable column in var_info. Whatever the selection expression is, the sample or variable column will always be kept.

Usage

select_col(exp, ...)

select_row(exp, ...)

Arguments

exp

An experiment() or SummarizedExperiment object.

...

<data-masking> Column names to select. If empty, all columns except the sample or variable column will be discarded.

Value

An object of the same class as exp.

Identifier columns

For an experiment() object, sample is a physical column in sample_info, and variable is a physical column in var_info.

For a SummarizedExperiment, sample and variable identifiers live in colnames(exp) and rownames(exp), rather than in SummarizedExperiment::colData() or SummarizedExperiment::rowData(). Observation verbs expose colnames(exp) as a virtual .sample column, and variable verbs expose rownames(exp) as a virtual .variable column. These dot-prefixed names distinguish dimension identifiers from regular metadata columns. After the operation, the virtual column is removed and its values are written back to the corresponding dimension names.

Consequently, sample in colData(exp) and variable in rowData(exp) remain ordinary metadata columns. The names .sample and .variable are reserved; an input containing either name in the corresponding metadata raises an error rather than overwriting that column.

Examples

toy_exp <- real_experiment

toy_exp_2 <- toy_exp |>
  select_col(group) |>
  select_row(protein, peptide)

toy_exp_2
#> 
#> ── GlycoproteomicSE ────────────────────────────────────────────────────────────
#>  Abundance assay: 12 samples, 4262 variables
#>  Glycan type: N
#>  Row data fields: protein <chr>, peptide <chr>
#>  Column data fields: group <fct>
#>  Metadata fields: exp_type <chr>, glycan_type <chr>, quant_method <chr>