Skip to content

Commit ce74c5c

Browse files
authored
Adding new pleiotropy data access functions (#11)
1 parent 2f394f4 commit ce74c5c

11 files changed

+190
-2
lines changed

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ export(associations_api)
55
export(gene)
66
export(gene_api)
77
export(genes_api)
8+
export(get_all_gene_pleiotropies)
9+
export(get_all_snp_pleiotropies)
810
export(health_api)
911
export(ld_matrix)
1012
export(ld_matrix_by_snp_id_api)

R/api.r

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,4 +357,27 @@ associations_api <- function(snp_ids, study_ids) {
357357
associations <- httr::content(associations, "text", encoding = "UTF-8")
358358
associations <- jsonlite::fromJSON(associations)
359359
return(associations)
360+
}
361+
362+
363+
#' @title Get All Gene Pleiotropies API
364+
#' @description Get all gene pleiotropies from the API
365+
#' @return A list containing the gene pleiotropies
366+
gene_pleiotropies_api <- function() {
367+
url <- paste0(getOption("gpmap_url"), "/v1/pleiotropy/genes")
368+
gene_pleiotropies <- httr::GET(url, httr::timeout(timeout_seconds))
369+
gene_pleiotropies <- httr::content(gene_pleiotropies, "text", encoding = "UTF-8")
370+
gene_pleiotropies <- jsonlite::fromJSON(gene_pleiotropies)
371+
return(gene_pleiotropies)
372+
}
373+
374+
#' @title Get All SNP Pleiotropies API
375+
#' @description Get all SNP pleiotropies from the API
376+
#' @return A list containing the SNP pleiotropies
377+
snp_pleiotropies_api <- function() {
378+
url <- paste0(getOption("gpmap_url"), "/v1/pleiotropy/snps")
379+
snp_pleiotropies <- httr::GET(url, httr::timeout(timeout_seconds))
380+
snp_pleiotropies <- httr::content(snp_pleiotropies, "text", encoding = "UTF-8")
381+
snp_pleiotropies <- jsonlite::fromJSON(snp_pleiotropies)
382+
return(snp_pleiotropies)
360383
}

R/pleiotropy.R

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#' @title Get All Gene Pleiotropies
2+
#' @description Get gene pleiotropy from the API by gene id
3+
#' @return A list containing the gene pleiotropy
4+
#' @inheritSection gene_pleiotropy_doc gene_pleiotropy_dataframe
5+
#' @export
6+
get_all_gene_pleiotropies <- function() {
7+
gene_pleiotropies <- gene_pleiotropies_api()
8+
return(gene_pleiotropies)
9+
}
10+
11+
#' @title Get All SNP Pleiotropies
12+
#' @description Get all SNP pleiotropies from the API
13+
#' @return A list containing the SNP pleiotropies
14+
#' @inheritSection snp_pleiotropy_doc snp_pleiotropy_dataframe
15+
#' @export
16+
get_all_snp_pleiotropies <- function() {
17+
snp_pleiotropies <- snp_pleiotropies_api()
18+
return(snp_pleiotropies)
19+
}

R/shared_docs.R

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,32 @@ genes_in_region_doc <- function() {}
188188
#' \item r: the r value between the lead and variant SNPs
189189
#' }
190190
#' @keywords internal
191-
ld_doc <- function() {}
191+
ld_doc <- function() {}
192+
193+
#' @title Gene Pleiotropies Dataframe Documentation
194+
#' @description Shared documentation for gene_pleiotropies dataframe columns
195+
#' @section gene_pleiotropies_dataframe:
196+
#' The gene_pleiotropies dataframe contains information about which genes are pleiotropic.
197+
#' It has the following columns:
198+
#' \itemize{
199+
#' \item gene_id: the id of the gene
200+
#' \item gene: the name of the gene
201+
#' \item : distinct_trait_categories the number of trait categories that the gene is associated with via coloc groups
202+
#' \item : distinct_protein_coding_genes the number of genes that the gene is associated with via coloc groups
203+
#' }
204+
#' @keywords internal
205+
gene_pleiotropies_doc <- function() {}
206+
207+
#' @title SNP Pleiotropies Dataframe Documentation
208+
#' @description Shared documentation for snp_pleiotropies dataframe columns
209+
#' @section snp_pleiotropies_dataframe:
210+
#' The snp_pleiotropies dataframe contains information about which SNPs are pleiotropic.
211+
#' It has the following columns:
212+
#' \itemize{
213+
#' \item snp_id: the id of the SNP
214+
#' \item snp: the name of the SNP
215+
#' \item : distinct_trait_categories the number of trait categories that the SNP is associated with via coloc groups
216+
#' \item : distinct_protein_coding_genes the number of genes that the SNP is associated with via coloc groups
217+
#' }
218+
#' @keywords internal
219+
snp_pleiotropies_doc <- function() {}

man/gene_pleiotropies_api.Rd

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/gene_pleiotropies_doc.Rd

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/get_all_gene_pleiotropies.Rd

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/get_all_snp_pleiotropies.Rd

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/snp_pleiotropies_api.Rd

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/snp_pleiotropies_doc.Rd

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)