-
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.
complete dynamic association endpoints; also rename calculate_eqtls()…
… to calculate_splicing_quantitative_trait_loci()
- Loading branch information
Showing
20 changed files
with
423 additions
and
123 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 |
---|---|---|
|
@@ -10,3 +10,5 @@ | |
^README\.Rmd$ | ||
^codecov\.yml$ | ||
^.vscode$ | ||
^doc$ | ||
^Meta$ |
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 |
---|---|---|
|
@@ -4,3 +4,5 @@ docs | |
.vscode | ||
inst/doc | ||
.Renviron | ||
/doc/ | ||
/Meta/ |
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#' Calculate Expression Quantitative Trait Loci | ||
#' | ||
#' @description Calculate your own eQTLs | ||
#' | ||
#' - This service calculates the gene-variant association for any given pair of gene and variant, which may or may not be significant. | ||
#' - This requires as input a GENCODE ID, GTEx variant ID, and tissue site detail ID. | ||
#' | ||
#' By default, the calculation is based on the latest GTEx release. | ||
#' | ||
#' [GTEx Portal API documentation](https://gtexportal.org/api/v2/redoc#tag/Dynamic-Association-Endpoints/operation/calculate_expression_quantitative_trait_loci_api_v2_association_dyneqtl_get). | ||
#' | ||
#' @details 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. | ||
#' * See examples for how to calculate minor and alternative allele frequencies. | ||
#' | ||
#' Notes on input: | ||
#' | ||
#' * Argument `variantId` also accepts RSIDs. | ||
#' | ||
#' @inheritParams gtexr_arguments | ||
#' | ||
#' @return A tibble. | ||
#' @export | ||
#' @family Dynamic Association Endpoints | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' # perform request - returns a tibble with a single row | ||
#' calculate_expression_quantitative_trait_loci(tissueSiteDetailId = "Whole_Blood", | ||
#' gencodeId = "ENSG00000203782.5", | ||
#' variantId = "rs79641866") | ||
#' | ||
#' # unnest list columns with tidyr::unnest() | ||
#' calculate_expression_quantitative_trait_loci(tissueSiteDetailId = "Whole_Blood", | ||
#' gencodeId = "ENSG00000203782.5", | ||
#' variantId = "rs79641866") |> | ||
#' tidyr::unnest(c("data", "genotypes")) | ||
#' | ||
#' # to calculate minor and alternative allele frequencies | ||
#' calculate_expression_quantitative_trait_loci( | ||
#' tissueSiteDetailId = "Liver", | ||
#' gencodeId = "ENSG00000237973.1", | ||
#' variantId = "rs12119111" | ||
#' ) |> | ||
#' dplyr::bind_rows(.id = "rsid") |> | ||
#' | ||
#' tidyr::separate( | ||
#' col = "variantId", | ||
#' into = c( | ||
#' "chromosome", | ||
#' "position", | ||
#' "reference_allele", | ||
#' "alternative_allele", | ||
#' "genome_build" | ||
#' ), | ||
#' sep = "_" | ||
#' ) |> | ||
#' | ||
#' # ...then ascertain alternative_allele frequency | ||
#' dplyr::mutate( | ||
#' alt_allele_count = (2 * homoAltCount) + hetCount, | ||
#' total_allele_count = 2 * (homoAltCount + hetCount + homoRefCount), | ||
#' alternative_allele_frequency = alt_allele_count / total_allele_count | ||
#' ) |> | ||
#' | ||
#' dplyr::select( | ||
#' rsid, | ||
#' beta = nes, | ||
#' se = error, | ||
#' pValue, | ||
#' minor_allele_frequency = maf, | ||
#' alternative_allele_frequency, | ||
#' chromosome:genome_build, | ||
#' tissueSiteDetailId | ||
#' ) | ||
#' } | ||
calculate_expression_quantitative_trait_loci <- function(tissueSiteDetailId, | ||
gencodeId, | ||
variantId, | ||
datasetId = "gtex_v8") { | ||
result <- gtex_query("association/dyneqtl", | ||
return_raw = TRUE) | ||
result$data <- list(tibble::tibble(data = as.numeric(result$data))) | ||
result$genotypes <- list(tibble::tibble(genotypes = as.integer(result$genotypes))) | ||
|
||
result <- tibble::as_tibble(result) | ||
|
||
return(result) | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#' Calculate Isqtls | ||
#' | ||
#' @description Calculate your own Cell Specific sQTLs. | ||
#' | ||
#' - This service calculates the gene-variant association for any given pair of gene and variant, which may or may not be significant. | ||
#' - This requires as input a GENCODE ID, GTEx variant ID, and tissue site detail ID. | ||
#' | ||
#' By default, the calculation is based on the latest GTEx release. | ||
#' | ||
#' [GTEx Portal API documentation](https://gtexportal.org/api/v2/redoc#tag/Dynamic-Association-Endpoints/operation/calculate_ieqtls_api_v2_association_dynieqtl_get). | ||
#' | ||
#' @inheritParams gtexr_arguments | ||
#' | ||
#' @return A tibble. | ||
#' @export | ||
#' @family Dynamic Association Endpoints | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' # perform request | ||
#' calculate_isqtls(cellType = "Neutrophils", | ||
#' tissueSiteDetailId = "Whole_Blood", | ||
#' phenotypeId = "chr1:15947:16607:clu_40980:ENSG00000227232.5", | ||
#' variantId = "chr1_1099341_T_C_b38") | ||
#' } | ||
calculate_isqtls <- | ||
function(cellType, | ||
tissueSiteDetailId, | ||
phenotypeId, | ||
variantId, | ||
datasetId = "gtex_v8") { | ||
gtex_query(endpoint = "association/dynisqtl", return_raw = TRUE) |> | ||
purrr::imap(\(x, idx) ifelse(is.list(x), | ||
tibble::tibble( | ||
data = purrr::map_depth(x, | ||
purrr::pluck_depth(x) - 2, | ||
unlist) | ||
), | ||
x)) |> | ||
tibble::as_tibble() | ||
} |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#' Calculate Splicing Quantitative Trait Loci | ||
#' | ||
#' @description | ||
#' [GTEx Portal API documentation](https://gtexportal.org/api/v2/redoc#tag/Dynamic-Association-Endpoints/operation/calculate_splicing_quantitative_trait_loci_api_v2_association_dynsqtl_get). | ||
#' | ||
#' @inheritParams gtexr_arguments | ||
#' | ||
#' @return A tibble. | ||
#' @export | ||
#' @family Dynamic Association Endpoints | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' # perform request - returns a tibble with a single row | ||
#' calculate_splicing_quantitative_trait_loci( | ||
#' tissueSiteDetailId = "Whole_Blood", | ||
#' phenotypeId = "chr1:15947:16607:clu_40980:ENSG00000227232.5", | ||
#' variantId = "chr1_14677_G_A_b38") | ||
#' } | ||
calculate_splicing_quantitative_trait_loci <- function(tissueSiteDetailId, | ||
phenotypeId, | ||
variantId, | ||
datasetId = "gtex_v8") { | ||
result <- gtex_query("association/dynsqtl", return_raw = TRUE) | ||
result$data <- list(tibble::tibble(data = as.numeric(result$data))) | ||
result$genotypes <- list(tibble::tibble(genotypes = as.integer(result$genotypes))) | ||
|
||
result <- tibble::as_tibble(result) | ||
|
||
return(result) | ||
} |
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
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
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.