Skip to contents

Select one or more values from each context. By default omitting an expression for a context is the same as selecting NOTHING from that context.

The <tidy-select> implementation within biocmask is almost similar to dplyr except when used within the across() function. When used from accross(), the data provided to eval_select is a zero length slice of the data. This was an intentional choice to prevent the evaluation of potentionally expensive chopping operations for S4Vectors. This means that predicate function from where() will NOT be able to query the original data.

Usage

# S3 method for class 'SummarizedExperiment'
select(.data, ...)

Arguments

.data

a SummarizedExperiment object

...

<tidy-select> one or more selection expressions. Supports wrapping expressions within the <biocmask-contexts>.

Value

an object inheriting SummarizedExperiment class

Examples



# only keep assays, other contexts are dropped
select(se_simple, everything())
#> class: SummarizedExperiment 
#> dim: 5 4 
#> metadata(0):
#> assays(2): counts logcounts
#> rownames(5): row_1 row_2 row_3 row_4 row_5
#> rowData names(0):
#> colnames(4): col_1 col_2 col_3 col_4
#> colData names(0):

# only keep rowData, other contexts are dropped
select(se_simple, rows(everything()))
#> class: SummarizedExperiment 
#> dim: 5 4 
#> metadata(0):
#> assays(0):
#> rownames(5): row_1 row_2 row_3 row_4 row_5
#> rowData names(3): gene length direction
#> colnames(4): col_1 col_2 col_3 col_4
#> colData names(0):

select(se_simple, rows(where(is.numeric)))
#> class: SummarizedExperiment 
#> dim: 5 4 
#> metadata(0):
#> assays(0):
#> rownames(5): row_1 row_2 row_3 row_4 row_5
#> rowData names(1): length
#> colnames(4): col_1 col_2 col_3 col_4
#> colData names(0):

# Note on `where()` clause, all data is available within select
select(se_simple, rows(where(~any(grepl("-", .x)))))
#> class: SummarizedExperiment 
#> dim: 5 4 
#> metadata(0):
#> assays(0):
#> rownames(5): row_1 row_2 row_3 row_4 row_5
#> rowData names(1): direction
#> colnames(4): col_1 col_2 col_3 col_4
#> colData names(0):

# within an `across()`, only a zero-length slice avialble, so the
# `where()` predicate cannot access the data
mutate(se_simple,
       rows(
        across(where(~any(grepl("-", .x))),
               ~sprintf("%s foo", .x))))
#> class: SummarizedExperiment 
#> dim: 5 4 
#> metadata(0):
#> assays(2): counts logcounts
#> rownames(5): row_1 row_2 row_3 row_4 row_5
#> rowData names(3): gene length direction
#> colnames(4): col_1 col_2 col_3 col_4
#> colData names(2): sample condition
# here is an acceptable usage of the `where()` predicate
mutate(se_simple,
       rows(
        across(where(is.character),
               ~sprintf("%s foo", .x))))
#> class: SummarizedExperiment 
#> dim: 5 4 
#> metadata(0):
#> assays(2): counts logcounts
#> rownames(5): row_1 foo row_2 foo row_3 foo row_4 foo row_5 foo
#> rowData names(3): gene length direction
#> colnames(4): col_1 col_2 col_3 col_4
#> colData names(2): sample condition