R NMF包:如何提取样本分类?

问题描述 投票:0回答:3

在 NMF R 包中,可以使用consensusmap() 来可视化输出。这些图显示了哪些样本属于“共识”轨道中的哪些集群。

我想提取此示例分类,以便获得如下数据框:

Sample    Cluster
S1        1
S2        1
S3        2
S4        1
.         .
.         .
S100      2

在 ConsensusClusterPlus 包中这很简单。你只需取出结果$consensusClass。我找不到 NMF 包的类似解决方案。我试图查看原始绘图数据,但它太复杂,无法从中提取任何含义。

这里有一个问题的说明:我需要找出哪个“状态”属于哪个“共识”。

r cluster-analysis consensus nmf
3个回答
1
投票

遍历整棵树并数数?

> v <- syntheticNMF(20, 3, 10)

> xx<-consensusmap(x) 

> str(xx)
List of 4
$ Rowv  :  ..--[dendrogram w/ 2 branches and 10 members at h = 1,  midpoint = 5.97, value = 3.4]
  ..  |--[dendrogram w/ 2 branches and 7 members at h = 1, midpoint = 3.69, value = 2.5]
  ..  |  |--[dendrogram w/ 2 branches and 4 members at h = 0, midpoint = 2.12, value = 1.6]
  ..  |  |  |--[dendrogram w/ 2 branches and 3 members at h = 0, midpoint = 1.25, value = 1.2]
  ..  |  |  |  |--[dendrogram w/ 2 branches and 2 members at h = 0, midpoint = 0.5, value = 0.8]
  ..  |  |  |  |  |--leaf "2" ( value.2 = 0.4 )
  ..  |  |  |  |  `--leaf "1" ( value.1 = 0.4 )
  ..  |  |  |  `--leaf "3" ( value.3 = 0.4 )
  ..  |  |  `--leaf "4" ( value.4 = 0.4 )
  ..  |  `--[dendrogram w/ 2 branches and 3 members at h = 0, midpoint = 1.25, value = 0.9]
  ..  |     |--[dendrogram w/ 2 branches and 2 members at h = 0, midpoint = 0.5, value = 0.6]
  ..  |     |  |--leaf "6" ( value.6 = 0.3 )
  ..  |     |  `--leaf "5" ( value.5 = 0.3 )
  ..  |     `--leaf "7" ( value.7 = 0.3 )
  ..  `--[dendrogram w/ 2 branches and 3 members at h = 0, midpoint = 1.25, value = 0.9]
  ..     |--[dendrogram w/ 2 branches and 2 members at h = 0, midpoint = 0.5, value = 0.6]
  ..     |  |--leaf "9" ( value.9 = 0.3 )
  ..     |  `--leaf "8" ( value.8 = 0.3 )
  ..     `--leaf "10" ( value.10 = 0.3 )
  $ rowInd: int [1:10] 2 1 3 4 6 5 7 9 8 10
  $ Colv  :  ..--[dendrogram w/ 2 branches and 10 members at h = 1, midpoint = 3.03, value = 3.4]
  ..  |--[dendrogram w/ 2 branches and 3 members at h = 0, midpoint = 0.75, value = 0.9]
  ..  |  |--leaf "10" ( value.10 = 0.3 )
  ..  |  `--[dendrogram w/ 2 branches and 2 members at h = 0, midpoint = 0.5, value = 0.6]
  ..  |     |--leaf "8" ( value.8 = 0.3 )
  ..  |     `--leaf "9" ( value.9 = 0.3 )
  ..  `--[dendrogram w/ 2 branches and 7 members at h = 1, midpoint = 2.31, value = 2.5]
  ..     |--[dendrogram w/ 2 branches and 3 members at h = 0, midpoint = 0.75, value = 0.9]
  ..     |  |--leaf "7" ( value.7 = 0.3 )
  ..     |  `--[dendrogram w/ 2 branches and 2 members at h = 0, midpoint = 0.5, value = 0.6]
  ..     |     |--leaf "5" ( value.5 = 0.3 )
  ..     |     `--leaf "6" ( value.6 = 0.3 )
  ..     `--[dendrogram w/ 2 branches and 4 members at h = 0, midpoint = 0.875, value = 1.6]
  ..        |--leaf "4" ( value.4 = 0.4 )
  ..        `--[dendrogram w/ 2 branches and 3 members at h = 0, midpoint = 0.75, value = 1.2]
  ..           |--leaf "3" ( value.3 = 0.4 )
  ..           `--[dendrogram w/ 2 branches and 2 members at h = 0, midpoint = 0.5, value = 0.8]
  ..              |--leaf "1" ( value.1 = 0.4 )
  ..              `--leaf "2" ( value.2 = 0.4 )
 $ colInd: int [1:10] 10 8 9 7 5 6 4 3 1 2


> lapply(cut(xx$Rowv,0.5)$lower, function(l) rapply(l, function(i) i))
[[1]]
[1] 2 1 3 4

[[2]]
[1] 6 5 7

[[3]]
[1]  9  8 10

0
投票
NMF::predict(NMFfitX_object, what = "consensus")

如果您有 NMF.rank 类的对象,则可以通过以下方式访问包含的 NMFfitX 对象(Rank = 3):

NMF.rank_object$fit$`3`

0
投票

我想我已经找到答案了

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.