slice_sample.SummarizedExperiment: Randomly selects rows or columns

View source: R/dplyr.R

slice_sample.SummarizedExperimentR Documentation

Randomly selects rows or columns

Description

Uses a slice operation to subset

Usage

## S3 method for class 'SummarizedExperiment'
slice_sample(.data, axis, ..., n, prop)

Arguments

.data

SummarizedExperiment to subset

axis

The axis to perform the operation on. Either row or col.

...

Arguments passed to dplyr::slice_sample

n

See prop

prop

Provide either n, the number of rows, or prop, the proportion of rows to select. If neither are supplied, n = 1 will be used. If n is greater than the number of rows in the group (or prop > 1), the result will be silently truncated to the group size. prop will be rounded towards zero to generate an integer number of rows. A negative value of n or prop will be subtracted from the group size. For example, n = -2 with a group of 5 rows will select 5 - 2 = 3 rows; prop = -0.25 with 8 rows will select 8 * (1 - 0.25) = 6 rows.

Value

A SummarizedExperiment after the sample operation

Examples

# subset 5 random columns
data(seq_se)
seq_se %>% slice_sample(col, n=5)
# randomly subset 20% of rows
seq_se %>% slice_sample(row, prop=.2)

martijnvanattekum/cleanse documentation built on Nov. 20, 2023, 8:28 p.m.