List of Variants to GWAS associations
Closed this issue · 3 comments
lizlitkowski commented
Hi -- Is there a function where I can specify a list of variants and get back a list of traits those variants have been associated with in GWAS studies?
Thanks.
Liz
ramiromagno commented
Hi Liz,
One variant can be implicated in many associations and each association associated with a single trait. Because the mapping from variants to associations is one to many, in {gwasrapidd}
we have to take this path of mapping from variants to associations to traits explicitly... In the future I might implement this in a more straightforward way for the user (apologies for that!).
For the moment the following code should do the trick:
library(gwasrapidd)
library(tidyverse)
# Adapt `my_variants` to be a vector of your variants
my_variants <- c("rs7329174", "rs3798440")
my_variants <- setNames(my_variants, nm = my_variants)
lst <- purrr::map(my_variants, ~ get_associations(variant_id = .x)@associations[, "association_id"])
var_to_assoc <- purrr::list_rbind(lst, names_to = "variant_id")
my_associations <- var_to_assoc$association_id
my_associations <- setNames(my_associations, nm = my_associations)
lst2 <- purrr::map(my_associations, ~ get_traits(association_id = .x)@traits[, c("efo_id", "trait")])
assoc_to_trait <- purrr::list_rbind(lst2, names_to = "association_id")
left_join(var_to_assoc, assoc_to_trait, by = "association_id")
#> # A tibble: 7 × 4
#> variant_id association_id efo_id trait
#> <chr> <chr> <chr> <chr>
#> 1 rs7329174 16617 MONDO_0007915 systemic lupus erythematosus
#> 2 rs7329174 26451 EFO_0000384 crohn's disease
#> 3 rs7329174 26394 MONDO_0007915 systemic lupus erythematosus
#> 4 rs7329174 92481688 MONDO_0007915 systemic lupus erythematosus
#> 5 rs7329174 17433639 MONDO_0007915 systemic lupus erythematosus
#> 6 rs7329174 103267749 EFO_0004339 body height
#> 7 rs3798440 24299710 EFO_0000537 hypertension
lizlitkowski commented
Hi Ramiro,
Thank you so much.
This is exactly what I am looking for!
I ran it for my 331 SNPs and it only took about 10-15 minutes.
I will be keeping this in my bag of tricks.
Thank you!!!!
Best,
Liz
…On Tue, May 16, 2023 at 8:05 PM Ramiro Magno ***@***.***> wrote:
[External Email - Use Caution]
Hi Liz,
One variant can be implicated in many associations and each association
associated with a single trait. Because the mapping from variants to
associations is one to many, in {gwasrapidd} we have to take this path of
mapping from variants to associations to traits explicitly... In the future
I might implement this in a more straightforward way for the user
(apologies for that!).
For the moment the following code should do the trick:
library(gwasrapidd)
library(tidyverse)
# Adapt `my_variants` to be a vector of your variantsmy_variants <- c("rs7329174", "rs3798440")my_variants <- setNames(my_variants, nm = my_variants)
lst <- purrr::map(my_variants, ~ get_associations(variant_id = .***@***.***[, "association_id"])var_to_assoc <- purrr::list_rbind(lst, names_to = "variant_id")
my_associations <- var_to_assoc$association_idmy_associations <- setNames(my_associations, nm = my_associations)lst2 <- purrr::map(my_associations, ~ get_traits(association_id = .***@***.***[, c("efo_id", "trait")])assoc_to_trait <- purrr::list_rbind(lst2, names_to = "association_id")
left_join(var_to_assoc, assoc_to_trait, by = "association_id")#> # A tibble: 7 × 4#> variant_id association_id efo_id trait #> <chr> <chr> <chr> <chr> #> 1 rs7329174 16617 MONDO_0007915 systemic lupus erythematosus#> 2 rs7329174 26451 EFO_0000384 crohn's disease #> 3 rs7329174 26394 MONDO_0007915 systemic lupus erythematosus#> 4 rs7329174 92481688 MONDO_0007915 systemic lupus erythematosus#> 5 rs7329174 17433639 MONDO_0007915 systemic lupus erythematosus#> 6 rs7329174 103267749 EFO_0004339 body height #> 7 rs3798440 24299710 EFO_0000537 hypertension
—
Reply to this email directly, view it on GitHub
<#40 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHOH45GGKTWWZMX2N45UG4DXGQI5XANCNFSM6AAAAAAYEIOBMA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
ramiromagno commented
You're welcome!