K Means Clustering Two Matrices for ComplexHeatmap
0
0
Entering edit mode
pthom010 • 0
@pthom010-23694
Last seen 9 weeks ago
United States

I have a csv file with the log2 scores of eight different timepoints. The header of the table looks like this:

head(templogs)

SB         SC         SD         SE
TRINITY_DN1001_c0_g1_i1  -0.5638283 -1.2861425 -0.8790812 -1.9667007
TRINITY_DN1001_c0_g1_i5  -0.3484778 -0.8097831 -0.3951722 -1.2755624
TRINITY_DN1001_c0_g2_i1  -0.4141790 -1.4300189 -1.0538773 -2.3604466
TRINITY_DN1001_c2_g1_i1  -0.3890476 -1.5069918 -0.9539496 -2.4254780
TRINITY_DN10027_c0_g1_i2 -0.2425431  0.4412087  0.4699400  0.7566083
TRINITY_DN10030_c0_g1_i1  1.0605554  0.4989614  0.2710047  0.8756346
RB         RC         RD        RE
TRINITY_DN1001_c0_g1_i1  -0.29717574 -0.8332547 -0.8467823 -1.343256
TRINITY_DN1001_c0_g1_i5  -0.45046536 -0.9659265 -1.1268979 -1.572577
TRINITY_DN1001_c0_g2_i1  -0.49264872 -1.0463790 -1.1199727 -1.916905
TRINITY_DN1001_c2_g1_i1  -0.58782459 -1.0346161 -1.0258695 -1.920455
TRINITY_DN10027_c0_g1_i2 -0.03957106  0.7577178  0.6700604  1.681934
TRINITY_DN10030_c0_g1_i1  4.94468049  5.6052340  6.0095423  4.954922


The table has about 2100 rows. What I would like to do is k-means clustering on the matrix and use those results to cluster my rows on a heatmap. However, I seem to be having issues with the hclust function in R. Here is how far I have gotten:

km = kmeans(templogs, centers = 2)$cluster  I then try to run rows = hclust(templogs)$order


but get the following error message:

Error in if is.na(n) || n > 65536L) stop("size cannot be NA nor exceed 65536") :
missing value where TRUE/FALSE needed


Would anybody by chance know how to resolve this issue. I am also trying to use the split function with the km$cluster object I made before but I am getting this error message: Error in Heatmap(templogs, row_order = rows, split = cluster) : object 'cluster' not found  complexheatmap R • 202 views ADD COMMENT 0 Entering edit mode Try rows = hclust(dist(temploogs))$order.