「R」Obtain RNAseq Values for a Specific Gene in Xena Database

时间:2022-07-22
本文章向大家介绍「R」Obtain RNAseq Values for a Specific Gene in Xena Database,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

写这篇文档的原因是有使用者问我如何获取单个基因的表达值,这个操作我其实在很久之前的生存分析示例文档中介绍过,但用户有所疑惑,说明我写的不清楚或者无法找到,所以针对性就这类问题进行介绍。

❝Hi Shixiang, How can I use Xena tools to extract and compare RNAseq values for a specific gene for TCGA LUAD tumor vs. LUAD adjacent normal? Are there instructions provided anywhere on how to specifically extract the adjacent normal data?❞

When using UCSCXenaTools package, you may want to focus on single gene analysis, a typical case has been shown in my previous blog UCSCXenaTools: Retrieve Gene Expression and Clinical Information from UCSC Xena for Survival Analysis[1]. Here I will describe how to get single gene values (especially RNAseq data) in details.

Let’s load package.

library(UCSCXenaTools)

First, Find Your Interest Dataset

UCSC Xena provides more than 1000 datasets, when you want to get values for single gene, you must select a target dataset. You can find them in the following table or from UCSC Xena datasets page[2].

DT::datatable(UCSCXenaTools::XenaData)

❝此处是 1000 多行的表格,查看原文 https://shixiangwang.github.io/home/en/post/2020-07-22-ucscxenatools-single-gene/[3] ❞

Pick up a dataset and get its XenaHosts and XenaDatasets, i.e. get its data hub host URL and dataset ID. You can copy them or you can use your R skill to get and store them in a object. For example, I got a reader want to study RNASeq values of TCGA LUAD gene.

I can use R:

library(dplyr)
#> 
#> 载入程辑包:'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
ge <- XenaData %>%
  filter(XenaHostNames == "tcgaHub") %>% # select TCGA Hub
  XenaScan("TCGA Lung Adenocarcinoma") %>%
  filter(DataSubtype == "gene expression RNAseq", Label == "IlluminaHiSeq")
str(ge)
#> tibble [1 × 17] (S3: tbl_df/tbl/data.frame)
#>  $ XenaHosts       : chr "https://tcga.xenahubs.net"
#>  $ XenaHostNames   : chr "tcgaHub"
#>  $ XenaCohorts     : chr "TCGA Lung Adenocarcinoma (LUAD)"
#>  $ XenaDatasets    : chr "TCGA.LUAD.sampleMap/HiSeqV2"
#>  $ SampleCount     : int 576
#>  $ DataSubtype     : chr "gene expression RNAseq"
#>  $ Label           : chr "IlluminaHiSeq"
#>  $ Type            : chr "genomicMatrix"
#>  $ AnatomicalOrigin: chr "Lung"
#>  $ SampleType      : chr "tumor"
#>  $ Tags            : chr "cancer,non-small cell lung cancer"
#>  $ ProbeMap        : chr "probeMap/hugo_gencode_good_hg19_V24lift37_probemap"
#>  $ LongTitle       : chr "TCGA lung adenocarcinoma (LUAD) gene expression by RNAseq (polyA+ IlluminaHiSeq)"
#>  $ Citation        : chr NA
#>  $ Version         : chr "2017-10-13"
#>  $ Unit            : chr "log2(norm_count+1)"
#>  $ Platform        : chr "IlluminaHiSeq_RNASeqV2"

Or I just copy https://tcga.xenahubs.net and TCGA.LUAD.sampleMap/HiSeqV2.

Get Your Gene Values

Once you got dataset information, you can get a specific gene expression (it also works for gene-level CNV, mutation, etc based on your dataset) by fetch_dense_values. Run ?fetch in your R console to see more details.

For example, I will query the gene TP53.

TP53 <- fetch_dense_values(
  host = ge$XenaHosts, # You can also set "https://tcga.xenahubs.net"
  dataset = ge$XenaDatasets, # You can also set "TCGA.LUAD.sampleMap/HiSeqV2"
  identifiers = "TP53",
  use_probeMap = TRUE
) %>%
  .[1, ]
#> -> Checking identifiers...
#> -> use_probeMap is TRUE, skipping checking identifiers...
#> -> Done.
#> -> Checking samples...
#> -> Done.
#> -> Checking if the dataset has probeMap...
#> -> Done. ProbeMap is found.
head(TP53)
#> TCGA-69-7978-01 TCGA-62-8399-01 TCGA-78-7539-01 TCGA-50-5931-11 TCGA-73-4658-01 
#>            9.89            8.31           10.35            9.62           10.02 
#> TCGA-44-6775-01 
#>           10.16

Typically, the TCGA sample ID have 15 letters, and the 14-15th letters mark a sample type. When it <10, it is a tumor sample, otherwise it is a normal sample.

table(as.integer(substr(names(TP53), 14, 15)))
#> 
#>   1   2  11 
#> 515   2  59

Now you can start your analysis with this data.

Other Things May Help

In addition to fetch_* functions, I generated many low-level API functions for UCSC Xena database, which described at https://shixiangwang.github.io/home/en/tools/ucscxenatools-api/. These functions can access different levels of data information in UCSC Xena. Some of them are combined to construct the core functionalities provided by UCSCXenaTools for now.

NOTE: not API functions work well, I haven’t tested them all, they are all generated by dynamic code based on XQuery[4].

An R Shiny package UCSCXenaShiny[5] provides a web-based platform to download datasets and analyze single genes. Besides, we have constructed some functions to get pan-cancer level single gene expression, CNV and mutation etc.

You can download recent development version in GitHub with:

remotes::install_github("openbiox/XenaShiny")

After you load this package, you can use the following functions to get data easily.

get_ccle_cn_value: Fetch copy number value from CCLE dataset

get_ccle_gene_value: Fetch gene expression value from CCLE dataset

get_ccle_protein_value: Fetch gene protein expression value from CCLE dataset

get_ccle_mutation_status: Fetch gene mutation info from CCLE dataset

get_pancan_value: Fetch identifier value from pan-cancer dataset

get_pancan_gene_value: Fetch gene expression value from pan-cancer dataset

get_pancan_protein_value: Fetch protein expression value from pan-cancer dataset

get_pancan_mutation_status: Fetch mutation status value from pan-cancer dataset

get_pancan_cn_value: Fetch gene copy number value from pan-cancer dataset processed by GISTIC 2.0

Any questions can be posted online at https://github.com/openbiox/UCSCXenaShiny/issues or https://github.com/ropensci/UCSCXenaTools/issues.

总结一下,除了 UCSCXenaTools 的 README,加上本文,我已经写了 4 篇介绍文档了:

  • Introduction and basic usage of UCSCXenaTools[6]
  • UCSCXenaTools: Retrieve Gene Expression and Clinical Information from UCSC Xena for Survival Analysis[7]
  • Obtain RNAseq Values for a Specific Gene in Xena Database[8]
  • UCSC Xena Access APIs in UCSCXenaTools[9]

References

  • Wang et al., (2019). The UCSCXenaTools R package: a toolkit for accessing genomics data from UCSC Xena platform, from cancer multi-omics to single-cell RNA-seq. Journal of Open Source Software, 4(40), 1627, https://doi.org/10.21105/joss.01627
  • Wang, S.; Xiong, Y.; Gu, K.; Zhao, L.; Li, Y.; Zhao, F.; Li, X.; Liu, X. UCSCXenaShiny: An R Package for Exploring and Analyzing UCSC Xena Public Datasets in Web Browser. Preprints 2020, 2020070179 (doi: 10.20944/preprints202007.0179.v1).

References

[1]UCSCXenaTools: Retrieve Gene Expression and Clinical Information from UCSC Xena for Survival Analysis: https://shixiangwang.github.io/home/en/post/ucscxenatools-201908/

[2]UCSC Xena datasets page: https://xenabrowser.net/datapages/

[3]https://shixiangwang.github.io/home/en/post/2020-07-22-ucscxenatools-single-gene/: https://shixiangwang.github.io/home/en/post/2020-07-22-ucscxenatools-single-gene/

[4]XQuery: https://github.com/ropensci/UCSCXenaTools/tree/master/inst/queries

[5]UCSCXenaShiny: https://github.com/openbiox/UCSCXenaShiny/

[6]Introduction and basic usage of UCSCXenaTools: https://shixiangwang.github.io/home/en/tools/ucscxenatools-intro

[7]UCSCXenaTools: Retrieve Gene Expression and Clinical Information from UCSC Xena for Survival Analysis: https://shixiangwang.github.io/home/en/post/ucscxenatools-201908/

[8]Obtain RNAseq Values for a Specific Gene in Xena Database: https://shixiangwang.github.io/home/en/post/2020-07-22-ucscxenatools-single-gene/

[9]UCSC Xena Access APIs in UCSCXenaTools: https://shixiangwang.github.io/home/en/tools/ucscxenatools-api