Skip to contents

The filter_dataset() function is used to select a subset of samples from a loaded TIRTLseq dataset and create a new dataset object.

Usage

filter_dataset(data, samples)

Arguments

data

a TIRTLseq dataset created by load_tirtlseq()

samples

the selected samples. Either1) a numeric vector of indices, 2) a character vector of sample names, or 3) a character vector of metadata conditions where each entry is of the form "column==value".

Value

A dataset object similar to that created by load_tirtlseq(), but with only the selected samples.

Details

The function accepts 1) a numeric vector of indices, 2) a character vector of sample names, or 3) a character vector of metadata conditions where each entry is of the form "column==value".

In the third case, c("cell_type==cd4", "timepoint==tp2") would, for example, select samples whose cell_type is cd4 and whose timepoint is tp2 in the sample metadata.

See also

Other data_wrangling: add_metadata(), load_tirtlseq(), reorder_samples()

Examples

# example code
# paired = load_tirtlseq("path_to/your_directory", sep = "_", meta_columns = c("cell_type", "timepoint"))
# p2 = filter_dataset(paired, 1:3) ### by indices
# p3 = filter_dataset(paired, c("cd8_tp1_v2", "cd8_tp2_v2", "cd8_tp3_v2")) ### by sample names
# p4 = filter_dataset(paired, "cell_type==cd4") ### by sample metadata condition
# p5 = filter_dataset(paired, c("cell_type==cd4", "timepoint==tp2")) ### by multiple sample metadata conditions