【发布时间】:2020-09-10 15:41:25
【问题描述】:
嘿,我是 R 的初学者,需要在接下来的几天内尽可能重现此热图。
我的数据是一个包含多张工作表的 xlsx 文件,我尽我所能清理了它,它的格式应该没问题。我有 2 个时间点 T0 和 T1 作为字符,所以我无法运行 pheatmap() 函数。
如何将热图划分为 T0 和 T1 并以正确的顺序构建样本 ID?
您是否有想法如何创建与给定示例尽可能相似的热图?
这是我在没有 T0 和 T1 数据的情况下在过去两天生成的热图,因为它们是字符而不是数值。现在我想将它们包括在内,并按照给定的热图正确排序 Samlple ID。
all_data2 <- cbind(amino,sphingo,hexoses,phospha,lyso,all_data)
matrix_data <- as.matrix(all_data2[, 3:73])
rownames(matrix_data) <- all_data2$`Sample Identification`
heatmap_final <- matrix_data[,!colnames(matrix_data) %in% c('Sample Identification.1','Sample Identification.2','Sample Identification')]
pheatmap(
mat = log2(heatmap_final),
scale = "column",
show_rownames = TRUE,
drop_levels = TRUE,
fontsize = 5,
clustering_method = "complete",
main = "Hierachical Cluster Analysis"
)
这是我现在包含 T0 和 T1 组的代码,但我无法运行它,因为 T 值是字符。 您将如何更改代码以尽可能好地重现给定的热图并改进我的?
all_data2 <- cbind(amino,sphingo,hexoses,phospha,lysophospha,acyl)
matrix_data <- as.matrix(all_data2[, 3:74])
rownames(matrix_data) <- all_data2$`Sample Identification`
heatmap_final <- matrix_data[,!colnames(matrix_data) %in% c('Sample Identification.1','Sample Identification.2','Sample Identification','Time point.1','Time point.2')]
pheatmap(
mat = log2(heatmap_final),
scale = "column",
show_rownames = TRUE,
drop_levels = TRUE,
fontsize = 5,
clustering_method = "complete",
main = "Hierachical Cluster Analysis"
)
此外,关于如何通过对数样条插补轻松插补 NA 的任何想法,因此结果数据不会改变。
【问题讨论】:
-
嘿@doc elfein,当
dput()函数的输出太大时,您可以对您的数据使用head()函数,仅提取表格的第一行,如下所示:@ 987654330@。最小可重现示例的想法不是访问您的所有数据,我们只需要重现您的问题所必需的。 -
您的 dput() 仍然太大。 (以“66.3”开头)因此我们无法复制您的数据
标签: r dplyr data-science heatmap pheatmap