Filter samples from a DAList
filter_samples.RdThis function is used to remove samples from a DAList, filtering using data in the metadata data frame of the DAList. Samples which do not produce a value of TRUE for the supplied condition are removed from the data, annotation, and metadata slots of the DAList. If condition evaluates to NA, the function will return an error.
Examples
if (FALSE) { # \dontrun{
# Suppose the DAList$metadata data frame contains three columns:
# sample_ID = An alpha-numeric ID uniquely identifying a sample
# treatment = A character listing the treatment group a sample belongs to
# year = A numeric value listing the year a sample was collected
# Remove a specific sample by ID
filtered <- filter_samples(DAList,
sample_ID != "abc123")
# Keep any sample which contains the string "control" in the treatment:
filtered <- filter_samples(DAList,
grepl(pattern = "control",
x = treatment))
# Remove any sample from before 2010
filtered <- filter_samples(DAList,
year >= 2010)
# Filtering functions can be chained together
filtered <- DAList |>
filter_samples(grepl(pattern = "control",
x = treatment)) |>
filter_samples(year >= 2010)
} # }