Code Monkey home page Code Monkey logo

Comments (3)

ramiromagno avatar ramiromagno commented on May 28, 2024

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

from gwasrapidd.

lizlitkowski avatar lizlitkowski commented on May 28, 2024

from gwasrapidd.

ramiromagno avatar ramiromagno commented on May 28, 2024

You're welcome!

from gwasrapidd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.