Extends dplyr::select() to keep or rename columns in a qseaSet's
sampleTable. This allows column subsetting, renaming, and use of
tidyselect helpers while preserving key identifiers.
# S3 method for class 'qseaSet'
select(.data, ...)qseaSet.
A qseaSet object whose sampleTable columns will be selected or renamed.
Additional arguments passed to dplyr::select(), supports tidyselect helpers
(e.g., dplyr::matches(), dplyr::starts_with()).
Negative selection (-col) is supported, but sample_name and group
cannot be removed.
Default: none.
A qseaSet with its sampleTable updated:
contains only selected/renamed columns,
always includes sample_name and group (if available).
This is a wrapper around selectQset().
Essential columns sample_name and group are always preserved (and appear
first if present).
selectQset() for the underlying implementation,
qsea::getSampleTable() to view results,
mutate.qseaSet(), filter.qseaSet() for related dplyr verbs.
data(exampleTumourNormal, package = "mesa")
# Keep only specific columns (sample_name and group always preserved)
exampleTumourNormal %>%
dplyr::select(type, tumour) %>%
qsea::getSampleTable()
#> sample_name group type tumour
#> Colon1_N Colon1_N Colon1_N NormalColon Normal
#> Colon1_T Colon1_T Colon1_T CRC Tumour
#> Colon2_N Colon2_N Colon2_N NormalColon Normal
#> Colon2_T Colon2_T Colon2_T CRC Tumour
#> Lung1_N Lung1_N Lung1_N NormalLung Normal
#> Lung1_T Lung1_T Lung1_T LUAD Tumour
#> Lung2_N Lung2_N Lung2_N NormalLung Normal
#> Lung2_T Lung2_T Lung2_T LUSC Tumour
#> Lung3_N Lung3_N Lung3_N NormalLung Normal
#> Lung3_T Lung3_T Lung3_T LUAD Tumour
# Select and rename a column
exampleTumourNormal %>%
dplyr::select(age, tumour_new = tumour) %>%
qsea::getSampleTable()
#> sample_name group age tumour_new
#> Colon1_N Colon1_N Colon1_N 80 Normal
#> Colon1_T Colon1_T Colon1_T 80 Tumour
#> Colon2_N Colon2_N Colon2_N 67 Normal
#> Colon2_T Colon2_T Colon2_T 67 Tumour
#> Lung1_N Lung1_N Lung1_N 64 Normal
#> Lung1_T Lung1_T Lung1_T 64 Tumour
#> Lung2_N Lung2_N Lung2_N 71 Normal
#> Lung2_T Lung2_T Lung2_T 71 Tumour
#> Lung3_N Lung3_N Lung3_N 72 Normal
#> Lung3_T Lung3_T Lung3_T 72 Tumour
# Use tidyselect helpers
exampleTumourNormal %>%
dplyr::select(matches("s")) %>%
qsea::getSampleTable()
#> sample_name group tissue stage
#> Colon1_N Colon1_N Colon1_N Colon <NA>
#> Colon1_T Colon1_T Colon1_T Colon III
#> Colon2_N Colon2_N Colon2_N Colon <NA>
#> Colon2_T Colon2_T Colon2_T Colon IV
#> Lung1_N Lung1_N Lung1_N Lung <NA>
#> Lung1_T Lung1_T Lung1_T Lung IIA
#> Lung2_N Lung2_N Lung2_N Lung <NA>
#> Lung2_T Lung2_T Lung2_T Lung IA
#> Lung3_N Lung3_N Lung3_N Lung <NA>
#> Lung3_T Lung3_T Lung3_T Lung IB
# Negative selection (except essential columns)
exampleTumourNormal %>%
dplyr::select(-matches("s")) %>%
qsea::getSampleTable()
#> sample_name group patient type tumour age gender
#> Colon1_N Colon1_N Colon1_N Colon1 NormalColon Normal 80 F
#> Colon1_T Colon1_T Colon1_T Colon1 CRC Tumour 80 F
#> Colon2_N Colon2_N Colon2_N Colon2 NormalColon Normal 67 F
#> Colon2_T Colon2_T Colon2_T Colon2 CRC Tumour 67 F
#> Lung1_N Lung1_N Lung1_N Lung1 NormalLung Normal 64 F
#> Lung1_T Lung1_T Lung1_T Lung1 LUAD Tumour 64 F
#> Lung2_N Lung2_N Lung2_N Lung2 NormalLung Normal 71 F
#> Lung2_T Lung2_T Lung2_T Lung2 LUSC Tumour 71 F
#> Lung3_N Lung3_N Lung3_N Lung3 NormalLung Normal 72 M
#> Lung3_T Lung3_T Lung3_T Lung3 LUAD Tumour 72 M