rnalysis.filtering.Filter.intersection

Filter.intersection(*others: Filter | set, return_type: Literal['set', 'str'] = 'set', inplace: bool = False)

Keep only the features that exist in ALL of the given Filter objects/sets. Can be done either inplace on the first Filter object, or return a set/string of features.

Parameters:
  • others (Filter or set objects.) – Objects to calculate intersection with.

  • return_type ('set' or 'str' (default='set')) – If β€˜set’, returns a set of the intersecting features. If β€˜str’, returns a string of the intersecting features, delimited by a comma.

  • inplace (bool (default=False)) – If True, the function will be applied in-place to the current Filter object. If False (default), the function will return a set/str that contains the intersecting indices.

Return type:

set or str

Returns:

If inplace=False, returns a set/string of the features that intersect between the given Filter objects/sets.

Examples:
>>> from rnalysis import filtering
>>> d = filtering.Filter("tests/test_files/test_deseq.csv")
>>> a_set = {'WBGene00000001','WBGene00000002','WBGene00000003'}
>>> # calculate intersection and return a set
>>> d.intersection(a_set)
{'WBGene00000002', 'WBGene00000003'}

# calculate intersection and filter in-place >>> d.intersection(a_set, inplace=True) Filtered 26 features, leaving 2 of the original 28 features. Filtered inplace.