rnalysis.filtering.CountFilter.differenceο
- CountFilter.difference(*others: Filter | set, return_type: Literal['set', 'str'] = 'set', inplace: bool = False)ο
Keep only the features that exist in the first Filter object/set but NOT in the others. Can be done inplace on the first Filter object, or return a set/string of features.
- Parameters:
others (Filter or set objects.) β Objects to calculate difference with.
return_type ('set' or 'str' (default='set')) β If βsetβ, returns a set of the features that exist only in the first Filter object. If βstrβ, returns a string of the WBGene indices that exist only in the first Filter object, delimited by a comma.
inplace (bool, default False) β If True, filtering will be applied to the current Filter object. If False (default), the function will return a set/str that contains the intersecting features.
- Return type:
set or str
- Returns:
If inplace=False, returns a set/string of the features that exist only in the first Filter object/set (set difference).
- Examples:
>>> from rnalysis import filtering >>> d = filtering.DESeqFilter("tests/test_files/test_deseq.csv") >>> counts = filtering.CountFilter('tests/test_files/counted.csv') >>> a_set = {'WBGene00000001','WBGene00000002','WBGene00000003'} >>> # calculate difference and return a set >>> d.difference(counts, a_set) {'WBGene00007063', 'WBGene00007064', 'WBGene00007066', 'WBGene00007067', 'WBGene00007069', 'WBGene00007071', 'WBGene00007074', 'WBGene00007075', 'WBGene00007076', 'WBGene00007077', 'WBGene00007078', 'WBGene00007079', 'WBGene00014997', 'WBGene00043987', 'WBGene00043988', 'WBGene00043989', 'WBGene00043990', 'WBGene00044022', 'WBGene00044951', 'WBGene00077502', 'WBGene00077503', 'WBGene00077504'}
# calculate difference and filter in-place >>> d.difference(counts, a_set, inplace=True) Filtered 2 features, leaving 26 of the original 28 features. Filtered inplace.