Setting up filters
Filters can be easily configured based on a filter table, making it easy to template sets of operations. Filters are NOT applied sequentially, but run independently. If you do want to run filters in sequentially, you will have to run successive iterations, but this is easy enough to do. An easy way to maintain filters and edit them is to store them in a google sheet and load them into R. Then using the function tglow_filters_from_table to create the filter objects. The filter table should have the following columns, and one sheet for feature level filters, and one for object level filters. Exact layouts are customizable, see the help of tglow_filters_from_table. The filtering is customizable using grep patterns, so you can specify which filter is applied to which features.
There are two flavors of filters:
filter_vec_x: Accepts a vector and returns a logical vector of the same length (i.e. 'which objects for this feature are > 0')filter_agg_x: Accepts a vector and aggregates on a statistic and returns a single logical (i.e 'is the variance of this feature > 0')
Then there are the filter modifiers
filter_vec_x_sum: Applies the filter to multiple columns, returning a logical of nrow(input), where T only if all columns for that row are T, otherwise Ffilter_agg_x_multicol: Applies a filter to data with multiple columns and returns a logical vector of ncol(input). If you want to apply these at the object level (i.e. 'filter objects with >x% of NA features'), make sure to settranspose=Tin the filter definition, if you want to filter features (i.e. 'filter features with >x% of NA objects') leavetranspose=F.
Filtering example
Filter objects where _mito features have more then 50% NA's and overall features objects have no more then 10% NA's. Another example can be found in /vingettes/example.r
Defining custom filters
You can also define custom filters at runtime by loading a new function into the global environment. Just make sure it has the following signature function(vec, thresh, grouping)
Available filters
Using manual filters
It is also fully possible to manually filter things using slicing. For example to filter NA's for the feature cell_centroid_x on the @meta slot you can simply:
This will create a new dataset with the objects filtered out.
The same can work for features, but these are filtered on the assay level, as each assay can have different number of features