Skip to contents

If your starting point for DAEQTL mapping is not the triad of the three data objects introduced in vignette('daeqtlr') and you need to assemble the set of SNP pairs for DAEQTL testing first, then this vignette is for you.

Here we show how to assemble a table of SNP pairs starting from:

  • a list of DAE SNPs
  • a list of candidate SNPs
  • genomic positional annotation for those SNPs

Let us read in the three data sets above from the example files bundled with this daeqtlr:

dae_snps <- read_dae_snps(file = daeqtlr_example("dae_snps.txt"))
dae_snps[1:10, ]
#> # A tibble: 10 × 1
#>    dae_snp
#>    <chr>  
#>  1 rsX019 
#>  2 rsX020 
#>  3 rsX031 
#>  4 rsX038 
#>  5 rsX041 
#>  6 rsX048 
#>  7 rsX049 
#>  8 rsX051 
#>  9 rsX058 
#> 10 rsX059

candidate_snps <-
  read_candidate_snps(file = daeqtlr_example("candidate_snps.txt"))
candidate_snps[1:10, ]
#> # A tibble: 10 × 1
#>    candidate_snp
#>    <chr>        
#>  1 rsX001       
#>  2 rsX002       
#>  3 rsX003       
#>  4 rsX004       
#>  5 rsX005       
#>  6 rsX006       
#>  7 rsX007       
#>  8 rsX008       
#>  9 rsX009       
#> 10 rsX010

snp_gen_positions <-
  read_snp_gen_positions(file = daeqtlr_example("snp_gen_positions.csv"))
snp_gen_positions[1:10, ]
#>        snp chromosome  position
#>  1: rsX001          4 177558514
#>  2: rsX002         19    442675
#>  3: rsX003         19    238404
#>  4: rsX004          4 135561143
#>  5: rsX005         19     48440
#>  6: rsX006          4  22474241
#>  7: rsX007          4 178157767
#>  8: rsX008          1 180682638
#>  9: rsX009          4  22571167
#> 10: rsX010         19     36346

We start by creating an intermediate data table (snp_table) with all the SNPs involved and their genomic positions, as well as the indication of who is a DAE SNP and who is a candidate SNP (they can be both). For that we use the function create_snp_table():

snp_table <-
  create_snp_table(snp_gen_pos = snp_gen_positions,
                   dae_snps = dae_snps,
                   candidate_snps = candidate_snps)
snp_table
#>        snp chromosome  position is_dae_snp is_candidate_snp
#>  1: rsX001          4 177558514      FALSE             TRUE
#>  2: rsX002         19    442675      FALSE             TRUE
#>  3: rsX003         19    238404      FALSE             TRUE
#>  4: rsX004          4 135561143      FALSE             TRUE
#>  5: rsX005         19     48440      FALSE             TRUE
#>  6: rsX006          4  22474241      FALSE             TRUE
#>  7: rsX007          4 178157767      FALSE             TRUE
#>  8: rsX008          1 180682638      FALSE             TRUE
#>  9: rsX009          4  22571167      FALSE             TRUE
#> 10: rsX010         19     36346      FALSE             TRUE
#> 11: rsX011          1 181006806      FALSE             TRUE
#> 12: rsX012          1 181005024      FALSE             TRUE
#> 13: rsX013          1 180709233      FALSE             TRUE
#> 14: rsX014         19    106704      FALSE             TRUE
#> 15: rsX015          1 181114464      FALSE             TRUE
#> 16: rsX016         19    160870      FALSE             TRUE
#> 17: rsX017         19    107075      FALSE             TRUE
#> 18: rsX018         19    422637      FALSE             TRUE
#> 19: rsX019         19    113462       TRUE             TRUE
#> 20: rsX020          1 181020238       TRUE             TRUE
#> 21: rsX021          1 181060085      FALSE             TRUE
#> 22: rsX022         19    599943      FALSE             TRUE
#> 23: rsX023         19    169787      FALSE             TRUE
#> 24: rsX024         19    376879      FALSE             TRUE
#> 25: rsX025         19    141544      FALSE             TRUE
#> 26: rsX026         19    402954      FALSE             TRUE
#> 27: rsX027          4 177956612      FALSE             TRUE
#> 28: rsX028          4 178073499      FALSE             TRUE
#> 29: rsX029          4  22275597      FALSE             TRUE
#> 30: rsX030          1 180744030      FALSE             TRUE
#> 31: rsX031          1 181058720       TRUE             TRUE
#> 32: rsX032          4  22861685      FALSE             TRUE
#> 33: rsX033          4  22682377      FALSE             TRUE
#> 34: rsX034         19    622636      FALSE             TRUE
#> 35: rsX035          4 135861949      FALSE             TRUE
#> 36: rsX036          4  22924223      FALSE             TRUE
#> 37: rsX037          1 181106008      FALSE             TRUE
#> 38: rsX038          4 136047668       TRUE             TRUE
#> 39: rsX039          1 180934838      FALSE             TRUE
#> 40: rsX040          1 181058949      FALSE             TRUE
#> 41: rsX041          4  22465713       TRUE             TRUE
#> 42: rsX042          4  22470182      FALSE             TRUE
#> 43: rsX043         19    190524      FALSE             TRUE
#> 44: rsX044          1 181005912      FALSE             TRUE
#> 45: rsX045         19    125316      FALSE             TRUE
#> 46: rsX046         19     99669      FALSE             TRUE
#> 47: rsX047         19    156172      FALSE             TRUE
#> 48: rsX048         19    139587       TRUE             TRUE
#> 49: rsX049          1 181040482       TRUE             TRUE
#> 50: rsX050         19    138345      FALSE             TRUE
#> 51: rsX051         19    139425       TRUE             TRUE
#> 52: rsX052          1 180575433      FALSE             TRUE
#> 53: rsX053         19    136349      FALSE             TRUE
#> 54: rsX054         19    155716      FALSE             TRUE
#> 55: rsX055          1 181116544      FALSE             TRUE
#> 56: rsX056          4 136032256      FALSE             TRUE
#> 57: rsX057          4 177971967      FALSE             TRUE
#> 58: rsX058          4 177973123       TRUE             TRUE
#> 59: rsX059          4 177973549       TRUE             TRUE
#> 60: rsX060         19    128944       TRUE             TRUE
#> 61: rsX061          1 180871514      FALSE             TRUE
#> 62: rsX062          1 181065405      FALSE             TRUE
#> 63: rsX063          4 177602406      FALSE             TRUE
#> 64: rsX064         19    598122      FALSE             TRUE
#> 65: rsX065          1 181180883      FALSE             TRUE
#> 66: rsX066          1 180708005      FALSE             TRUE
#> 67: rsX099          1 180709100       TRUE            FALSE
#>        snp chromosome  position is_dae_snp is_candidate_snp

To create the set of SNP pairs, we use the function create_snp_pairs() that takes in the snp_table. Essentially, the create_snp_pairs() searches within a genomic neighborhood of each DAE SNP for other SNPs marked as candidate SNPs. This genomic neighborhood is specified via a genomic window size centered on the DAE SNP. The window size defaults to 500 kb (window_size = 500000L), meaning a total of 1 Mb around the DAE SNP’s position (500 kb to each side).

# Assembles a data table of SNP pairs
snp_pairs <- create_snp_pairs(snp_table = snp_table)

snp_pairs
#>      dae_snp candidate_snp chromosome dae_snp_position candidate_snp_position
#>   1:  rsX099        rsX052          1        180709100              180575433
#>   2:  rsX099        rsX008          1        180709100              180682638
#>   3:  rsX099        rsX066          1        180709100              180708005
#>   4:  rsX099        rsX013          1        180709100              180709233
#>   5:  rsX099        rsX030          1        180709100              180744030
#>  ---                                                                         
#> 207:  rsX059        rsX057          4        177973549              177971967
#> 208:  rsX059        rsX058          4        177973549              177973123
#> 209:  rsX059        rsX059          4        177973549              177973549
#> 210:  rsX059        rsX028          4        177973549              178073499
#> 211:  rsX059        rsX007          4        177973549              178157767

And there you have it, the SNP pairs needed for DAEQTL mapping as explained in vignette('daeqtlr').