使用pheatmap()改进R中的热图 [英] Improving my Heatmap in R with pheatmap()

查看:98
本文介绍了使用pheatmap()改进R中的热图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我是R的完整入门者,需要在接下来的几天中尽可能重现此热图。

Hey I am a complete beginner to R and need to reproduce this heatmap as best as possible in the next couple of days.

我的数据是一个包含多张纸的xlsx文件,我尽力清除了它,并且应该采用正确的格式。我有2个时间点T0和T1作为字符,因此无法运行 pheatmap()函数。
如何将热图划分为T0和T1并以正确的顺序构造样本ID?
您是否有一个想法如何创建一个与给定示例尽可能相似的热图?

My data is an xlsx file with multiple sheets, I cleaned it as good as I could and it should be in an okay format. I Have 2 Timepoints T0 and T1 as characters so I can not run the pheatmap() function. How can I divide the heatmap into T0 and T1 and structure the Sample IDs in correct order ? Do you have an Idea how to create a heatmap as similar as possible to the given example?

这是我在过去两天内能够生成的热图,而没有T0和T1数据,因为它们是字符而不是数字值。现在,我想包括它们并按照给定的热图正确地对Samlple ID进行排序。

This is the heatmap I was able to produce in the last two days without the T0 and T1 data because they were characters and not numeric values. Now I would like to include them and sort the Samlple ID properly as in the given heatmap.

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"
)



Thi s是我现在包含T0和T1组的代码,但是我不能运行它,因为T值是字符。
您将如何更改代码以基本上尽可能地重现给定的热图并在我的基础上进行改进?

This is the code I have now for including the T0 and T1 groups but I cant run it because the T values are characters. How would you change the code to basically reproduce the given heatmap as good as possible and improve on mine?

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的任何想法,因此不会更改结果数据。

And furthermore any ideas on how I could imputate the NA´s easily, by logspline imputation so the resulting data is not changed.

推荐答案

Re。 T值是字符。:T字符是否意味着TRUE逻辑值?如果是这样,并假设您正在从CSV文件中读取数据,则您需要1)读入时指定列类型,或2)使用以下方式更改data.frame中的列类型: .ologic()

Re. "the T values are characters.": Are the T characters meant to be TRUE logical values? If so, and assuming you are reading in the data from, say, a CSV file, then you need to either 1) specify the column type when you read it in, or 2) change the column type in the data.frame using as.logical()

Df$mycolumn <- as.logical(Df$mycolumn)

这篇关于使用pheatmap()改进R中的热图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆