Set operations for objects of same class
# set operation in EFO Trait
from pandasgwas.get_traits import get_traits
from pandasgwas.set_operation import *
traits1 = get_traits(study_id='GCST000854', efo_id='EFO_0001065')
traits2 = get_traits(study_id='GCST000854', efo_uri='http://www.ebi.ac.uk/efo/EFO_0005133')
#Equivalent to traits3 = traits1 + traits2
traits3 = bind(traits1, traits2)
traits1 = get_traits(study_id='GCST000854', efo_id='EFO_0001065')
traits2 = get_traits(study_id='GCST000854', efo_uri='http://www.ebi.ac.uk/efo/EFO_0005133')
#Equivalent to traits3 = traits1 & traits2
traits3 = intersect(traits1, traits2)
traits1 = get_traits(study_id='GCST000854', efo_id='EFO_0001065')
traits2 = get_traits(study_id='GCST000854', efo_uri='http://www.ebi.ac.uk/efo/EFO_0005133')
#Equivalent to traits3 = traits1 - traits2
traits3 = set_diff(traits1, traits2)
traits1 = get_traits(study_id='GCST000854', efo_id='EFO_0001065')
traits2 = get_traits(study_id='GCST000854', efo_uri='http://www.ebi.ac.uk/efo/EFO_0005133')
#Equivalent to traits3 = traits1 ^ traits2
traits3 = set_xor(traits1, traits2)
traits1 = get_traits(study_id='GCST000854', efo_id='EFO_0001065')
traits2 = get_traits(study_id='GCST000854', efo_uri='http://www.ebi.ac.uk/efo/EFO_0005133')
#Equivalent to traits3 = traits1 | traits2
traits3 = union(traits1, traits2)
traits1 = get_traits(study_id='GCST000854')
traits2 = get_traits(study_id='GCST000854')
#Equivalent to traits1 == traits2
set_equal(traits1, traits2)
bind
bind(
a: Union[Association, Variant, Study, Trait],
b: Union[Association, Variant, Study, Trait],
) -> Union[Association, Variant, Study, Trait]
Binds together GWAS Catalog objects of the same class. Note that bind() preserves duplicates whereas union() does not.
intersect
intersect(
a: Union[Association, Variant, Study, Trait],
b: Union[Association, Variant, Study, Trait],
) -> Union[Association, Variant, Study, Trait]
Returns the data common to both A and B, with no repetitions
set_diff
set_diff(
a: Union[Association, Variant, Study, Trait],
b: Union[Association, Variant, Study, Trait],
) -> Union[Association, Variant, Study, Trait]
Returns the data in A that is not in B, with no repetitions
set_equal
set_equal(
a: Union[Association, Variant, Study, Trait],
b: Union[Association, Variant, Study, Trait],
) -> bool
Check if the raw data of a and b are equal
set_xor
set_xor(
a: Union[Association, Variant, Study, Trait],
b: Union[Association, Variant, Study, Trait],
) -> Union[Association, Variant, Study, Trait]
Returns the data of A and B that are not in their intersection (the symmetric difference), with no repetitions
union
union(
a: Union[Association, Variant, Study, Trait],
b: Union[Association, Variant, Study, Trait],
) -> Union[Association, Variant, Study, Trait]
Returns the combined data from A and B with no repetitions