pheatmap 中缺少注释和颜色
missing annotations and colors in pheatmap
使用 pheatmap R 包,我需要制作一个带有自定义颜色集注释的热图。
我使用以下代码:
### Make a matrix
mat<-replicate(23, rnorm(23))
colnames(mat)<-c("1","2","3plus3reseq","4","5","6","7","8","D1","D2","D3","11","12","13","14","15","16","59","e7","e8","e9","17","18")
rownames(mat)<-c("1","2","3plus3reseq","4","5","6","7","8","D1","D2","D3","11","12","13","14","15","16","59","e7","e8","e9","17","18")
### Define annotations
colData_D<-data.frame(time=factor(x=c(rep("0",2), rep("1.5",3),rep("3",3), rep("3D",3), rep("12", 3),
rep("24",4),rep("24e",3), rep("24c",2)),levels=c("0","1.5","3","3D","12","24","24e", "24c")))
### Assign custom colors for annotations
newCols <- colorRampPalette(grDevices::rainbow(length(unique(colData_D$time))))
mycolors <- newCols(length(unique(colData_D$time)))
names(mycolors) <- unique(colData_D$time)
mycolors <- list(category = mycolors)
### Make the heatmap
pheatmap(mat,annotation_col = colData_D, annotation_colors = mycolors)
这会生成一个热图,其中缺少一些注释,并且颜色未更改为自定义配色方案。
但是,如果我更改列名和行名,则会显示缺少的类别,但颜色仍分配给默认类别。
mat<-replicate(23, rnorm(23))
colnames(mat)<-c(1:23)
rownames(mat)<-c(1:23)
pheatmap(mat,annotation_col = colData_D, annotation_colors = mycolors)
非常感谢任何提示。
您需要列表的名称 "annotation_colors" 需要与您在 colData_D 中的名称相匹配。并且还为注释数据框的行名提供矩阵的列名
也一样:
rownames(colData_D) = colnames(mat)
mycolors <- newCols(length(unique(colData_D$time)))
names(mycolors) <- unique(colData_D$time)
mycolors <- list(time = mycolors)
pheatmap(mat,annotation_col = colData_D, annotation_colors = mycolors)
这是你想要的吗?
使用 pheatmap R 包,我需要制作一个带有自定义颜色集注释的热图。
我使用以下代码:
### Make a matrix
mat<-replicate(23, rnorm(23))
colnames(mat)<-c("1","2","3plus3reseq","4","5","6","7","8","D1","D2","D3","11","12","13","14","15","16","59","e7","e8","e9","17","18")
rownames(mat)<-c("1","2","3plus3reseq","4","5","6","7","8","D1","D2","D3","11","12","13","14","15","16","59","e7","e8","e9","17","18")
### Define annotations
colData_D<-data.frame(time=factor(x=c(rep("0",2), rep("1.5",3),rep("3",3), rep("3D",3), rep("12", 3),
rep("24",4),rep("24e",3), rep("24c",2)),levels=c("0","1.5","3","3D","12","24","24e", "24c")))
### Assign custom colors for annotations
newCols <- colorRampPalette(grDevices::rainbow(length(unique(colData_D$time))))
mycolors <- newCols(length(unique(colData_D$time)))
names(mycolors) <- unique(colData_D$time)
mycolors <- list(category = mycolors)
### Make the heatmap
pheatmap(mat,annotation_col = colData_D, annotation_colors = mycolors)
这会生成一个热图,其中缺少一些注释,并且颜色未更改为自定义配色方案。
但是,如果我更改列名和行名,则会显示缺少的类别,但颜色仍分配给默认类别。
mat<-replicate(23, rnorm(23))
colnames(mat)<-c(1:23)
rownames(mat)<-c(1:23)
pheatmap(mat,annotation_col = colData_D, annotation_colors = mycolors)
非常感谢任何提示。
您需要列表的名称 "annotation_colors" 需要与您在 colData_D 中的名称相匹配。并且还为注释数据框的行名提供矩阵的列名
也一样:
rownames(colData_D) = colnames(mat)
mycolors <- newCols(length(unique(colData_D$time)))
names(mycolors) <- unique(colData_D$time)
mycolors <- list(time = mycolors)
pheatmap(mat,annotation_col = colData_D, annotation_colors = mycolors)
这是你想要的吗?