R語言使用cgdsr包獲取TCGA數(shù)據(jù)示例詳解
TCGA數(shù)據(jù)源
眾所周知,TCGA數(shù)據(jù)庫是目前最綜合全面的癌癥病人相關(guān)組學(xué)數(shù)據(jù)庫,包括的測序數(shù)據(jù)有:
DNA Sequencing
miRNA Sequencing
Protein Expression
mRNA Sequencing
Total RNA Sequencing
Array-based Expression
DNA Methylation
Copy Number
TCGA數(shù)據(jù)庫探索工具
知名的腫瘤研究機構(gòu)都有著自己的TCGA數(shù)據(jù)庫探索工具,比如:
Broad Institute FireBrowse portal, The Broad Institute
cBioPortal for Cancer Genomics, Memorial Sloan-Kettering Cancer Center
TCGA Batch Effects, MD Anderson Cancer Center
Regulome Explorer, Institute for Systems Biology
Next-Generation Clustered Heat Maps, MD Anderson Cancer Center
其中cBioPortal更是被包裝到R包里面
這里介紹如何使用R語言的cgdsr包來獲取任意TCGA數(shù)據(jù)。
cgdsr包:R語言工具包,可以下載TCGA數(shù)據(jù)。
DT包:data.table包,簡稱DT包,是R語言中的數(shù)據(jù)可視化工具包。DT包可以將Javascript中的方法運用到R中,也能將矩陣或者數(shù)據(jù)表在網(wǎng)頁中可視化為表格,以及其它的一些功能。
> setwd("C:/Users/YLAB/Documents/R/win-library/4.1/") > install.packages("R.methodsS3_1.8.1.zip",repos=NULL)#安裝 > install.packages("R.oo_1.24.0.zip",repos=NULL)#安裝 > install.packages("data.table") > BiocManager::install("cgdsr", force = TRUE)#安裝 > library(cgdsr) > library(DT) #創(chuàng)建一個cgdsr對象 > mycgds <- CGDS("http://www.cbioportal.org/") #檢查下載是否成功,如果是FAILED就是沒成功。 > test(mycgds) getCancerStudies... OK getCaseLists (1/2) ... OK getCaseLists (2/2) ... OK getGeneticProfiles (1/2) ... OK getGeneticProfiles (2/2) ... OK getClinicalData (1/1) ... OK getProfileData (1/6) ... OK getProfileData (2/6) ... OK getProfileData (3/6) ... OK getProfileData (4/6) ... OK getProfileData (5/6) ... OK getProfileData (6/6) ... OK all_TCGA_studies <- getCancerStudies(mycgds) > DT::datatable(all_TCGA_studies)
查看任意數(shù)據(jù)集的樣本列表方式
上表的cancer_study_id其實就是數(shù)據(jù)集的名字,我們?nèi)我膺x擇一個數(shù)據(jù)集,比如stad_tcga_pub ,可以查看它里面有多少種樣本列表方式。
stad2014 <- "stad_tcga_pub" ## 獲取在stad2014數(shù)據(jù)集中有哪些表格(每個表格都是一個樣本列表) all_tables <- getCaseLists(mycgds, stad2014) dim(all_tables) ## 共6種樣本列表方式 [1] 6 5 DT::datatable(all_tables[,1:3])
查看任意數(shù)據(jù)集的數(shù)據(jù)形式
## 而后獲取可以下載哪幾種數(shù)據(jù),一般是mutation,CNV和表達量數(shù)據(jù) all_dataset <- getGeneticProfiles(mycgds, stad2014) DT::datatable(all_dataset, extensions = 'FixedColumns', options = list( #dom = 't', scrollX = TRUE, fixedColumns = TRUE ))
一般來說,TCGA的一個項目數(shù)據(jù)就幾種,如下:
選定數(shù)據(jù)形式及樣本列表后獲取感興趣基因的信息,下載mRNA數(shù)據(jù)
my_dataset <- 'stad_tcga_pub_rna_seq_v2_mrna' my_table <- "stad_tcga_pub_rna_seq_v2_mrna" BRCA1 <- getProfileData(mycgds, "BRCA1", my_dataset, my_table) dim(BRCA1) [1] 265 1
樣本個數(shù)差異很大,不同癌癥熱度不一樣。
選定樣本列表獲取臨床信息
## 如果我們需要繪制survival curve,那么需要獲取clinical數(shù)據(jù) clinicaldata <- getClinicalData(mycgds, my_table) DT::datatable(clinicaldata, extensions = 'FixedColumns', options = list( #dom = 't', scrollX = TRUE, fixedColumns = TRUE ))
綜合性獲取
只需要根據(jù)癌癥列表選擇自己感興趣的研究數(shù)據(jù)集即可,然后選擇好感興趣的數(shù)據(jù)形式及對應(yīng)的樣本量。就可以獲取對應(yīng)的信息:
library(cgdsr) library(DT) mycgds <- CGDS("http://www.cbioportal.org") ##mycancerstudy = getCancerStudies(mycgds)[25,1] mycancerstudy = 'brca_tcga' getCaseLists(mycgds,mycancerstudy)[,1] ## [1] "brca_tcga_3way_complete" "brca_tcga_all" ## [3] "brca_tcga_protein_quantification" "brca_tcga_sequenced" ## [5] "brca_tcga_cna" "brca_tcga_methylation_hm27" ## [7] "brca_tcga_methylation_hm450" "brca_tcga_mrna" ## [9] "brca_tcga_rna_seq_v2_mrna" "brca_tcga_rppa" ## [11] "brca_tcga_cnaseq"
getGeneticProfiles(mycgds,mycancerstudy)[,1] ## [1] "brca_tcga_rppa" ## [2] "brca_tcga_rppa_Zscores" ## [3] "brca_tcga_protein_quantification" ## [4] "brca_tcga_protein_quantification_zscores" ## [5] "brca_tcga_gistic" ## [6] "brca_tcga_mrna" ## [7] "brca_tcga_mrna_median_Zscores" ## [8] "brca_tcga_rna_seq_v2_mrna" ## [9] "brca_tcga_rna_seq_v2_mrna_median_Zscores" ## [10] "brca_tcga_linear_CNA" ## [11] "brca_tcga_methylation_hm450" ## [12] "brca_tcga_mutations"
下載mRNA數(shù)據(jù)
mycaselist ='brca_tcga_rna_seq_v2_mrna' mygeneticprofile = 'brca_tcga_rna_seq_v2_mrna' # Get data slices for a specified list of genes, genetic profile and case list expr=getProfileData(mycgds,c('BRCA1','BRCA2'),mygeneticprofile,mycaselist) DT::datatable(expr)
很簡單就得到了指定基因在指定癌癥的表達量
獲取病例列表的臨床數(shù)據(jù)
myclinicaldata = getClinicalData(mycgds,mycaselist) DT::datatable(myclinicaldata, extensions = 'FixedColumns', options = list( #dom = 't', scrollX = TRUE, fixedColumns = TRUE )) ## Warning in instance$preRenderHook(instance): It seems your data is too ## big for client-side DataTables. You may consider server-side processing: ## http://rstudio.github.io/DT/server.html
從cBioPortal下載點突變信息
#突變基因名稱集合 mutGene=c("EGFR", "PTEN", "TP53", "ATRX") #檢索基因和遺傳圖譜的基因組圖譜數(shù)據(jù) mut_df <- getProfileData(mycgds, caseList ="gbm_tcga_sequenced", geneticProfile = "gbm_tcga_mutations", genes = mutGene ) mut_df <- apply(mut_df,2,as.factor) mut_df[mut_df == "NaN"] = "" mut_df[is.na(mut_df)] = "" mut_df[mut_df != ''] = "MUT" DT::datatable(mut_df)
從cBioPortal下載拷貝數(shù)變異數(shù)據(jù)
mutGene=c("TP53","UGT2B7","CYP3A4") cna<-getProfileData(mycgds,mutGene,"gbm_tcga_gistic","gbm_tcga_sequenced") cna<-apply(cna,2,function(x) as.character(factor(x,levels = c(-2:2),labels = c("HOMDEL","HETLOSS","DIPLOID","GAIN","AMP")))) cna[is.na(cna)]="" cna[cna=="DIPLOID"]="" DT::datatable(cna)
把拷貝數(shù)及點突變信息結(jié)合畫熱圖
下面的函數(shù),主要是配色比較復(fù)雜,其實原理很簡單,就是一個熱圖。
library(ComplexHeatmap) library(grid) conb <- data.frame(matrix(paste(as.matrix(cna),as.matrix(mut_df),sep = ";"), nrow=nrow(cna),ncol=ncol(cna), dimnames=list(row.names(mut_df),colnames(cna)))) mat <- as.matrix(t(conb)) DT::datatable((mat)) alt <- apply(mat,1,function(x)strsplit(x,";")) alt <- unique(unlist(alt)) alt <- alt[which(alt !="")] alt <-c("background",alt) alter_fun = list( background = function(x,y,w,h){ grid.rect(x,y,w-unit(0.5,"mm"),h-unit(0.5,"mm"), gp=gpar(fill="#CCCCCC",col=NA)) }, HOMDEL = function(x,y,w,h){ grid.rect(x,y,w-unit(0.5,"mm"),h-unit(0.5,"mm"), gp=gpar(fill="blue3",col=NA)) }, HETLOSS = function(x,y,w,h){ grid.rect(x,y,w-unit(0.5,"mm"),h-unit(0.5,"mm"), gp=gpar(fill="cadetblue1",col=NA)) }, GAIN = function(x,y,w,h){ grid.rect(x,y,w-unit(0.5,"mm"),h-unit(0.5,"mm"), gp=gpar(fill="pink",col=NA)) }, AMP = function(x,y,w,h){ grid.rect(x,y,w-unit(0.5,"mm"),h-unit(0.5,"mm"), gp=gpar(fill="red",col=NA)) }, MUT = function(x,y,w,h){ grid.rect(x,y,w-unit(0.5,"mm"),h-unit(0.5,"mm"), gp=gpar(fill="#008000",col=NA)) }) col <- c("MUT"="#008000","AMP"="red","HOMDEL"="blue3", "HETLOSS"="cadetblue1","GAIN"="pink") alt = intersect(names(alter_fun),alt) alt_fun_list <- alter_fun[alt] col <- col[alt] oncoPrint(mat=mat,alter_fun = alt_fun_list, get_type = function(x) strsplit(x,";")[[1]], col = col)
以上就是R語言使用cgdsr包獲取TCGA數(shù)據(jù)示例詳解的詳細內(nèi)容,更多關(guān)于R語言cgdsr獲取TCGA數(shù)據(jù)的資料請關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
R語言利用loess如何去除某個變量對數(shù)據(jù)的影響詳解
這篇文章主要給大家介紹了關(guān)于R語言利用loess去除某個變量對數(shù)據(jù)的影響的相關(guān)資料,文中通過示例代碼介紹的非常詳細,對大家學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。2017-11-11R語言數(shù)據(jù)可視化ggplot添加左右y軸繪制天貓雙十一銷售圖
本篇文章主要介紹如何在R中,使用ggplot2包在一個圖像上添加左右兩個 y 軸刻度,并在同一個圖像上繪制兩個完全不一樣的統(tǒng)計圖,有需要的朋友可以借鑒參考下2021-11-11R包clusterProfiler如何安裝成功(新手必看!)
最近在我以為ClusterProfiler已經(jīng)安裝好的時候,又遇到了一些問題,所以這篇文章主要給大家介紹了關(guān)于R包clusterProfiler如何安裝成功的相關(guān)資料,需要的朋友可以參考下2023-02-02R語言RCode與RStudio使用對比體驗分析總結(jié)
這篇文章主要為大家介紹了R語言RCode與RStudio使用對比體驗分析總結(jié),有需要的朋友可以借鑒參考下,希望能夠有所幫助祝大家多多進步2021-11-11詳解R語言MCMC:Metropolis-Hastings采樣用于回歸的貝葉斯估計
這篇文章主要介紹了R語言MCMC:Metropolis-Hastings采樣用于回歸的貝葉斯估計,本文通過圖文實例相結(jié)合給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2021-03-03