filter: Functions to filter features or samples using 'genefilter'.

Description Usage Arguments Details Value Examples

Description

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

Usage

1
2
3
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.

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.

Value

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## 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)))

## End(Not run)

jenzopr/singlecellutils documentation built on June 12, 2019, 2:51 a.m.