rnalysis.filtering.Pipeline.apply_to

Pipeline.apply_to(filter_object: Union[Filter, CountFilter, DESeqFilter, FoldChangeFilter], inplace: bool = True) Optional[Union[Filter, Tuple[Filter, dict], Tuple[Tuple[Filter], dict], dict]]

Sequentially apply all functions in the Pipeline to a given Filter object.

Parameters
  • filter_object (Filter, CountFilter, DESeqFilter, or FoldChangeFilter) – filter object to apply the Pipeline to. Type of filter_object must be identical to Pipeline.filter_type.

  • inplace (bool (default=True)) – Determines whether to apply operations in-place or not.

Returns

If inplace=False, a Filter object/tuple of Filter objects will be returned. If the functions in the Pipeline return any additional outputs, they will also be returned in a dictionary. Otherwise, nothing will be returned.

Return type

Filter object, Tuple[Filter, dict], dict, or None

Examples
>>> from rnalysis import filtering
>>> # create the pipeline
>>> pipe = filtering.Pipeline('DESeqFilter')
>>> pipe.add_function(filtering.DESeqFilter.filter_missing_values)
Added function 'DESeqFilter.filter_missing_values()' to the pipeline.
>>> pipe.add_function(filtering.DESeqFilter.filter_top_n, by='padj', n=3)
Added function 'DESeqFilter.filter_top_n(by='padj', n=3)' to the pipeline.
>>> pipe.add_function('sort', by='baseMean')
Added function 'DESeqFilter.sort(by='baseMean')' to the pipeline.
>>> # load the Filter object
>>> d = filtering.DESeqFilter('tests/test_files/test_deseq_with_nan.csv')
>>> # apply the Pipeline not-inplace
>>> d_filtered = pipe.apply_to(d, inplace=False)
Filtered 3 features, leaving 25 of the original 28 features. Filtering result saved to new object.
Filtered 22 features, leaving 3 of the original 25 features. Filtering result saved to new object.
Sorted 3 features. Sorting result saved to a new object.
>>> # apply the Pipeline inplace
>>> pipe.apply_to(d)
Filtered 3 features, leaving 25 of the original 28 features. Filtered inplace.
Filtered 22 features, leaving 3 of the original 25 features. Filtered inplace.
Sorted 3 features. Sorted inplace.