Skip to content

Commit

Permalink
various typo and documentation fixes; also update getdownloads_page_d…
Browse files Browse the repository at this point in the history
…ata(), get_file_list(), get_significantTissueEqtlByLocation() and get_linkage_disequilibrium_data()
  • Loading branch information
rmgpanw committed Apr 16, 2024
1 parent 1cd8c0c commit 836b938
Show file tree
Hide file tree
Showing 64 changed files with 1,377 additions and 221 deletions.
1 change: 1 addition & 0 deletions .Rprofile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
source("renv/activate.R")
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.Rproj.user
docs
.Rhistory
29 changes: 29 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Package: gtexr
Title: Query the GTEx Portal API
Version: 0.0.0.9000
Authors@R:
person(given = "Alasdair",
family = "Warwick",
role = c("aut", "cre", "cph"),
email = "alasdair.warwick06@gmail.com",
comment = c(ORCID = "0000-0002-0800-2890"))
Description: A convenient R interface to the GTEx Portal API.
License: MIT + file LICENSE
URL: https://rmgpanw.github.io/gtexr/,
https://github.com/rmgpanw/gtexr
BugReports: https://github.com/rmgpanw/gtexr/issues
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
Imports:
cli,
dplyr,
httr2 (>= 1.0.0),
purrr,
rlang,
tibble,
tidyr
Suggests:
httptest2,
testthat (>= 3.0.0)
Config/testthat/edition: 3
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
YEAR: 2024
COPYRIGHT HOLDER: gtexr authors
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License

Copyright (c) 2024 gtexr authors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
38 changes: 38 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Generated by roxygen2: do not edit by hand

export(available_tissueSiteDetailIds)
export(calculate_eqtls)
export(get_annotation)
export(get_collapsed_gene_model_exon)
export(get_dataset_info)
export(get_downloads_page_data)
export(get_eqtl_genes)
export(get_exons)
export(get_file_list)
export(get_fine_mapping)
export(get_full_get_collapsed_gene_model_exon)
export(get_functional_annotation)
export(get_gene_search)
export(get_genes)
export(get_gwas_catalog_by_location)
export(get_image)
export(get_independent_eqtl)
export(get_linkage_disequilibrium_by_variant_data)
export(get_linkage_disequilibrium_data)
export(get_maintenance_message)
export(get_multi_tissue_eqtls)
export(get_neighbor_gene)
export(get_news_item)
export(get_sample)
export(get_service_info)
export(get_significant_single_tissue_eqtls)
export(get_significant_single_tissue_eqtls_by_location)
export(get_significant_single_tissue_ieqtls)
export(get_significant_single_tissue_isqtls)
export(get_significant_single_tissue_sqtls)
export(get_sqtl_genes)
export(get_subject)
export(get_tissue_site_detail)
export(get_transcripts)
export(get_variant)
export(get_variant_by_location)
5 changes: 5 additions & 0 deletions R/calculate_eqtls.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
#' [Calculate your own
#' eQTLs](https://gtexportal.org/api/v2/redoc#tag/Dynamic-Association-Endpoints/operation/calculate_expression_quantitative_trait_loci_api_v2_association_dyneqtl_get)
#'
#' Notes on output:
#'
#' * Beta and standard error are recorded in columns `nes` and `error` respectively (see [GTEx FAQs](https://gtexportal.org/home/faq#nes_beta))
#' * `variantId` contains (in order) chromosome, position, reference allele, alternative allele and human genome build separated by underscores. The reference and alternative alleles for "chr1_13550_G_A_b38" for example are "G" and "A" respectively.
#'
#' @inheritParams gtexr_arguments
#'
#' @return A tibble.
Expand Down
8 changes: 3 additions & 5 deletions R/get_annotation.R
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
#'Get Annotation
#'
#'@description
#'[GTEx Portal API documentation]
#'https://gtexportal.org/api/v2/redoc#tag/Datasets-Endpoints/operation/get_annotation_api_v2_dataset_annotation_get
#' - This service returns the list of annotations and allowed values by which a particular dataset can be subsetted.
#' - Results may be filtered by dataset.
#'
#'[GTEx Portal API documentation]
#'https://gtexportal.org/api/v2/redoc#tag/Datasets-Endpoints/operation/get_annotation_api_v2_dataset_annotation_get
#'[GTEx Portal API
#'documentation](https://gtexportal.org/api/v2/redoc#tag/Datasets-Endpoints/operation/get_annotation_api_v2_dataset_annotation_get)
#'
#'@inheritParams gtexr_arguments
#'
#'@return A tibble
#'@export
#'@family Datasets Endpoints
#'
#' @examples
#' \dontrun
#' get_annotation()
get_annotation <- function(datasetId = "gtex_v8",
page = 0,
Expand Down
4 changes: 1 addition & 3 deletions R/get_collapsed_gene_model_exon.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
#'algorithm developed by the GTEx analysis team.
#' - By default, this service queries the models used by the latest GTEx release.
#'
#'[GTEx Portal API documentation]
#'https://gtexportal.org/api/v2/redoc#tag/Datasets-Endpoints/operation/get_collapsed_gene_model_exon_api_v2_dataset_collapsedGeneModelExon_get
#'[GTEx Portal API documentation](https://gtexportal.org/api/v2/redoc#tag/Datasets-Endpoints/operation/get_collapsed_gene_model_exon_api_v2_dataset_collapsedGeneModelExon_get)
#'
#'@inheritParams gtexr_arguments
#'
Expand All @@ -18,7 +17,6 @@
#'@family Datasets Endpoints
#'
#' @examples
#' \dontrun
#' get_collapsed_gene_model_exon(gencodeIds = c("ENSG00000132693.12",
#' "ENSG00000203782.5"))
get_collapsed_gene_model_exon <- function(gencodeIds,
Expand Down
14 changes: 8 additions & 6 deletions R/get_downloads_page_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
#'@description
#' - Retrieves all the files belonging to the given project_id for display on the Downloads Page
#'
#'[GTEx Portal API documentation]
#'https://gtexportal.org/api/v2/redoc#tag/Datasets-Endpoints/operation/get_downloads_page_data_api_v2_dataset_openAccessFilesMetadata_get
#'[GTEx Portal API
#'documentation](https://gtexportal.org/api/v2/redoc#tag/Datasets-Endpoints/operation/get_downloads_page_data_api_v2_dataset_openAccessFilesMetadata_get)
#'
#'@inheritParams gtexr_arguments
#'
#'@return A Tibble
#'@export
#'@family Dataset Endpoints
#'@family Datasets Endpoints
#'
#' @examples
#' \dontrun
#' get_downloads_page_data()
get_downloads_page_data <- function(project_id = "gtex"){
gtex_query(endpoint = "dataset/openAccessFilesMetaData")
get_downloads_page_data <- function(project_id = "adult-gtex") {
gtex_query(endpoint = "dataset/openAccessFilesMetadata",
return_raw = TRUE)$data |>
purrr::map(tibble::as_tibble) |>
dplyr::bind_rows()
}
14 changes: 8 additions & 6 deletions R/get_file_list.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
#' Get File List
#'
#' @description
#' - Get all the files in GTEx dataset for Download page
#'
#' [GTEx Portal API documentation]
#' https://gtexportal.org/api/v2/redoc#tag/Datasets-Endpoints/operation/get_file_list_api_v2_dataset_fileList_get
#' [GTEx Portal API
#' documentation](https://gtexportal.org/api/v2/redoc#tag/Datasets-Endpoints/operation/get_file_list_api_v2_dataset_fileList_get)
#'
#'@inheritParams gtexr_arguments
#'
#' @return A Tibble
#' @export
#' @family Datasets Endpoints
#'
#' @examples
#' \dontrun
#' get_file_list()
get_file_list <- function(){
gtex_query(enpoint = "dataset/fileList")
get_file_list <- function() {
gtex_query(endpoint = "dataset/fileList",
return_raw = TRUE) |>
purrr::map(tibble::as_tibble) |>
dplyr::bind_rows()
}
2 changes: 0 additions & 2 deletions R/get_fine_mapping.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#'@family Static Association Endpoints
#'
#' @examples
#' \dontrun{
#' # search by gene
#' get_fine_mapping(gencodeIds = c("ENSG00000132693.12",
#' "ENSG00000203782.5"))
Expand All @@ -28,7 +27,6 @@
#' variantId = "chr1_153228363_A_G_b38",
#' tissueSiteDetailIds = c("Whole_Blood",
#' "Thyroid"))
#'}
get_fine_mapping <- function(gencodeIds,
datasetId = "gtex_v8",
variantId = NULL,
Expand Down
7 changes: 3 additions & 4 deletions R/get_full_get_collapsed_gene_model_exon.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
#'@description
#' - This service allows the user to query the full Collapsed Gene Model Exon of a specific gene by gencode ID
#'
#'[GTEx Portal API documentation]
#'https://gtexportal.org/api/v2/redoc#tag/Datasets-Endpoints/operation/get_full_get_collapsed_gene_model_exon_api_v2_dataset_fullCollapsedGeneModelExon_get
#'[GTEx Portal API
#'documentation](https://gtexportal.org/api/v2/redoc#tag/Datasets-Endpoints/operation/get_full_get_collapsed_gene_model_exon_api_v2_dataset_fullCollapsedGeneModelExon_get)
#'
#'@inheritParams gtexr_arguments
#'
#'@return A Tibble
#'@export
#'@family Dataset Endpoints
#'@family Datasets Endpoints
#'
#' @examples
#' \dontrun
#' get_full_get_collapsed_gene_model_exon(gencodeIds = c("ENSG00000132693.12",
#' "ENSG00000203782.5"))
get_full_get_collapsed_gene_model_exon <- function(gencodeIds,
Expand Down
7 changes: 3 additions & 4 deletions R/get_functional_annotation.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
#'@description
#' - This endpoint retrieves the functional annotation of a certain chromosome location. Default to most recent dataset release.
#'
#'[GTEx Portal API documentation]
#'https://gtexportal.org/api/v2/redoc#tag/Datasets-Endpoints/operation/get_full_get_collapsed_gene_model_exon_api_v2_dataset_fullCollapsedGeneModelExon_get
#'[GTEx Portal API
#'documentation](https://gtexportal.org/api/v2/redoc#tag/Datasets-Endpoints/operation/get_full_get_collapsed_gene_model_exon_api_v2_dataset_fullCollapsedGeneModelExon_get)
#'
#'@inheritParams gtexr_arguments
#'@return A Tibble
#'@export
#'@family Dataset Endpoints
#'@family Datasets Endpoints
#'
#' @examples
#' \dontrun
#' get_functional_annotation(chromosome = "chr15", start = 1400, end = 20000)
get_functional_annotation <- function(datasetId = "gtex_v8",
chromosome,
Expand Down
4 changes: 2 additions & 2 deletions R/get_image.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#'
#' @examples
#' get_image()
#' get_image(tissueSampleId = "GTEX-1117F-0226", page = 0, itemsPerPage = 100000)
get_image <- function(tissueSampleId = NULL,
#' get_image(tissueSampleIds = "GTEX-1117F-0226", page = 0, itemsPerPage = 100000)
get_image <- function(tissueSampleIds = NULL,
page = 0,
itemsPerPage = 250) {
gtex_query(endpoint = "histology/image")
Expand Down
22 changes: 10 additions & 12 deletions R/get_independent_eqtl.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
#'
#'@description Retrieve Independent eQTL Data
#'
#' Finds and returns Independent eQTL Data data for the provided list of genes
#' By default, this endpoint fetches data from the latest GTEx version The
#' retrieved data is split into pages with items_per_page entries per page
#' - Finds and returns Independent eQTL Data data for the provided list of genes
#' - By default, this endpoint fetches data from the latest GTEx version
#'
#' [GTEx portal API documentation]
#' (https://gtexportal.org/api/v2/redoc#tag/Static-Association-Endpoints/operation/get_independent_eqtl_api_v2_association_independentEqtl_get)
#' The retrieved data is split into pages with items_per_page entries per page
#'
#' [GTEx portal API documentation](https://gtexportal.org/api/v2/redoc#tag/Static-Association-Endpoints/operation/get_independent_eqtl_api_v2_association_independentEqtl_get)
#'
#'@inheritParams gtexr_arguments
#'
Expand All @@ -16,19 +16,17 @@
#'@family Static Association Endpoints
#'
#' @examples
#' \dontrun{
#' # search by gene
#' get_independent_eqtl(gencodeIds = c("ENSG00000132693.12",
#' "ENSG00000203782.5"))
#'
#' # optionally filter for a single variant and/or one or more tissues
#' get_independent_eqtl(gencodeIds = c("ENSG00000132693.12",
#' "ENSG00000203782.5"),
#' tissueSiteDetailIds = c("Whole_Blood",
#' "Thyroid"))
#'}
get_independent_eqtl <- function(gencodeId,
tissueSiteDetailId = NULL,
#' "ENSG00000203782.5"),
#' tissueSiteDetailIds = c("Whole_Blood",
#' "Thyroid"))
get_independent_eqtl <- function(gencodeIds,
tissueSiteDetailIds = NULL,
datasetId = "gtex_v8",
page = 0,
itemsPerPage = 250){
Expand Down
13 changes: 6 additions & 7 deletions R/get_linkage_disequilibrium_by_variant_data.R
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
#' Get Linkage Disequilibrium By Variant Data
#'Get Linkage Disequilibrium By Variant Data
#'
#' @description
#'@description
#' - Find linkage disequilibrium (LD) data for a given variant
#'
#'[GTEx Portal API documentation]
#'https://gtexportal.org/api/v2/redoc#tag/Datasets-Endpoints/operation/get_linkage_disequilibrium_by_variant_data_api_v2_dataset_ldByVariant_get
#'[GTEx Portal API
#'documentation](https://gtexportal.org/api/v2/redoc#tag/Datasets-Endpoints/operation/get_linkage_disequilibrium_by_variant_data_api_v2_dataset_ldByVariant_get)
#'
#'@inheritParams gtexr_arguments
#'@return A Tibble
#'@export
#'@family Dataset Endpoints
#'@family Datasets Endpoints
#'
#' @examples
#' \dontrun
#' get_linkage_disequilibrium_by_variant_data()
get_linkage_disequilibirum_by_variant_data <- function(variantId = NULL,
get_linkage_disequilibrium_by_variant_data <- function(variantId = NULL,
page = 0,
itemsPerPage = 250){
gtex_query(endpoint = "dataset/ldByVariant")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
#'Get Linkage Disequilibrium Data
#' Get Linkage Disequilibrium Data
#'
#'@description
#' @description
#' - Find linkage disequilibrium (LD) data for a given gene.
#' - This endpoint returns linkage disequilibrium data for the cis-eQTLs found associated with the provided gene in a specified dataset.
#' - Results are queried by gencode ID. By default, the service queries the latest GTEx release.
#' - Specify a dataset ID to fetch results from a different dataset.
#'
#'[GTEx Portal API documentation]
#'https://gtexportal.org/api/v2/redoc#tag/Datasets-Endpoints/operation/get_variant_by_location_api_v2_dataset_variantByLocation_get#'
#' [GTEx Portal API documentation](https://gtexportal.org/api/v2/redoc#tag/Datasets-Endpoints/operation/get_variant_by_location_api_v2_dataset_variantByLocation_get)
#'
#'@inheritParams gtexr_arguments
#'@return A Tibble
#'@export
#'@family Dataset Endpoints
#' @inheritParams gtexr_arguments
#' @return A tibble.
#' @export
#'@family Datasets Endpoints
#'
#' @examples
#' \dontrun
#' get_linkage_disequilibrium_data(gencodeIds = c("ENSG00000132693.12",
#' "ENSG00000203782.5"))
get_linkage_disequilibirum_data <- function(gencodeIds,
get_linkage_disequilibrium_data <- function(gencodeIds,
datasetId = "gtex_v8",
page = 0,
itemsPerPage = 250){
gtex_query(endpoint = "dataset/ld")
gtex_query(endpoint = "dataset/ld",
return_raw = TRUE)$data |>
purrr::map(\(x) tibble::tibble(variants = x[[1]], ld = x[[2]])) |>
dplyr::bind_rows() |>
tidyr::separate_wider_delim(
cols = "variants",
delim = ",",
names = c("variantId_1", "variantId_2")
)
}
Loading

0 comments on commit 836b938

Please sign in to comment.