【问题标题】:Pheatmap: change annotation relating to colData()Pheatmap:更改与 colData() 相关的注释
【发布时间】:2020-09-01 16:53:13
【问题描述】:

我正在尝试从 DSEq 对象的成对比较创建一个 pheatmap,但我希望行和列的标签与元数据相关,而不是样本名称。

实验设置:我只有 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="层次聚类")

但我希望显示单元格类型而不是样本名称 (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)

【问题讨论】:

    标签: r pairwise pheatmap


    【解决方案1】:

    如果有人有同样的问题,我想通了: 得到相关矩阵后:

    rownames(vsd_cor) <- paste(sample_info$Cell_type)
    colnames(vsd_cor) <- paste(sample_info$Cell_type)
    pheatmap(vsd_cor,
             main="Hierarchical clustering")
    

    【讨论】:

      猜你喜欢
      • 2021-12-27
      • 2023-03-08
      • 2020-01-08
      • 1970-01-01
      • 2016-01-22
      • 2017-05-28
      • 2012-07-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多