如何解决Pheatmap:更改与colData有关的注释
我试图根据DESEq对象的成对比较来创建热图,但是我希望行和列的标签与元数据相关,而不是作为示例名称。
实验设置:我只是拥有3种不同的细胞类型,每一种都有3个重复 目标:制作一个热图,使这些细胞类型根据成对的相关值聚类
到目前为止,我做了什么以及数据如何显示:
带有示例信息的数据框:
> sample_info[,1:3]
Sample Cell_type Treatment
AM1 AM1 Alveolar_macrophages healthy
AM2 AM2 Alveolar_macrophages healthy
AM3 AM3 Alveolar_macrophages healthy
IM1 IM1 Interstitial_macrophages healthy
IM2 IM2 Interstitial_macrophages healthy
IM3 IM3 Interstitial_macrophages healthy
T1 T1 T_cells healthy
T2 T2 T_cells healthy
T3 T3 T_cells healthy
具有读取计数的数据框:
> head(only_counts)
AM1 AM2 AM3 IM1 IM2 IM3 T1 T2 T3
let-7a-1-3p 1383 930 1321 621 734 347 325 355 911
let-7a-2-3p 0 0 0 1 1 4 0 0 0
let-7a-5p 396731 293379 408655 177221 165887 152788 295030 331667 457912
let-7b-3p 40 24 23 151 172 87 81 140 170
let-7b-5p 5889 3051 2353 16342 15507 10990 31974 30384 34134
let-7c-1-3p 4 2 0 103 83 65 0 0 0
DESEq对象:
dds <- DESeqDataSetFromMatrix(countData = only_counts,colData = sample_info,design= ~ Cell_type)
转换和计算:
vsd <- varianceStabilizingTransformation(dds,blind=T)
vsd_mat <- assay(vsd) #extract the vst matrix
vsd_cor <- cor(vsd_mat) #compute pairwise correlation values
热图
pheatmap(vsd_cor,main="Hierarchical clustering",annotation = colData(dds)$Cell_type)
Error in `[.default`(annotation_col,colnames(mat),drop = F) :
incorrect number of dimensions
当我做简单的热图时: pheatmap(vsd_cor, main =“ Herarchical clustering”)
但是我希望显示的不是单元格名称,而是显示单元格类型(colData(dds)$ Cell_type)
我尝试过类似的操作,但是没有用:
pheatmap(vsd_cor,annotation = sample_info$Cell_type)
pheatmap(vsd_cor,annotation_col = colData(dds)$Cell_type,annotation_row=colData(dds)$Cell_type)
pheatmap(vsd_cor,annotation_col = sample_info$Cell_type,annotation_row=sample_info$Cell_type)
解决方法
如果有人有相同的问题,我想通了: 得到相关矩阵后:
rownames(vsd_cor) <- paste(sample_info$Cell_type)
colnames(vsd_cor) <- paste(sample_info$Cell_type)
pheatmap(vsd_cor,main="Hierarchical clustering")
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。