Comments (4)
Hi Pradeep,
Thank you for your question! Let me look into that to see if that piece of information is provided by the GWAS REST API.
from gwasrapidd.
Hi again Pradeep,
It seems that that information about the genes is only provided at the GWAS Catalog website, not via REST API at the moment.
I looked a bit though how the front-end website retrieves that information, and I found the URL being requested. So I wrote a bit of a hack to get that info into R: the get_gene()
function. Then get_genes()
is just a vectorised version of get_gene()
.
Finally I exemplify how you could use these functions to augment the genes
table in the associations object. I hope this solution is helpful for the time being.
library(dplyr, warn.conflicts = FALSE)
library(glue, warn.conflicts = FALSE)
library(httr, warn.conflicts = FALSE)
library(tidyjson, warn.conflicts = FALSE)
library(purrr)
library(gwasrapidd, warn.conflicts = FALSE)
# For retrieving info about one gene only.
get_gene <- function(gene_name) {
gene_name <- URLencode(gene_name)
url <- glue::glue("https://www.ebi.ac.uk/gwas/api/search?q=title%3A+%22{gene_name}%22+AND+resourcename%3Agene")
response <- httr::GET(url)
json <- httr::content(response, 'text', encoding = 'UTF-8')
tbl <-
json %>%
tidyjson::enter_object('response', 'docs') %>%
tidyjson::gather_array() %>%
tidyjson::spread_values(
gene_name = tidyjson::jstring('title'),
description = tidyjson::jstring('description'),
chromosome_name = tidyjson::jstring('chromosomeName'),
chromosome_start = tidyjson::jnumber('chromosomeStart'),
chromosome_end = tidyjson::jnumber('chromosomeEnd'),
cytogenetic_band = tidyjson::jstring('cytobands'),
biotype = tidyjson::jstring('biotype')
) %>%
tidyjson::as_tibble() %>%
dplyr::select(-c('document.id', 'array.index'))
return(tbl)
}
# Maps over genes
get_genes <- function(gene_names) {
purrr::map_dfr(gene_names, get_gene)
}
# As an example, let us get some studies about rheumatoid arthritis.
my_studies <- get_studies(efo_trait = 'rheumatoid arthritis')
# Going after those associations related to the first study found only (for the
# sake of simplicity)
one_study <- my_studies[1]
my_associations <- get_associations(study_id = one_study@studies$study_id)
gene_info <- get_genes(my_associations@genes$gene_name)
my_associations@genes <- dplyr::left_join(my_associations@genes, gene_info, by = 'gene_name')
# The slot `genes` of the `associations` object is now augmented to include
# those extra details about each gene.
my_associations@genes
#> # A tibble: 5 × 9
#> association_id locus_id gene_name description chromosome_name chromosome_start
#> <chr> <int> <chr> <chr> <chr> <dbl>
#> 1 17729 1 BLK BLK proto-… 8 11486894
#> 2 17731 1 ARHGEF3 Rho guanin… 3 56727418
#> 3 17883 1 HLA-DRB1 major hist… 6 32578769
#> 4 17730 1 TRHDE thyrotropi… 12 72087266
#> 5 40454 1 PADI4 peptidyl a… 1 17308195
#> # … with 3 more variables: chromosome_end <dbl>, cytogenetic_band <chr>,
#> # biotype <chr>
from gwasrapidd.
Indeed! It seems that the gene being queried is used as a keyword that will match any gene name containing that keyword. But do not worry, when you do the dplyr::left_join()
by gene_name
, it has to match exactly. So the final table obtained in my_associations@genes
should be as expected.
from gwasrapidd.
Thanks a lot, @ramiromagno, for this quick hack.
I have tested these functions briefly and made the following observation. If the input contains HLA to the get_genes()
function, it fetches the information for even HLA-E, HLA-F etc. Similarly, if the input contains C10orf95, then it will fetch the C10orf95-AS1.
from gwasrapidd.
Related Issues (20)
- Response code 500 when using get_studies() HOT 8
- parsing issue while using get_variants() HOT 10
- Gwascatcollect<-function(gene, chr=xx, start=xx, end=xx) HOT 3
- GRASP: Genome-Wide Repository of Associations Between SNPs and Phenotypes HOT 4
- The most efficient way to retrieve association results by study_id? HOT 2
- institutional logo not rendered in footer
- revisit FAQ 5 HOT 1
- consider transitioning to the (not so) new pkgdown website template HOT 2
- Error: parse error: premature EOF in study responses
- Response code was 500. HOT 3
- About failing download the studies of "get_studies()“ HOT 6
- Error when running get_associations() HOT 4
- List of Variants to GWAS associations HOT 3
- Problem with obtaining the RAF for individual variants contained within associations with a haplotype
- Why are some gene names present in `genomic_contexts` but not in `ensembl_ids`? HOT 7
- The associations number obtained by "gwasrapidd" differs extremly from obtained in GWAS Catalog HOT 5
- How do I export `my_associations` to a table file, separated by tabs HOT 8
- FR: Add export functionality for gwasrapidd objects: `write_xlsx()`
- `get_studies()` not returning a scores object with efo id `"MONDO_0004648"`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gwasrapidd.