Skip to contents

Performs set union, intersection, and (asymmetric!) difference on two objects of either class studies, associations, variants, or traits. Note that union() removes duplicated entities, whereas bind() does not.

Usage

union(x, y, ...)

intersect(x, y, ...)

setdiff(x, y, ...)

setequal(x, y, ...)

Arguments

x, y

Objects of either class studies, associations, variants, or traits.

...

other arguments passed on to methods.

Value

An object of the same class as x and y, i.e.,

studies, associations, variants, or traits.

Examples

#
# union()
#
# Combine studies and remove duplicates
union(studies_ex01, studies_ex02)
#> An object of class "studies"
#> Slot "studies":
#> # A tibble: 3 × 13
#>   study_id reported_trait initial_sample_size replication_sample_s…¹ gxe   gxg  
#>   <chr>    <chr>          <chr>               <chr>                  <lgl> <lgl>
#> 1 GCST001… Breast size    16,175 European an… NA                     FALSE FALSE
#> 2 GCST003… Breast size    33,790 European an… NA                     FALSE FALSE
#> 3 GCST006… Breast size    5,609 Japanese anc… NA                     FALSE FALSE
#> # ℹ abbreviated name: ¹​replication_sample_size
#> # ℹ 7 more variables: snp_count <int>, qualifier <chr>, imputed <lgl>,
#> #   pooled <lgl>, study_design_comment <chr>, full_pvalue_set <lgl>,
#> #   user_requested <lgl>
#> 
#> Slot "genotyping_techs":
#> # A tibble: 3 × 2
#>   study_id   genotyping_technology       
#>   <chr>      <chr>                       
#> 1 GCST001585 Genome-wide genotyping array
#> 2 GCST003985 Genome-wide genotyping array
#> 3 GCST006655 Genome-wide genotyping array
#> 
#> Slot "platforms":
#> # A tibble: 3 × 2
#>   study_id   manufacturer
#>   <chr>      <chr>       
#> 1 GCST001585 Illumina    
#> 2 GCST003985 Illumina    
#> 3 GCST006655 Affymetrix  
#> 
#> Slot "ancestries":
#> # A tibble: 3 × 4
#>   study_id   ancestry_id type    number_of_individuals
#>   <chr>            <int> <chr>                   <int>
#> 1 GCST001585           1 initial                 16175
#> 2 GCST003985           1 initial                 33790
#> 3 GCST006655           1 initial                  5609
#> 
#> Slot "ancestral_groups":
#> # A tibble: 3 × 3
#>   study_id   ancestry_id ancestral_group
#>   <chr>            <int> <chr>          
#> 1 GCST001585           1 European       
#> 2 GCST003985           1 European       
#> 3 GCST006655           1 East Asian     
#> 
#> Slot "countries_of_origin":
#> # A tibble: 3 × 5
#>   study_id   ancestry_id country_name major_area region
#>   <chr>            <int> <chr>        <chr>      <chr> 
#> 1 GCST001585           1 NA           NA         NA    
#> 2 GCST003985           1 NA           NA         NA    
#> 3 GCST006655           1 NA           NA         NA    
#> 
#> Slot "countries_of_recruitment":
#> # A tibble: 3 × 5
#>   study_id   ancestry_id country_name major_area region
#>   <chr>            <int> <chr>        <chr>      <chr> 
#> 1 GCST001585           1 NA           NA         NA    
#> 2 GCST003985           1 NA           NA         NA    
#> 3 GCST006655           1 NA           NA         NA    
#> 
#> Slot "publications":
#> # A tibble: 3 × 7
#>   study_id   pubmed_id publication_date publication   title      author_fullname
#>   <chr>          <int> <date>           <chr>         <chr>      <chr>          
#> 1 GCST001585  22747683 2012-06-29       BMC Med Genet Genetic v… Eriksson N     
#> 2 GCST003985  27182965 2016-05-15       Nat Genet     Detection… Pickrell JK    
#> 3 GCST006655  29855537 2018-05-30       Sci Rep       Japanese … Hirata T       
#> # ℹ 1 more variable: author_orcid <chr>
#> 

# Combine associations and remove duplicates
union(associations_ex01, associations_ex02)
#> An object of class "associations"
#> Slot "associations":
#> # A tibble: 6 × 17
#>   association_id pvalue pvalue_description pvalue_mantissa pvalue_exponent
#>   <chr>           <dbl> <chr>                        <int>           <int>
#> 1 22509           3e- 9 NA                               3              -9
#> 2 22505           7e- 6 NA                               7              -6
#> 3 19537565        7e-31 NA                               7             -31
#> 4 19537593        1e-11 NA                               1             -11
#> 5 31665940        8e- 6 NA                               8              -6
#> 6 34944736        6e- 9 NA                               6              -9
#> # ℹ 12 more variables: multiple_snp_haplotype <lgl>, snp_interaction <lgl>,
#> #   snp_type <chr>, standard_error <dbl>, range <chr>,
#> #   or_per_copy_number <dbl>, beta_number <dbl>, beta_unit <chr>,
#> #   beta_direction <chr>, beta_description <chr>, last_mapping_date <dttm>,
#> #   last_update_date <dttm>
#> 
#> Slot "loci":
#> # A tibble: 6 × 4
#>   association_id locus_id haplotype_snp_count description   
#>   <chr>             <int>               <int> <chr>         
#> 1 22509                 1                  NA Single variant
#> 2 22505                 1                  NA Single variant
#> 3 19537565              1                  NA Single variant
#> 4 19537593              1                  NA Single variant
#> 5 31665940              1                  NA Single variant
#> 6 34944736              1                  NA Single variant
#> 
#> Slot "risk_alleles":
#> # A tibble: 6 × 7
#>   association_id locus_id variant_id     risk_allele risk_frequency genome_wide
#>   <chr>             <int> <chr>          <chr>                <dbl> <lgl>      
#> 1 22509                 1 rs7089814      C                   NA     NA         
#> 2 22505                 1 chr22:45895495 T                   NA     NA         
#> 3 19537565              1 rs10110651     NA                  NA     FALSE      
#> 4 19537593              1 rs9397437      NA                  NA     FALSE      
#> 5 31665940              1 rs985648       G                    0.248 FALSE      
#> 6 34944736              1 rs146992477    TTCTTTCTTTC          0.381 FALSE      
#> # ℹ 1 more variable: limited_list <lgl>
#> 
#> Slot "genes":
#> # A tibble: 11 × 3
#>    association_id locus_id gene_name   
#>    <chr>             <int> <chr>       
#>  1 22509                 1 ADO         
#>  2 22509                 1 ZNF365      
#>  3 22509                 1 ALDH7A1P4   
#>  4 22505                 1 TBC1D22A    
#>  5 22505                 1 LOC100128818
#>  6 19537565              1 KCNU1       
#>  7 19537565              1 ZNF703      
#>  8 19537593              1 CCDC170     
#>  9 19537593              1 ESR1        
#> 10 31665940              1 NA          
#> 11 34944736              1 KCNU1       
#> 
#> Slot "ensembl_ids":
#> # A tibble: 11 × 4
#>    association_id locus_id gene_name    ensembl_id     
#>    <chr>             <int> <chr>        <chr>          
#>  1 22509                 1 ADO          ENSG00000181915
#>  2 22509                 1 ZNF365       ENSG00000138311
#>  3 22509                 1 ALDH7A1P4    ENSG00000234489
#>  4 22505                 1 TBC1D22A     ENSG00000054611
#>  5 22505                 1 LOC100128818 NA             
#>  6 19537565              1 KCNU1        ENSG00000215262
#>  7 19537565              1 ZNF703       ENSG00000183779
#>  8 19537593              1 CCDC170      ENSG00000120262
#>  9 19537593              1 ESR1         ENSG00000091831
#> 10 31665940              1 NA           NA             
#> 11 34944736              1 KCNU1        ENSG00000215262
#> 
#> Slot "entrez_ids":
#> # A tibble: 11 × 4
#>    association_id locus_id gene_name    entrez_id
#>    <chr>             <int> <chr>        <chr>    
#>  1 22509                 1 ADO          84890    
#>  2 22509                 1 ZNF365       22891    
#>  3 22509                 1 ALDH7A1P4    544      
#>  4 22505                 1 TBC1D22A     25771    
#>  5 22505                 1 LOC100128818 NA       
#>  6 19537565              1 KCNU1        157855   
#>  7 19537565              1 ZNF703       80139    
#>  8 19537593              1 CCDC170      80129    
#>  9 19537593              1 ESR1         2099     
#> 10 31665940              1 NA           NA       
#> 11 34944736              1 KCNU1        157855   
#> 

# Combine variants and remove duplicates
union(variants_ex01, variants_ex02)
#> An object of class "variants"
#> Slot "variants":
#> # A tibble: 5 × 7
#>   variant_id  merged functional_class        chromosome_name chromosome_position
#>   <chr>        <int> <chr>                   <chr>                         <int>
#> 1 rs146992477      0 regulatory_region_vari… 8                          36984538
#> 2 rs56261590       0 intron_variant          4                          73189781
#> 3 rs4725504        0 intergenic_variant      7                         153608338
#> 4 rs11099757       0 intron_variant          4                         150143216
#> 5 rs16871509       0 intergenic_variant      5                          71726395
#> # ℹ 2 more variables: chromosome_region <chr>, last_update_date <dttm>
#> 
#> Slot "genomic_contexts":
#> # A tibble: 33 × 11
#>    variant_id  gene_name    chromosome_name chromosome_position distance
#>    <chr>       <chr>        <chr>                         <int>    <int>
#>  1 rs146992477 LOC105379377 8                          36984538    81555
#>  2 rs146992477 KCNU1        8                          36984538    48413
#>  3 rs146992477 LOC105379376 8                          36984538     2533
#>  4 rs146992477 TPT1P8       8                          36984538    95231
#>  5 rs146992477 RPL26P25     8                          36984538     3392
#>  6 rs146992477 KCNU1        8                          36984538    48413
#>  7 rs146992477 AC090453.1   8                          36984538     3439
#>  8 rs146992477 TPT1P8       8                          36984538    95008
#>  9 rs146992477 AC092818.1   8                          36984538    82903
#> 10 rs146992477 LOC105379375 8                          36984538    59331
#> # ℹ 23 more rows
#> # ℹ 6 more variables: is_closest_gene <lgl>, is_intergenic <lgl>,
#> #   is_upstream <lgl>, is_downstream <lgl>, source <chr>, mapping_method <chr>
#> 
#> Slot "ensembl_ids":
#> # A tibble: 17 × 3
#>    variant_id  gene_name  ensembl_id     
#>    <chr>       <chr>      <chr>          
#>  1 rs146992477 KCNU1      ENSG00000215262
#>  2 rs146992477 TPT1P8     ENSG00000219491
#>  3 rs146992477 AC090453.1 ENSG00000243503
#>  4 rs146992477 AC092818.1 ENSG00000254038
#>  5 rs56261590  ANKRD17    ENSG00000132466
#>  6 rs56261590  HMGA1P2    ENSG00000248641
#>  7 rs56261590  AC053527.1 ENSG00000250220
#>  8 rs56261590  RF00334    ENSG00000221093
#>  9 rs4725504   DPP6       ENSG00000130226
#> 10 rs4725504   PAXBP1P1   ENSG00000233489
#> 11 rs11099757  RNU7-194P  ENSG00000238721
#> 12 rs11099757  DCLK2      ENSG00000170390
#> 13 rs11099757  RNU6-1230P ENSG00000207121
#> 14 rs11099757  AC105343.1 ENSG00000250704
#> 15 rs16871509  AC143336.1 ENSG00000278824
#> 16 rs16871509  CARTPT     ENSG00000164326
#> 17 rs16871509  MCCC2      ENSG00000131844
#> 
#> Slot "entrez_ids":
#> # A tibble: 18 × 3
#>    variant_id  gene_name    entrez_id
#>    <chr>       <chr>        <chr>    
#>  1 rs146992477 LOC105379377 105379377
#>  2 rs146992477 KCNU1        157855   
#>  3 rs146992477 LOC105379376 105379376
#>  4 rs146992477 TPT1P8       59347    
#>  5 rs146992477 RPL26P25     100270966
#>  6 rs146992477 LOC105379375 105379375
#>  7 rs56261590  ANKRD17      26057    
#>  8 rs56261590  HMGA1P2      171559   
#>  9 rs56261590  LOC102724832 102724832
#> 10 rs4725504   DPP6         1804     
#> 11 rs4725504   PAXBP1P1     106481704
#> 12 rs4725504   LOC107986750 107986750
#> 13 rs11099757  RNU7-194P    106480834
#> 14 rs11099757  DCLK2        166614   
#> 15 rs11099757  RNU6-1230P   106481944
#> 16 rs16871509  CARTPT       9607     
#> 17 rs16871509  MCCC2        64087    
#> 18 rs16871509  LOC100422013 100422013
#> 

# Combine traits and remove duplicates
union(traits_ex01, traits_ex02)
#> An object of class "traits"
#> Slot "traits":
#> # A tibble: 6 × 3
#>   efo_id      trait                      uri                                 
#>   <chr>       <chr>                      <chr>                               
#> 1 EFO_0004884 breast size                http://www.ebi.ac.uk/efo/EFO_0004884
#> 2 EFO_0004343 waist-hip ratio            http://www.ebi.ac.uk/efo/EFO_0004343
#> 3 EFO_0005299 non-word reading           http://www.ebi.ac.uk/efo/EFO_0005299
#> 4 EFO_0007845 lip morphology measurement http://www.ebi.ac.uk/efo/EFO_0007845
#> 5 EFO_0004699 gambling                   http://www.ebi.ac.uk/efo/EFO_0004699
#> 6 EFO_0004875 mathematical ability       http://www.ebi.ac.uk/efo/EFO_0004875
#> 

#
# intersect()
#
# Intersect common studies
intersect(studies_ex01, studies_ex02)
#> An object of class "studies"
#> Slot "studies":
#> # A tibble: 1 × 13
#>   study_id reported_trait initial_sample_size replication_sample_s…¹ gxe   gxg  
#>   <chr>    <chr>          <chr>               <chr>                  <lgl> <lgl>
#> 1 GCST001… Breast size    16,175 European an… NA                     FALSE FALSE
#> # ℹ abbreviated name: ¹​replication_sample_size
#> # ℹ 7 more variables: snp_count <int>, qualifier <chr>, imputed <lgl>,
#> #   pooled <lgl>, study_design_comment <chr>, full_pvalue_set <lgl>,
#> #   user_requested <lgl>
#> 
#> Slot "genotyping_techs":
#> # A tibble: 1 × 2
#>   study_id   genotyping_technology       
#>   <chr>      <chr>                       
#> 1 GCST001585 Genome-wide genotyping array
#> 
#> Slot "platforms":
#> # A tibble: 1 × 2
#>   study_id   manufacturer
#>   <chr>      <chr>       
#> 1 GCST001585 Illumina    
#> 
#> Slot "ancestries":
#> # A tibble: 1 × 4
#>   study_id   ancestry_id type    number_of_individuals
#>   <chr>            <int> <chr>                   <int>
#> 1 GCST001585           1 initial                 16175
#> 
#> Slot "ancestral_groups":
#> # A tibble: 1 × 3
#>   study_id   ancestry_id ancestral_group
#>   <chr>            <int> <chr>          
#> 1 GCST001585           1 European       
#> 
#> Slot "countries_of_origin":
#> # A tibble: 1 × 5
#>   study_id   ancestry_id country_name major_area region
#>   <chr>            <int> <chr>        <chr>      <chr> 
#> 1 GCST001585           1 NA           NA         NA    
#> 
#> Slot "countries_of_recruitment":
#> # A tibble: 1 × 5
#>   study_id   ancestry_id country_name major_area region
#>   <chr>            <int> <chr>        <chr>      <chr> 
#> 1 GCST001585           1 NA           NA         NA    
#> 
#> Slot "publications":
#> # A tibble: 1 × 7
#>   study_id   pubmed_id publication_date publication   title      author_fullname
#>   <chr>          <int> <date>           <chr>         <chr>      <chr>          
#> 1 GCST001585  22747683 2012-06-29       BMC Med Genet Genetic v… Eriksson N     
#> # ℹ 1 more variable: author_orcid <chr>
#> 

# Intersect common associations
intersect(associations_ex01, associations_ex02)
#> An object of class "associations"
#> Slot "associations":
#> # A tibble: 1 × 17
#>   association_id       pvalue pvalue_description pvalue_mantissa pvalue_exponent
#>   <chr>                 <dbl> <chr>                        <int>           <int>
#> 1 19537593              1e-11 NA                               1             -11
#> # ℹ 12 more variables: multiple_snp_haplotype <lgl>, snp_interaction <lgl>,
#> #   snp_type <chr>, standard_error <dbl>, range <chr>,
#> #   or_per_copy_number <dbl>, beta_number <dbl>, beta_unit <chr>,
#> #   beta_direction <chr>, beta_description <chr>, last_mapping_date <dttm>,
#> #   last_update_date <dttm>
#> 
#> Slot "loci":
#> # A tibble: 1 × 4
#>   association_id locus_id haplotype_snp_count description   
#>   <chr>             <int>               <int> <chr>         
#> 1 19537593              1                  NA Single variant
#> 
#> Slot "risk_alleles":
#> # A tibble: 1 × 7
#>   association_id locus_id variant_id risk_allele risk_frequency genome_wide
#>   <chr>             <int> <chr>      <chr>                <dbl> <lgl>      
#> 1 19537593              1 rs9397437  NA                      NA FALSE      
#> # ℹ 1 more variable: limited_list <lgl>
#> 
#> Slot "genes":
#> # A tibble: 2 × 3
#>   association_id locus_id gene_name
#>   <chr>             <int> <chr>    
#> 1 19537593              1 CCDC170  
#> 2 19537593              1 ESR1     
#> 
#> Slot "ensembl_ids":
#> # A tibble: 2 × 4
#>   association_id locus_id gene_name ensembl_id     
#>   <chr>             <int> <chr>     <chr>          
#> 1 19537593              1 CCDC170   ENSG00000120262
#> 2 19537593              1 ESR1      ENSG00000091831
#> 
#> Slot "entrez_ids":
#> # A tibble: 2 × 4
#>   association_id locus_id gene_name entrez_id
#>   <chr>             <int> <chr>     <chr>    
#> 1 19537593              1 CCDC170   80129    
#> 2 19537593              1 ESR1      2099     
#> 

# Intersect common variants
intersect(variants_ex01, variants_ex02)
#> An object of class "variants"
#> Slot "variants":
#> # A tibble: 2 × 7
#>   variant_id merged functional_class   chromosome_name chromosome_position
#>   <chr>       <int> <chr>              <chr>                         <int>
#> 1 rs56261590      0 intron_variant     4                          73189781
#> 2 rs4725504       0 intergenic_variant 7                         153608338
#> # ℹ 2 more variables: chromosome_region <chr>, last_update_date <dttm>
#> 
#> Slot "genomic_contexts":
#> # A tibble: 11 × 11
#>    variant_id gene_name    chromosome_name chromosome_position distance
#>    <chr>      <chr>        <chr>                         <int>    <int>
#>  1 rs56261590 ANKRD17      4                          73189781        0
#>  2 rs56261590 ANKRD17      4                          73189781        0
#>  3 rs56261590 HMGA1P2      4                          73189781    90636
#>  4 rs56261590 HMGA1P2      4                          73189781    89275
#>  5 rs56261590 LOC102724832 4                          73189781    69394
#>  6 rs56261590 AC053527.1   4                          73189781    69428
#>  7 rs56261590 RF00334      4                          73189781    74179
#>  8 rs4725504  DPP6         7                         153608338   278759
#>  9 rs4725504  DPP6         7                         153608338   139795
#> 10 rs4725504  PAXBP1P1     7                         153608338   158463
#> 11 rs4725504  LOC107986750 7                         153608338    84107
#> # ℹ 6 more variables: is_closest_gene <lgl>, is_intergenic <lgl>,
#> #   is_upstream <lgl>, is_downstream <lgl>, source <chr>, mapping_method <chr>
#> 
#> Slot "ensembl_ids":
#> # A tibble: 6 × 3
#>   variant_id gene_name  ensembl_id     
#>   <chr>      <chr>      <chr>          
#> 1 rs56261590 ANKRD17    ENSG00000132466
#> 2 rs56261590 HMGA1P2    ENSG00000248641
#> 3 rs56261590 AC053527.1 ENSG00000250220
#> 4 rs56261590 RF00334    ENSG00000221093
#> 5 rs4725504  DPP6       ENSG00000130226
#> 6 rs4725504  PAXBP1P1   ENSG00000233489
#> 
#> Slot "entrez_ids":
#> # A tibble: 6 × 3
#>   variant_id gene_name    entrez_id
#>   <chr>      <chr>        <chr>    
#> 1 rs56261590 ANKRD17      26057    
#> 2 rs56261590 HMGA1P2      171559   
#> 3 rs56261590 LOC102724832 102724832
#> 4 rs4725504  DPP6         1804     
#> 5 rs4725504  PAXBP1P1     106481704
#> 6 rs4725504  LOC107986750 107986750
#> 

# Intersect common traits
intersect(traits_ex01, traits_ex02)
#> An object of class "traits"
#> Slot "traits":
#> # A tibble: 1 × 3
#>   efo_id      trait       uri                                 
#>   <chr>       <chr>       <chr>                               
#> 1 EFO_0004884 breast size http://www.ebi.ac.uk/efo/EFO_0004884
#> 

#
# setdiff()
#
# Remove studies from ex01 that are also present in ex02
setdiff(studies_ex01, studies_ex02)
#> An object of class "studies"
#> Slot "studies":
#> # A tibble: 1 × 13
#>   study_id reported_trait initial_sample_size replication_sample_s…¹ gxe   gxg  
#>   <chr>    <chr>          <chr>               <chr>                  <lgl> <lgl>
#> 1 GCST003… Breast size    33,790 European an… NA                     FALSE FALSE
#> # ℹ abbreviated name: ¹​replication_sample_size
#> # ℹ 7 more variables: snp_count <int>, qualifier <chr>, imputed <lgl>,
#> #   pooled <lgl>, study_design_comment <chr>, full_pvalue_set <lgl>,
#> #   user_requested <lgl>
#> 
#> Slot "genotyping_techs":
#> # A tibble: 1 × 2
#>   study_id   genotyping_technology       
#>   <chr>      <chr>                       
#> 1 GCST003985 Genome-wide genotyping array
#> 
#> Slot "platforms":
#> # A tibble: 1 × 2
#>   study_id   manufacturer
#>   <chr>      <chr>       
#> 1 GCST003985 Illumina    
#> 
#> Slot "ancestries":
#> # A tibble: 1 × 4
#>   study_id   ancestry_id type    number_of_individuals
#>   <chr>            <int> <chr>                   <int>
#> 1 GCST003985           1 initial                 33790
#> 
#> Slot "ancestral_groups":
#> # A tibble: 1 × 3
#>   study_id   ancestry_id ancestral_group
#>   <chr>            <int> <chr>          
#> 1 GCST003985           1 European       
#> 
#> Slot "countries_of_origin":
#> # A tibble: 1 × 5
#>   study_id   ancestry_id country_name major_area region
#>   <chr>            <int> <chr>        <chr>      <chr> 
#> 1 GCST003985           1 NA           NA         NA    
#> 
#> Slot "countries_of_recruitment":
#> # A tibble: 1 × 5
#>   study_id   ancestry_id country_name major_area region
#>   <chr>            <int> <chr>        <chr>      <chr> 
#> 1 GCST003985           1 NA           NA         NA    
#> 
#> Slot "publications":
#> # A tibble: 1 × 7
#>   study_id   pubmed_id publication_date publication title        author_fullname
#>   <chr>          <int> <date>           <chr>       <chr>        <chr>          
#> 1 GCST003985  27182965 2016-05-15       Nat Genet   Detection a… Pickrell JK    
#> # ℹ 1 more variable: author_orcid <chr>
#> 

# Remove associations from ex01 that are also present in ex02
setdiff(associations_ex01, associations_ex02)
#> An object of class "associations"
#> Slot "associations":
#> # A tibble: 3 × 17
#>   association_id pvalue pvalue_description pvalue_mantissa pvalue_exponent
#>   <chr>           <dbl> <chr>                        <int>           <int>
#> 1 22509           3e- 9 NA                               3              -9
#> 2 22505           7e- 6 NA                               7              -6
#> 3 19537565        7e-31 NA                               7             -31
#> # ℹ 12 more variables: multiple_snp_haplotype <lgl>, snp_interaction <lgl>,
#> #   snp_type <chr>, standard_error <dbl>, range <chr>,
#> #   or_per_copy_number <dbl>, beta_number <dbl>, beta_unit <chr>,
#> #   beta_direction <chr>, beta_description <chr>, last_mapping_date <dttm>,
#> #   last_update_date <dttm>
#> 
#> Slot "loci":
#> # A tibble: 3 × 4
#>   association_id locus_id haplotype_snp_count description   
#>   <chr>             <int>               <int> <chr>         
#> 1 22509                 1                  NA Single variant
#> 2 22505                 1                  NA Single variant
#> 3 19537565              1                  NA Single variant
#> 
#> Slot "risk_alleles":
#> # A tibble: 3 × 7
#>   association_id locus_id variant_id     risk_allele risk_frequency genome_wide
#>   <chr>             <int> <chr>          <chr>                <dbl> <lgl>      
#> 1 22509                 1 rs7089814      C                       NA NA         
#> 2 22505                 1 chr22:45895495 T                       NA NA         
#> 3 19537565              1 rs10110651     NA                      NA FALSE      
#> # ℹ 1 more variable: limited_list <lgl>
#> 
#> Slot "genes":
#> # A tibble: 7 × 3
#>   association_id locus_id gene_name   
#>   <chr>             <int> <chr>       
#> 1 22509                 1 ADO         
#> 2 22509                 1 ZNF365      
#> 3 22509                 1 ALDH7A1P4   
#> 4 22505                 1 TBC1D22A    
#> 5 22505                 1 LOC100128818
#> 6 19537565              1 KCNU1       
#> 7 19537565              1 ZNF703      
#> 
#> Slot "ensembl_ids":
#> # A tibble: 7 × 4
#>   association_id locus_id gene_name    ensembl_id     
#>   <chr>             <int> <chr>        <chr>          
#> 1 22509                 1 ADO          ENSG00000181915
#> 2 22509                 1 ZNF365       ENSG00000138311
#> 3 22509                 1 ALDH7A1P4    ENSG00000234489
#> 4 22505                 1 TBC1D22A     ENSG00000054611
#> 5 22505                 1 LOC100128818 NA             
#> 6 19537565              1 KCNU1        ENSG00000215262
#> 7 19537565              1 ZNF703       ENSG00000183779
#> 
#> Slot "entrez_ids":
#> # A tibble: 7 × 4
#>   association_id locus_id gene_name    entrez_id
#>   <chr>             <int> <chr>        <chr>    
#> 1 22509                 1 ADO          84890    
#> 2 22509                 1 ZNF365       22891    
#> 3 22509                 1 ALDH7A1P4    544      
#> 4 22505                 1 TBC1D22A     25771    
#> 5 22505                 1 LOC100128818 NA       
#> 6 19537565              1 KCNU1        157855   
#> 7 19537565              1 ZNF703       80139    
#> 

# Remove variants from ex01 that are also present in ex02
setdiff(variants_ex01, variants_ex02)
#> An object of class "variants"
#> Slot "variants":
#> # A tibble: 1 × 7
#>   variant_id  merged functional_class        chromosome_name chromosome_position
#>   <chr>        <int> <chr>                   <chr>                         <int>
#> 1 rs146992477      0 regulatory_region_vari… 8                          36984538
#> # ℹ 2 more variables: chromosome_region <chr>, last_update_date <dttm>
#> 
#> Slot "genomic_contexts":
#> # A tibble: 10 × 11
#>    variant_id  gene_name    chromosome_name chromosome_position distance
#>    <chr>       <chr>        <chr>                         <int>    <int>
#>  1 rs146992477 LOC105379377 8                          36984538    81555
#>  2 rs146992477 KCNU1        8                          36984538    48413
#>  3 rs146992477 LOC105379376 8                          36984538     2533
#>  4 rs146992477 TPT1P8       8                          36984538    95231
#>  5 rs146992477 RPL26P25     8                          36984538     3392
#>  6 rs146992477 KCNU1        8                          36984538    48413
#>  7 rs146992477 AC090453.1   8                          36984538     3439
#>  8 rs146992477 TPT1P8       8                          36984538    95008
#>  9 rs146992477 AC092818.1   8                          36984538    82903
#> 10 rs146992477 LOC105379375 8                          36984538    59331
#> # ℹ 6 more variables: is_closest_gene <lgl>, is_intergenic <lgl>,
#> #   is_upstream <lgl>, is_downstream <lgl>, source <chr>, mapping_method <chr>
#> 
#> Slot "ensembl_ids":
#> # A tibble: 4 × 3
#>   variant_id  gene_name  ensembl_id     
#>   <chr>       <chr>      <chr>          
#> 1 rs146992477 KCNU1      ENSG00000215262
#> 2 rs146992477 TPT1P8     ENSG00000219491
#> 3 rs146992477 AC090453.1 ENSG00000243503
#> 4 rs146992477 AC092818.1 ENSG00000254038
#> 
#> Slot "entrez_ids":
#> # A tibble: 6 × 3
#>   variant_id  gene_name    entrez_id
#>   <chr>       <chr>        <chr>    
#> 1 rs146992477 LOC105379377 105379377
#> 2 rs146992477 KCNU1        157855   
#> 3 rs146992477 LOC105379376 105379376
#> 4 rs146992477 TPT1P8       59347    
#> 5 rs146992477 RPL26P25     100270966
#> 6 rs146992477 LOC105379375 105379375
#> 

# Remove traits from ex01 that are also present in ex02
setdiff(traits_ex01, traits_ex02)
#> An object of class "traits"
#> Slot "traits":
#> # A tibble: 2 × 3
#>   efo_id      trait            uri                                 
#>   <chr>       <chr>            <chr>                               
#> 1 EFO_0004343 waist-hip ratio  http://www.ebi.ac.uk/efo/EFO_0004343
#> 2 EFO_0005299 non-word reading http://www.ebi.ac.uk/efo/EFO_0005299
#> 

#
# setequal()
#
# Compare two studies objects
setequal(studies_ex01, studies_ex01)
#> [1] TRUE
setequal(studies_ex01, studies_ex02)
#> [1] FALSE

# Compare two associations objects
setequal(associations_ex01, associations_ex01)
#> [1] TRUE
setequal(associations_ex01, associations_ex02)
#> [1] FALSE

# Compare two variants objects
setequal(variants_ex01, variants_ex01)
#> [1] TRUE
setequal(variants_ex01, variants_ex02)
#> [1] FALSE

# Compare two traits objects
setequal(traits_ex01, traits_ex01)
#> [1] TRUE
setequal(traits_ex01, traits_ex02)
#> [1] FALSE