-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
65 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,58 @@ | ||
#' Get Gene Expression | ||
#' | ||
#' @description | ||
#' - Find normalized gene expression data. | ||
#' @description Find normalized gene expression data. | ||
#' | ||
#' - Returns normalized gene expression in tissues at the sample level. | ||
#' - Results may be filtered by dataset, gene or tissue, but at least one gene must be provided. | ||
#' - By default, this service queries the latest GTEx release. | ||
#' | ||
#'[GTEx Portal API | ||
#'documentation](https://gtexportal.org/api/v2/redoc#tag/Expression-Data-Endpoints/operation/get_gene_expression_api_v2_expression_geneExpression_get) | ||
#' By default, this service queries the latest GTEx release. | ||
#' | ||
#' [GTEx Portal API | ||
#' documentation](https://gtexportal.org/api/v2/redoc#tag/Expression-Data-Endpoints/operation/get_gene_expression_api_v2_expression_geneExpression_get) | ||
#' | ||
#' @inheritParams gtexr_arguments | ||
#' | ||
#' @return A Tibble | ||
#' @return A tibble. | ||
#' @export | ||
#' @family Expression Data Endpoints | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' get_gene_expression(gencodeIds = "ENSG00000132693.12") | ||
#' # multiple genes, selected tissues | ||
#' get_gene_expression(gencodeIds = c("ENSG00000132693.12", | ||
#' "ENSG00000203782.5"), | ||
#' tissueSiteDetailIds = c("Thyroid", "Whole_Blood")) | ||
#' | ||
#' # single gene, selected (single) tissue | ||
#' get_gene_expression(gencodeIds = "ENSG00000132693.12", | ||
#' tissueSiteDetailIds = "Whole_Blood") | ||
#' | ||
#' # subset by sex | ||
#' get_gene_expression(gencodeIds = "ENSG00000132693.12", | ||
#' tissueSiteDetailIds = "Whole_Blood", | ||
#' attributeSubset = "sex") | ||
#' | ||
#' # subset by age bracket | ||
#' get_gene_expression(gencodeIds = "ENSG00000132693.12", | ||
#' tissueSiteDetailIds = "Whole_Blood", | ||
#' attributeSubset = "ageBracket") | ||
#' } | ||
get_gene_expression <- function(gencodeIds, | ||
datasetId = "gtex_v8", | ||
tissueSiteDetailId = NULL, | ||
tissueSiteDetailIds = NULL, | ||
attributeSubset = NULL, | ||
page = 0, | ||
itemsPerPage = 250){ | ||
gtex_query(endpoint = "expression/geneExpression") | ||
itemsPerPage = 250) { | ||
resp_body <- gtex_query(endpoint = "expression/geneExpression", return_raw = TRUE) | ||
|
||
paging_info_messages(resp_body) | ||
|
||
resp_body$data |> | ||
purrr::map(\(x) { | ||
x$data <- list(as.numeric(x$data)) | ||
x |> | ||
purrr::map_if(is.null, \(y) NA) |> | ||
tibble::as_tibble() | ||
}) |> | ||
dplyr::bind_rows() | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.