ConsensusClusterPlus: R中實(shí)現(xiàn)鑒定簇集數(shù)及其成員的算法

無監(jiān)督分析下鑒定簇集數(shù)及成員

Wilkerson, D. M, Hayes, Neil D (2010). “ConsensusClusterPlus: a class discovery tool with confidence assessments and item tracking.” Bioinformatics, 26(12), 1572-1573. http://bioinformatics.oxfordjournals.org/content/26/12/1572.abstract.

1. 關(guān)于 ConsensusClusterPlus

  • Consensus Clustering 是一種可用于鑒定數(shù)據(jù)集(比如 microarray 基因表達(dá))中的簇集 (clusters) 成員及其數(shù)量的算法司蔬。ConsensusClusterPlus 則將 Consensus Clustering 在 R 中實(shí)現(xiàn)了。

  • Jimmy大神說這是他見過最簡單的包┑( ̄Д  ̄)┍

library(ConsensusClusterPlus)
ls("package:ConsensusClusterPlus")
# [1] "calcICL"              "ConsensusClusterPlus"

ConsensusClusterPlus function for determing cluster number and class membership by stability evidence.

calcICL function for calculating cluster-consensus and item-consensus.

2. 好像真的很簡單 只是操作簡單

使用 ConsensusClusterPlus 的主要三個(gè)步驟:

  • 準(zhǔn)備輸入數(shù)據(jù)
  • 跑程序
  • 計(jì)算聚類一致性 (cluster-consensus) 和樣品一致性 (item-consensus)

3. 準(zhǔn)備輸入數(shù)據(jù)

首先收集用于聚類分析的數(shù)據(jù)殖侵,比如 mRNA 表達(dá)微陣列或免疫組織化學(xué)染色強(qiáng)度的實(shí)驗(yàn)結(jié)果數(shù)據(jù)。輸入數(shù)據(jù)的格式應(yīng)為矩陣。下面以 ALL 基因表達(dá)數(shù)據(jù)為例進(jìn)行操作误窖。

library(ALL)
data(ALL)
dataset <- exprs(ALL)
dataset[1:5,1:5]
#              01005    01010    03002    04006    04007
# 1000_at   7.597323 7.479445 7.567593 7.384684 7.905312
# 1001_at   5.046194 4.932537 4.799294 4.922627 4.844565
# 1002_f_at 3.900466 4.208155 3.886169 4.206798 3.416923
# 1003_s_at 5.903856 6.169024 5.860459 6.116890 5.687997
# 1004_at   5.925260 5.912780 5.893209 6.170245 5.615210

取矩陣中 MAD 值 top 5000 的數(shù)據(jù):

mads <- apply(dataset, 1, mad)
dataset <- dataset[rev(order(mads))[1:5000],]
dim(dataset)
# [1] 5000  128

4. 運(yùn)行 ConsensusClusterPlus

先設(shè)定幾個(gè)參數(shù):

  • pItem (item resampling, proportion of items to sample) : 80%
  • pFeature (gene resampling, proportion of features to sample) : 80%
  • maxK (a maximum evalulated k, maximum cluster number to evaluate) : 6
  • reps (resamplings, number of subsamples) : 50
  • clusterAlg (agglomerative heirarchical clustering algorithm) : 'hc' (hclust)
  • distance : 'pearson' (1 - Pearson correlation)
# title <- tempdir() ## 雖說是“當(dāng)前文件夾”阿趁,但似乎結(jié)果會(huì)輸出到包的安裝路徑...
## 所以還是??
title <- “YOUR PATH”
results <- ConsensusClusterPlus(dataset, maxK = 6,
                                reps = 50, pItem = 0.8,
                                pFeature = 0.8,  
                                clusterAlg = "hc", 
                                distance = "pearson",
                                title = title,
                                plot = "png")  
## 作者這里是pFeature = 1僵芹,和前文不符邀跃,于是我依然是按0.8輸入計(jì)算的

這時(shí)工作路徑的文件夾會(huì)出現(xiàn)9張圖霉咨。

查看一下結(jié)果:

results[[2]][["consensusMatrix"]][1:5,1:5] 
#         [,1]      [,2]      [,3]    [,4]      [,5]
# [1,] 1.00000 0.9375000 1.0000000 0.90625 1.0000000
# [2,] 0.93750 1.0000000 0.9677419 1.00000 0.9393939
# [3,] 1.00000 0.9677419 1.0000000 0.93750 1.0000000
# [4,] 0.90625 1.0000000 0.9375000 1.00000 0.9062500
# [5,] 1.00000 0.9393939 1.0000000 0.90625 1.0000000
results[[2]][["consensusTree"]] 
# Call:
# hclust(d = as.dist(1 - fm), method = finalLinkage)
# 
# Cluster method   : average 
# Number of objects: 128 
results[[2]][["consensusClass"]][1:5] 
# 01005 01010 03002 04006 04007 
#     1     1     1     1     1 

4.1 一致性矩陣

分別為圖例、k = 2, 3, 4, 5 時(shí)的矩陣熱圖坞嘀。

4.2 一致性累積分布函數(shù)圖

This figure allows a user to determine at what number of clusters, k, the CDF

reaches an approximate maximum, thus consensus and cluster con dence is at

a maximum at this k.

4.3 Delta Area Plot

The delta area score (y-axis) indicates the relative increase in cluster stability.

4.4 Tracking Plot

This plot provides a view of item cluster membership across different k and enables a user to track the history of clusters relative to earlier clusters.

5. 計(jì)算聚類一致性 (cluster-consensus) 和樣品一致性 (item-consensus)

icl <- calcICL(results, title = title,
               plot = "png")
## 返回了具有兩個(gè)元素的list躯护,然后分別查看一下
dim(icl[["clusterConsensus"]])
# [1] 20  3
icl[["clusterConsensus"]] 
#       k cluster clusterConsensus
#  [1,] 2       1        0.9402982
#  [2,] 2       2        0.9062500
#  [3,] 3       1        0.8504193
#  [4,] 3       2        0.9062500
#  [5,] 3       3        0.9869781
#  [6,] 4       1        0.9652282
#  [7,] 4       2        0.9045058
#  [8,] 4       3        0.9062500
#  [9,] 4       4        0.9728043
# [10,] 5       1        0.9216686
# [11,] 5       2        0.9145987
# [12,] 5       3        0.9062500
# [13,] 5       4        0.9874950
# [14,] 5       5              NaN
# [15,] 6       1        0.9307379
# [16,] 6       2        0.8897721
# [17,] 6       3        0.7474747
# [18,] 6       4        0.8750000
# [19,] 6       5        0.9885269
# [20,] 6       6        0.6333333
dim(icl[["itemConsensus"]])
# [1] 2560    4
icl[["itemConsensus"]][1:5,] 
#   k cluster  item itemConsensus
# 1 2       1 28032     0.9523526
# 2 2       1 28024     0.9366226
# 3 2       1 03002     0.9686272
# 4 2       1 01005     0.9573623
# 5 2       1 04007     0.9549235

5.1 Cluster-Consensus Plot

5.2 tem-Consensus Plot

References


最后,向大家隆重推薦生信技能樹的一系列干貨丽涩!

  1. 生信技能樹全球公益巡講:https://mp.weixin.qq.com/s/E9ykuIbc-2Ja9HOY0bn_6g
  2. B站公益74小時(shí)生信工程師教學(xué)視頻合輯:https://mp.weixin.qq.com/s/IyFK7l_WBAiUgqQi8O7Hxw
  3. 招學(xué)徒:https://mp.weixin.qq.com/s/KgbilzXnFjbKKunuw7NVfw
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市裁蚁,隨后出現(xiàn)的幾起案子矢渊,更是在濱河造成了極大的恐慌,老刑警劉巖枉证,帶你破解...
    沈念sama閱讀 218,682評論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件矮男,死亡現(xiàn)場離奇詭異,居然都是意外死亡室谚,警方通過查閱死者的電腦和手機(jī)毡鉴,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,277評論 3 395
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來秒赤,“玉大人猪瞬,你說我怎么就攤上這事∪肜海” “怎么了陈瘦?”我有些...
    開封第一講書人閱讀 165,083評論 0 355
  • 文/不壞的土叔 我叫張陵,是天一觀的道長潮售。 經(jīng)常有香客問我痊项,道長,這世上最難降的妖魔是什么酥诽? 我笑而不...
    開封第一講書人閱讀 58,763評論 1 295
  • 正文 為了忘掉前任鞍泉,我火速辦了婚禮,結(jié)果婚禮上肮帐,老公的妹妹穿的比我還像新娘咖驮。我一直安慰自己,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,785評論 6 392
  • 文/花漫 我一把揭開白布游沿。 她就那樣靜靜地躺著饰抒,像睡著了一般。 火紅的嫁衣襯著肌膚如雪诀黍。 梳的紋絲不亂的頭發(fā)上袋坑,一...
    開封第一講書人閱讀 51,624評論 1 305
  • 那天,我揣著相機(jī)與錄音眯勾,去河邊找鬼枣宫。 笑死,一個(gè)胖子當(dāng)著我的面吹牛吃环,可吹牛的內(nèi)容都是我干的也颤。 我是一名探鬼主播,決...
    沈念sama閱讀 40,358評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼郁轻,長吁一口氣:“原來是場噩夢啊……” “哼翅娶!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起好唯,我...
    開封第一講書人閱讀 39,261評論 0 276
  • 序言:老撾萬榮一對情侶失蹤竭沫,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后骑篙,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體蜕提,經(jīng)...
    沈念sama閱讀 45,722評論 1 315
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,900評論 3 336
  • 正文 我和宋清朗相戀三年靶端,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了谎势。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 40,030評論 1 350
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡杨名,死狀恐怖脏榆,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情镣煮,我是刑警寧澤姐霍,帶...
    沈念sama閱讀 35,737評論 5 346
  • 正文 年R本政府宣布,位于F島的核電站典唇,受9級(jí)特大地震影響镊折,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜介衔,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,360評論 3 330
  • 文/蒙蒙 一恨胚、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧炎咖,春花似錦赃泡、人聲如沸寒波。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,941評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽俄烁。三九已至,卻和暖如春级野,著一層夾襖步出監(jiān)牢的瞬間页屠,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,057評論 1 270
  • 我被黑心中介騙來泰國打工蓖柔, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留辰企,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 48,237評論 3 371
  • 正文 我出身青樓况鸣,卻偏偏與公主長得像牢贸,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個(gè)殘疾皇子镐捧,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,976評論 2 355