From 06ece1e09f2a018fd0d8323efbd6876b45c93abe Mon Sep 17 00:00:00 2001 From: rmgpanw Date: Mon, 24 Jun 2024 22:52:22 +0100 Subject: [PATCH] udpate Reference Genome Endpoints functions --- R/get_exons.R | 5 +++++ R/get_gene_search.R | 8 ++++++-- R/get_genes.R | 9 ++++++--- R/get_genomic_features.R | 23 +++++++++++++---------- R/get_gwas_catalog_by_location.R | 17 ++++++++++++----- R/get_neighbor_gene.R | 17 ++++++++++++----- R/get_transcripts.R | 15 ++++++++++----- man/get_exons.Rd | 6 ++++-- man/get_gene_search.Rd | 8 +++++--- man/get_genes.Rd | 10 +++++----- man/get_genomic_features.Rd | 4 ++-- man/get_gwas_catalog_by_location.Rd | 11 +++++++---- man/get_neighbor_gene.Rd | 11 +++++++---- man/get_transcripts.Rd | 6 ++++-- 14 files changed, 98 insertions(+), 52 deletions(-) diff --git a/R/get_exons.R b/R/get_exons.R index a4b93b7..692bb44 100644 --- a/R/get_exons.R +++ b/R/get_exons.R @@ -1,11 +1,14 @@ #' Get Exons #' +#' @description #' This service returns exons from all known transcripts of the given gene. #' #' - A versioned GENCODE ID is required to ensure that all exons are from a single gene. #' - A dataset ID or both GENCODE version and genome build must be provided. #' - Although annotated exons are not dataset dependent, specifying a dataset here is equivalent to specifying the GENCODE version and genome build used by that dataset. #' +#' [GTEx Portal API documentation](https://gtexportal.org/api/v2/redoc#tag/Reference-Genome-Endpoints/operation/get_exons_api_v2_reference_exon_get) +#' #' @inheritParams gtexr_arguments #' #' @return A tibble. @@ -13,7 +16,9 @@ #' @family Reference Genome Endpoints #' #' @examples +#' \dontrun{ #' get_exons(gencodeId = "ENSG00000203782.5") +#' } get_exons <- function(gencodeId, gencodeVersion = NULL, genomeBuild = NULL, diff --git a/R/get_gene_search.R b/R/get_gene_search.R index 1ad6e6e..27773b5 100644 --- a/R/get_gene_search.R +++ b/R/get_gene_search.R @@ -1,11 +1,13 @@ #' Get Gene Search #' -#' [Find genes that are partial or complete match of a -#' gene_id](https://gtexportal.org/api/v2/redoc#tag/Reference-Genome-Endpoints/operation/get_gene_search_api_v2_reference_geneSearch_get) +#' @description Find genes that are partial or complete match of a gene_id #' #' - gene_id could be a gene symbol, a gencode ID, or an Ensemble ID #' - Gencode Version and Genome Build must be specified #' +#' [GTEx Portal API +#' documentation](https://gtexportal.org/api/v2/redoc#tag/Reference-Genome-Endpoints/operation/get_gene_search_api_v2_reference_geneSearch_get) +#' #' @inheritParams gtexr_arguments #' #' @return A tibble. @@ -13,7 +15,9 @@ #' @family Reference Genome Endpoints #' #' @examples +#' \dontrun{ #' get_gene_search("CRP") +#' } get_gene_search <- function(geneId, gencodeVersion = "v26", genomeBuild = "GRCh38/hg38", diff --git a/R/get_genes.R b/R/get_genes.R index 9b166a8..c9ee78c 100644 --- a/R/get_genes.R +++ b/R/get_genes.R @@ -1,13 +1,14 @@ #' Get Genes #' -#' This service returns information about reference genes. A genome build and -#' GENCODE version must be provided. +#' @description This service returns information about reference genes. A genome +#' build and GENCODE version must be provided. #' #' - Genes are searchable by gene symbol, GENCODE ID and versioned GENCODE ID. #' - Versioned GENCODE ID is recommended to ensure unique ID matching. #' - By default, this service queries the genome build and GENCODE version used by the latest GTEx release. #' -#' [GTEx API Portal docs](https://gtexportal.org/api/v2/redoc#tag/Reference-Genome-Endpoints/operation/get_genes_api_v2_reference_gene_get) +#' [GTEx API Portal +#' documentation](https://gtexportal.org/api/v2/redoc#tag/Reference-Genome-Endpoints/operation/get_genes_api_v2_reference_gene_get) #' #' @inheritParams gtexr_arguments #' @@ -16,7 +17,9 @@ #' @family Reference Genome Endpoints #' #' @examples +#' \dontrun{ #' get_genes(c("CRP", "IL6R")) +#' } get_genes <- function(geneIds, gencodeVersion = "v26", genomeBuild = "GRCh38/hg38", diff --git a/R/get_genomic_features.R b/R/get_genomic_features.R index eb526aa..8ac9dd1 100644 --- a/R/get_genomic_features.R +++ b/R/get_genomic_features.R @@ -1,13 +1,13 @@ #' Get Genomic Features #' #' @description [GTEx API Portal -#' docs](https://gtexportal.org/api/v2/redoc#tag/Reference-Genome-Endpoints/operation/get_genomic_features_api_v2_reference_features__featureId__get) +#' documentation](https://gtexportal.org/api/v2/redoc#tag/Reference-Genome-Endpoints/operation/get_genomic_features_api_v2_reference_features__featureId__get) #' #' @details This endpoint takes a path parameter "featureId". #' #' @inheritParams gtexr_arguments #' -#' @return A tibble +#' @return A tibble. #' @export #' @family Reference Genome Endpoints #' @@ -25,20 +25,17 @@ #' # GTEx variant ID #' get_genomic_features("chr11_66561023_G_GTTA_b38") #' } -get_genomic_features <- function(.featureId, - datasetId = "gtex_v8") { - +get_genomic_features <- function(.featureId, datasetId = "gtex_v8") { # validate `.featureId` validate_featureId(.featureId) # perform query gtex_query(endpoint = paste0("reference/features/", .featureId), - return_raw = TRUE) |> + return_raw = TRUE) |> process_get_genomic_features_resp_json(.featureId = .featureId) } process_get_genomic_features_resp_json <- function(resp_json, .featureId) { - if (rlang::is_empty(resp_json$features)) { result <- tibble::tibble(assembly = resp_json$assembly) } else { @@ -51,9 +48,15 @@ process_get_genomic_features_resp_json <- function(resp_json, .featureId) { validate_featureId <- function(.featureId) { if (!rlang::is_string(.featureId)) { - cli::cli_abort(c("!" = "Invalid `.featureId` input", - "x" = cli::format_inline("You supplied: {class(.featureId)} of length {length(.featureId)}"), - "i" = "`.featureId` must be a single string")) + cli::cli_abort( + c( + "!" = "Invalid `.featureId` input", + "x" = cli::format_inline( + "You supplied: {class(.featureId)} of length {length(.featureId)}" + ), + "i" = "`.featureId` must be a single string" + ) + ) } if (grepl("[^a-zA-Z0-9_.]", .featureId)) { diff --git a/R/get_gwas_catalog_by_location.R b/R/get_gwas_catalog_by_location.R index aec857a..2a3d733 100644 --- a/R/get_gwas_catalog_by_location.R +++ b/R/get_gwas_catalog_by_location.R @@ -1,5 +1,10 @@ #' Get Gwas Catalog By Location -#' Find the GWAS Catalog on a certain chromosome between start and end locations. +#' +#' @description Find the GWAS Catalog on a certain chromosome between start and +#' end locations. +#' +#' [GTEx API Portal +#' documentation](https://gtexportal.org/api/v2/redoc#tag/Reference-Genome-Endpoints/operation/get_gwas_catalog_by_location_api_v2_reference_gwasCatalogByLocation_get) #' #' @inheritParams gtexr_arguments #' @@ -8,11 +13,13 @@ #' @family Reference Genome Endpoints #' #' @examples +#' \dontrun{ #' get_gwas_catalog_by_location(start = 1, end = 10000000, chromosome = "chr1") +#' } get_gwas_catalog_by_location <- function(start, - end, - chromosome, - page = 0, - itemsPerPage = 250) { + end, + chromosome, + page = 0, + itemsPerPage = 250) { gtex_query(endpoint = "reference/gwasCatalogByLocation") } diff --git a/R/get_neighbor_gene.R b/R/get_neighbor_gene.R index 4eb3035..0d9653d 100644 --- a/R/get_neighbor_gene.R +++ b/R/get_neighbor_gene.R @@ -1,5 +1,10 @@ #' Get Neighbor Gene -#' Find all neighboring genes on a certain chromosome around a position with a certain window size. +#' +#' @description Find all neighboring genes on a certain chromosome around a +#' position with a certain window size. +#' +#' [GTEx API Portal +#' documentation](https://gtexportal.org/api/v2/redoc#tag/Reference-Genome-Endpoints/operation/get_neighbor_gene_api_v2_reference_neighborGene_get) #' #' @inheritParams gtexr_arguments #' @@ -8,11 +13,13 @@ #' @family Reference Genome Endpoints #' #' @examples +#' \dontrun{ #' get_neighbor_gene(pos = 1000000, chromosome = "chr1", bp_window = 10000) +#' } get_neighbor_gene <- function(pos, - chromosome, - bp_window, - page = 0, - itemsPerPage = 250) { + chromosome, + bp_window, + page = 0, + itemsPerPage = 250) { gtex_query(endpoint = "reference/neighborGene") } diff --git a/R/get_transcripts.R b/R/get_transcripts.R index 0917669..55da4d1 100644 --- a/R/get_transcripts.R +++ b/R/get_transcripts.R @@ -1,11 +1,14 @@ #' Get Transcripts #' -#' Find all transcripts of a reference gene. +#' @description Find all transcripts of a reference gene. #' #' - This service returns information about transcripts of the given versioned GENCODE ID. #' - A genome build and GENCODE version must be provided. #' - By default, this service queries the genome build and GENCODE version used by the latest GTEx release. #' +#' [GTEx API Portal +#' documentation](https://gtexportal.org/api/v2/redoc#tag/Reference-Genome-Endpoints/operation/get_transcripts_api_v2_reference_transcript_get) +#' #' @inheritParams gtexr_arguments #' #' @return A tibble. @@ -13,11 +16,13 @@ #' @family Reference Genome Endpoints #' #' @examples +#' \dontrun{ #' get_transcripts(gencodeId = "ENSG00000203782.5") +#' } get_transcripts <- function(gencodeId, - gencodeVersion = "v26", - genomeBuild = "GRCh38/hg38", - page = 0, - itemsPerPage = 250) { + gencodeVersion = "v26", + genomeBuild = "GRCh38/hg38", + page = 0, + itemsPerPage = 250) { gtex_query(endpoint = "reference/transcript") } diff --git a/man/get_exons.Rd b/man/get_exons.Rd index 49074bc..32ec0e0 100644 --- a/man/get_exons.Rd +++ b/man/get_exons.Rd @@ -35,17 +35,19 @@ A tibble. } \description{ This service returns exons from all known transcripts of the given gene. -} -\details{ \itemize{ \item A versioned GENCODE ID is required to ensure that all exons are from a single gene. \item A dataset ID or both GENCODE version and genome build must be provided. \item Although annotated exons are not dataset dependent, specifying a dataset here is equivalent to specifying the GENCODE version and genome build used by that dataset. } + +\href{https://gtexportal.org/api/v2/redoc#tag/Reference-Genome-Endpoints/operation/get_exons_api_v2_reference_exon_get}{GTEx Portal API documentation} } \examples{ +\dontrun{ get_exons(gencodeId = "ENSG00000203782.5") } +} \seealso{ Other Reference Genome Endpoints: \code{\link{get_gene_search}()}, diff --git a/man/get_gene_search.Rd b/man/get_gene_search.Rd index 390782b..61b89e7 100644 --- a/man/get_gene_search.Rd +++ b/man/get_gene_search.Rd @@ -29,17 +29,19 @@ Either "v26" or "v19".} A tibble. } \description{ -\href{https://gtexportal.org/api/v2/redoc#tag/Reference-Genome-Endpoints/operation/get_gene_search_api_v2_reference_geneSearch_get}{Find genes that are partial or complete match of a gene_id} -} -\details{ +Find genes that are partial or complete match of a gene_id \itemize{ \item gene_id could be a gene symbol, a gencode ID, or an Ensemble ID \item Gencode Version and Genome Build must be specified } + +\href{https://gtexportal.org/api/v2/redoc#tag/Reference-Genome-Endpoints/operation/get_gene_search_api_v2_reference_geneSearch_get}{GTEx Portal API documentation} } \examples{ +\dontrun{ get_gene_search("CRP") } +} \seealso{ Other Reference Genome Endpoints: \code{\link{get_exons}()}, diff --git a/man/get_genes.Rd b/man/get_genes.Rd index c9cd044..65985d3 100644 --- a/man/get_genes.Rd +++ b/man/get_genes.Rd @@ -30,21 +30,21 @@ Either "v26" or "v19".} A tibble } \description{ -This service returns information about reference genes. A genome build and -GENCODE version must be provided. -} -\details{ +This service returns information about reference genes. A genome +build and GENCODE version must be provided. \itemize{ \item Genes are searchable by gene symbol, GENCODE ID and versioned GENCODE ID. \item Versioned GENCODE ID is recommended to ensure unique ID matching. \item By default, this service queries the genome build and GENCODE version used by the latest GTEx release. } -\href{https://gtexportal.org/api/v2/redoc#tag/Reference-Genome-Endpoints/operation/get_genes_api_v2_reference_gene_get}{GTEx API Portal docs} +\href{https://gtexportal.org/api/v2/redoc#tag/Reference-Genome-Endpoints/operation/get_genes_api_v2_reference_gene_get}{GTEx API Portal documentation} } \examples{ +\dontrun{ get_genes(c("CRP", "IL6R")) } +} \seealso{ Other Reference Genome Endpoints: \code{\link{get_exons}()}, diff --git a/man/get_genomic_features.Rd b/man/get_genomic_features.Rd index 7622ae6..272fd1e 100644 --- a/man/get_genomic_features.Rd +++ b/man/get_genomic_features.Rd @@ -14,10 +14,10 @@ GTEx Variant ID.} data source and data release. Options: "gtex_v8", "gtex_snrnaseq_pilot".} } \value{ -A tibble +A tibble. } \description{ -\href{https://gtexportal.org/api/v2/redoc#tag/Reference-Genome-Endpoints/operation/get_genomic_features_api_v2_reference_features__featureId__get}{GTEx API Portal docs} +\href{https://gtexportal.org/api/v2/redoc#tag/Reference-Genome-Endpoints/operation/get_genomic_features_api_v2_reference_features__featureId__get}{GTEx API Portal documentation} } \details{ This endpoint takes a path parameter "featureId". diff --git a/man/get_gwas_catalog_by_location.Rd b/man/get_gwas_catalog_by_location.Rd index 64794c3..363a50a 100644 --- a/man/get_gwas_catalog_by_location.Rd +++ b/man/get_gwas_catalog_by_location.Rd @@ -2,8 +2,7 @@ % Please edit documentation in R/get_gwas_catalog_by_location.R \name{get_gwas_catalog_by_location} \alias{get_gwas_catalog_by_location} -\title{Get Gwas Catalog By Location -Find the GWAS Catalog on a certain chromosome between start and end locations.} +\title{Get Gwas Catalog By Location} \usage{ get_gwas_catalog_by_location( start, @@ -31,12 +30,16 @@ get_gwas_catalog_by_location( A tibble. } \description{ -Get Gwas Catalog By Location -Find the GWAS Catalog on a certain chromosome between start and end locations. +Find the GWAS Catalog on a certain chromosome between start and +end locations. + +\href{https://gtexportal.org/api/v2/redoc#tag/Reference-Genome-Endpoints/operation/get_gwas_catalog_by_location_api_v2_reference_gwasCatalogByLocation_get}{GTEx API Portal documentation} } \examples{ +\dontrun{ get_gwas_catalog_by_location(start = 1, end = 10000000, chromosome = "chr1") } +} \seealso{ Other Reference Genome Endpoints: \code{\link{get_exons}()}, diff --git a/man/get_neighbor_gene.Rd b/man/get_neighbor_gene.Rd index 81b0f3d..4b0378e 100644 --- a/man/get_neighbor_gene.Rd +++ b/man/get_neighbor_gene.Rd @@ -2,8 +2,7 @@ % Please edit documentation in R/get_neighbor_gene.R \name{get_neighbor_gene} \alias{get_neighbor_gene} -\title{Get Neighbor Gene -Find all neighboring genes on a certain chromosome around a position with a certain window size.} +\title{Get Neighbor Gene} \usage{ get_neighbor_gene(pos, chromosome, bp_window, page = 0, itemsPerPage = 250) } @@ -25,12 +24,16 @@ get_neighbor_gene(pos, chromosome, bp_window, page = 0, itemsPerPage = 250) A tibble. } \description{ -Get Neighbor Gene -Find all neighboring genes on a certain chromosome around a position with a certain window size. +Find all neighboring genes on a certain chromosome around a +position with a certain window size. + +\href{https://gtexportal.org/api/v2/redoc#tag/Reference-Genome-Endpoints/operation/get_neighbor_gene_api_v2_reference_neighborGene_get}{GTEx API Portal documentation} } \examples{ +\dontrun{ get_neighbor_gene(pos = 1000000, chromosome = "chr1", bp_window = 10000) } +} \seealso{ Other Reference Genome Endpoints: \code{\link{get_exons}()}, diff --git a/man/get_transcripts.Rd b/man/get_transcripts.Rd index 76c722c..3d27012 100644 --- a/man/get_transcripts.Rd +++ b/man/get_transcripts.Rd @@ -31,17 +31,19 @@ A tibble. } \description{ Find all transcripts of a reference gene. -} -\details{ \itemize{ \item This service returns information about transcripts of the given versioned GENCODE ID. \item A genome build and GENCODE version must be provided. \item By default, this service queries the genome build and GENCODE version used by the latest GTEx release. } + +\href{https://gtexportal.org/api/v2/redoc#tag/Reference-Genome-Endpoints/operation/get_transcripts_api_v2_reference_transcript_get}{GTEx API Portal documentation} } \examples{ +\dontrun{ get_transcripts(gencodeId = "ENSG00000203782.5") } +} \seealso{ Other Reference Genome Endpoints: \code{\link{get_exons}()},