很多人因為網(wǎng)絡(luò)原因不能使用TCGAbiolinks這個神包下載TCGA的RNA-seq數(shù)據(jù),只能通過瀏覽器訪問GDC TCGA的官網(wǎng)進行下載,而下載后得到的是一個個文件夾,對于如何整理成一個表達矩陣也是很麻煩的。
今天給大家介紹一個簡單點的方法,使用TCGAbiolinks包整理你通過瀏覽器官網(wǎng)下載的rna-seq數(shù)據(jù)。
下載新版TCGA的數(shù)據(jù)建議使用我之前的教程:TCGA下載和表達矩陣整理:最適合初學者的教程 - 簡書 (jianshu.com),不然會報錯。
通常大家通過瀏覽器下載后會得到下面的這種很多個文件夾:

這時候你可以通過之前介紹過的方法得到表達矩陣:新版TCGA數(shù)據(jù)庫表達矩陣整理
但是這個方法對于新手還是不夠友好,尤其是根據(jù)Json文件匹配數(shù)據(jù)時,但是TCGA表達量數(shù)據(jù)又是很常用的,這個操作還是很高頻的需求。
前幾天學習TCGAbiolinks包時意外發(fā)現(xiàn),即使是手動下載的數(shù)據(jù),只要構(gòu)建合適的路徑,也是可以通過GDCprepare()函數(shù)進行整理從而簡單的得到表達矩陣的!
TCGAbiolinks包下載的表達量數(shù)據(jù)的文件路徑是有規(guī)律的,如果你沒有特別指明,通常是位于GDCdata\TCGA-COAD\harmonized\Transcriptome_Profiling\Gene_Expression_Quantification這個路徑下的。
這個包下載數(shù)據(jù)就是三板斧操作,query,download,prepare,而且最后GDCprepare()需要的還是GDCquery()得到的對象,因此我們完全可以通過構(gòu)建一個適合它的路徑,讓GDC_prepare()幫我們整理成表達矩陣!
比如我上面的各個樣本文件夾的路徑在我的電腦中是這樣的:G:\tcga\GDCdata\TCGA-COAD\harmonized\Transcriptome_Profiling\Gene_Expression_Quantification,我的get_expr.R腳本是放在G:\tcga這個路徑下的。
腳本內(nèi)容如下:一定要注意TCGAbiolinks包的版本!?。?/strong>
library(TCGAbiolinks)
## =============================================================
## ______ ___ ____ ___
## || | | | | | o __ | o _ __
## || | | ___ |___| |__ | | | | | | | | |_/ |__
## || |___ |____| | | |__| | |__| |__ | | |_| | \ __|
## ------------------------------------------------------------
## Query, download & analyze - GDC
## Version:2.25.2
## ==============================================================
# 查詢這一步是需要的!即使網(wǎng)在欄,這一步應(yīng)該可以成功的...
query <- GDCquery(project = "TCGA-COAD",
data.category = "Transcriptome Profiling",
data.type = "Gene Expression Quantification",
workflow.type = "STAR - Counts"
)
# 下載這一步就不用了,我們是通過官網(wǎng)手動下載的~
# GDCdownload(query, files.per.chunk = 100) #每次下載100個文件
# 整理
GDCprepare(query,save = T,save.filename = "example.rdata")
##|===============================================================================|100% ## Completed after 1 m
##Starting to add information to samples
## => Add clinical information to samples
## => Adding TCGA molecular information from marker papers
## => Information will have prefix 'paper_'
##coad subtype information from:doi:10.1038/nature11252
##Available assays in SummarizedExperiment :
## => unstranded
## => stranded_first
## => stranded_second
## => tpm_unstrand
## => fpkm_unstrand
## => fpkm_uq_unstrand
##=> Saving file: example.rdata
##=> File saved
這樣我們的數(shù)據(jù)就整理好了: 
下次使用直接load即可:
rm(list = ls())
load(file = "example.rdata")
se <- data
se
class: RangedSummarizedExperiment
dim: 60660 521
metadata(1): data_release
assays(6): unstranded stranded_first ... fpkm_unstrand fpkm_uq_unstrand
rownames(60660): ENSG00000000003.15 ENSG00000000005.6 ... ENSG00000288674.1 ENSG00000288675.1
rowData names(10): source type ... hgnc_id havana_gene
colnames(521): TCGA-A6-5664-01A-21R-1839-07 TCGA-D5-6530-01A-11R-1723-07 ...
TCGA-A6-2683-01A-01R-0821-07 TCGA-A6-2683-11A-01R-A32Z-07
colData names(107): barcode patient ... paper_vascular_invasion_present paper_vital_status
這個se就是我們之前介紹過的SummarizedExperiment對象,你可以對它進行各種操作,得到counts矩陣、tpm矩陣、fpkm矩陣都是小事一樁,猶如探囊取物一般簡單流暢! 詳情可參考之前的推文。
關(guān)于TCGA表達矩陣提取,告訴我,你還有哪里搞不定???