拆分你的百萬級別單細胞數據集後做降維聚類分群
有粉絲在交流羣提問說看到了2022的一個泛癌文章但是數據量有點大以至於他自己的個人電腦或者課題組服務器都沒辦法hold住,標題是 :《Pan-cancer single-cell analysis reveals the heterogeneity and plasticity of cancer- associated fibroblasts in the tumor microenvironment》,這個泛癌單細胞數據挖掘文章納入了很多不同癌症的單細胞轉錄組數據集做了一個彙總的降維聚類分羣,如下所示:
因爲納入的數據集有點多,來源於12篇文章:232 single cell transcriptome samples (normal = 31; adjacent = 54; tumor = 148) ,分別來源於:
31 GSM samples were derived from GSE134355 11 GSM samples wererelated to GSE141445 49 samples were derived from the under accession numberE-MTAB-8107 2 GSM samples were associated with GSE157703 22 GSMsamples were derived from GSE131907 7 GSM samples were derived fromGSE138709 31 samples were derived from the under accession number E-MTAB-6149 and E-MTAB-6653 32 CRR samples were related to GSA database underaccession number CRA001160 10 GSM samples were related to GSE154778 7 HRR samples were available in GSA-Human under the accession codeHRA000212 10 thyroid samples were derived from GSA-Human databaseunder accession number HRA000686 20 gastric samples were download from http://dna-discovery.stanford.edu/download/1401/;
並不需要自己去重新分析上面的12個文章的12個數據集了,因爲作者直接就在 GSE210347 數據集給出來了表達量矩陣文件 (GSE210347_counts.Rds.gz ),如下所示:
GSE210347_counts.Rds.gz 2.4 Gb (ftp)(http) RDS
GSE210347_meta.txt.gz 18.5 Mb (ftp)(http) TXT
GSE210347_sample_information.txt.gz 632 b (ftp)(http) TXT
GSE210347_study_metadata.xls.gz 39.8 Kb (ftp)(http) XLS
其實這個甚至都不需要自己做降維聚類分羣了,因爲本來就是有對應的GSE210347_meta.txt.gz 18.5 Mb 文件,裏面就給每個細胞一個身份了。如果假設作者沒有提供,我們就需要加載作者的表達量矩陣文件 (GSE210347_counts.Rds.gz )然後走降維聚類分羣流程啦。
拆分這個表達量矩陣
我做了一個簡單的 操作:
tmp = readRDS('../inputs/GSE210347_counts.Rds')
dim(tmp) # [1] 42113 855271
half_cols <- ceiling(ncol(tmp) / 2);half_cols
### part 1
sce.all=CreateSeuratObject(
counts = tmp[,1:half_cols]
)
### part 2
sce.all=CreateSeuratObject(
counts = tmp[,(half_cols+1):ncol(tmp)]
)
上面的 855271 個細胞,被我平等的拆分成爲了兩個矩陣後各自構建了 Seurat對象,只需要對 兩個 sce.all 變量 走我們的降維聚類分羣流程即可。唯一的區別就是文章裏面的分羣UMAP圖就是一個:
但是我們把表達量矩陣拆分了,所以就會跑出來多個分羣UMAP圖,不過這個並不重要,因爲我們之所以要跑降維聚類分羣流程就是爲了給細胞一個身份,這個過程甚至是可以免去降維聚類分羣流程的,因爲有很多自動化註釋軟件,它們是針對具體的每個單細胞本身獨立的註釋。
比如,我們可以使用作者的降維聚類分羣和細胞亞羣命名結果來驗證一下我們的拆分成爲兩個單細胞表達量矩陣之後的結果:
library(data.table)
tmp = fread('../inputs/GSE210347_meta.txt.gz',
data.table = F)
> colnames(tmp)
[1] "cellname" "nCount_RNA" "nFeature_RNA"
[4] "SampleID" "percent.mt" "seurat_clusters"
[7] "cluster" "celltype" "tissue"
[10] "group"
> table(tmp$celltype)
Endothelium Epithelium Erythrocyte Fibroblast Lymphocyte Myeloid
74102 268469 3295 104804 202077 151298
Plasma undefined
37638 13588
如下所示,哪怕是拆分了,結果仍然是還不錯:
而且絕大部分小夥伴拿到了主要的百萬級別單細胞轉錄組數據集,其實並不會關心全局情況,應該是會挑選裏面的具體的某個單細胞亞羣,比如癌症相關成纖維細胞,然後對它繼續細緻的降維聚類分羣后討論它的臨牀意義。
當然了,如果你想完成上面的操作,最好是有自己的計算機資源哦,比如我們的2024的共享服務器交個朋友福利價仍然是800,而且還需要有基本的生物信息學基礎,也可以看看我們的生物信息學馬拉松授課(買一得五) ,你的生物信息學入門課。
如果你有了生物信息學基礎,僅僅是感興趣單細胞的細緻分析,就看看SBC的 Nature年度技術 | 單細胞及空間多組學實驗技術與生信分析培訓(暑期班)招生火熱進行中