The functions will assemble a (combined) filtering function from the inputs and then apply it to features/samples from the given SingleCellExperiment object.

filter_features(object, filters, exprs_values = "counts", tolerate = 0)

filter_samples(object, filters, exprs_values = "counts", tolerate = 0)

Arguments

object

A SingleCellExperiment object.

filters

A named list. Names should be callable (filter) functions, list items should be named paramters.

exprs_values

String indicating which assay contains the data that should be used for filtering.

tolerate

A number indicating how many failed filters should be toleated.

Value

A SingleCellExperiment object with features or samples passing the filter(s).

Details

The list of filters should be of the format list("package::function" = list(...)). The filter functions described here will try to fetch the correct function from the associated package namespace before evaluation. In case several filters are given, the filter functions allow to tolerate up to tolerate failing filters. This is useful to implement OR conjuctions between filters.

Examples

# NOT RUN {
# Keep only features with an aggregated expression above 1000 counts.
obj <- filter_features(obj, list("EpOverA" = list(A = 1000)))

# Keep only features with an aggregated expression above 1000 counts and expression
# in at least in 10 samples.
obj <- filter_features(obj, list("EpOverA" = list(A = 1000), "genefilter::kOverA" = list(k=10, A=0)))

# Keep only features with an aggregated expression above 1000 counts or expression
# in at least in 10 samples (tolerate one being not met).
obj <- filter_features(obj, list("EpOverA" = list(A = 1000), "genefilter::kOverA" = list(k=10, A=0)), tolerate = 1)

# Keep only features with expression over 10 in at least 5 samples, using the fpkm assay.
obj <- filter_features(obj, list("genefilter::kOverA" = list(k=5, A=10)), exprs_values = "fpkm")

# Keep only samples that express at least 1000 features.
obj <- filter_samples(obj, list("genefilter::kOverA" = list(k = 1000, A=0))

# Keep only samples with at least 100000 counts across all features.
obj <- filter_samples(obj, list("EpOverA" = list(A = 100000)))
# }