提问人:Anon 提问时间:11/4/2023 更新时间:11/4/2023 访问量:17
kmeans(mat, centers) 中的错误:聚类中心多于不同的数据点
Error in kmeans(mat, centers) : more cluster centers than distinct data points
问:
我想使用 ComplexHeatmap 包为我的输入绘制热图。
对行应用 k 均值聚类。如果该值大于 1,则热图将根据 k 均值聚类按行进行拆分。mrna_deconv
row_km
法典:
library(ComplexHeatmap)
row_km = ncol(t(mrna_deconv))-1
Heatmap(t(as.matrix(t(mrna_deconv))), name = "mRNA", row_km = row_km, col=mrna.col, show_row_names=TRUE, show_column_names=FALSE, show_row_dend=FALSE)
追踪:
Error in kmeans(mat, centers) :
more cluster centers than distinct data points.
输入:
> dim(mrna_deconv)
[1] 28 166
> dput(mrna_deconv[1:10,1:10])
structure(list(TCGA.2Z.A9J1.01 = c(0, 0.0409227767244807, 0,
0, 0, 0, 0.351617771147991, 0.0874153582385608, 0, 0.181772456644037
), TCGA.2Z.A9J3.01 = c(0, 0.02991533249762, 0, 0, 0, 0, 0.340011889094215,
0.108785286587523, 0, 0.199858678474956), TCGA.2Z.A9J6.01 = c(0,
0.0296918459782142, 0, 0, 0, 0, 0.296641234912303, 0.100551635314064,
0, 0.164095782525901), TCGA.2Z.A9J7.01 = c(0, 0.0197225903735211,
0, 0, 0, 0.005625184851424, 0.265789421116835, 0.11036843733851,
0, 0.190301998904762), TCGA.2Z.A9J8.01 = c(0, 0.0506430272529989,
0, 0, 0, 0, 0.321750942332837, 0.07680559708907, 0, 0.146217739550562
), TCGA.2Z.A9JI.01 = c(0, 0.0289269562400886, 0, 0, 0, 0.0467023827588638,
0.0904484780838239, 0.107838580255164, 0.0529934482238177, 0.144075063451225
), TCGA.2Z.A9JJ.01 = c(0, 0.0203195082892011, 0, 0, 0, 0, 0.33893336182288,
0.0501685493926867, 0, 0.272718188315665), TCGA.2Z.A9JQ.01 = c(0,
0.00872511598871086, 0, 0, 0, 0, 0.328168453426525, 0.0856889817939333,
0, 0.149557465101895), TCGA.4A.A93W.01 = c(0, 0.0198721808021985,
0, 0, 0, 0, 0.0921068773935397, 0.103863526495157, 0.0978161334714752,
0.183588973080623), TCGA.4A.A93X.01 = c(0, 0.0458104097651123,
0, 0, 0, 0.055944046487111, 0.106248085127836, 0.087253111672165,
0.0346258754734651, 0.160117115506731)), row.names = c("B.cell",
"CD16..Monocyte", "CD1C..DC", "CLEC9A..DC", "CXCL10.Hi.TAM",
"Cycling.CD8..T.cell", "Cycling.TAM", "Effector.T.Helper", "Endothelial",
"FGFBP2..NK"), class = "data.frame")
答: 暂无答案
评论
heatmap(as.matrix(mrna_deconv))