【问题标题】:Remove NAs from non-selected rownames in pheatmap in R从 R 中 pheatmap 中未选择的行名中删除 NA
【发布时间】:2021-06-27 19:00:01
【问题描述】:

我有一组选定的基因要绘制,我已重命名。但是在绘制它们时,我也得到了未选中的 NA。 如何删除仅绘制我选择的基因的 NA?

library(pheatmap)
set.seed(2020)
    mat = matrix(rnorm(200),20,10)
    rownames(mat) = paste0("g",1:20)
    rownames(mat)[rownames(mat) == "g2"] <- "abc"
    rownames(mat)[rownames(mat) == "g4"] <- "pqr"
    rownames(mat)[rownames(mat) == "g6"] <- "zzz"
    selected_genes <- c("abc","pqr", "zzz")
    obj = pheatmap(mat,cluster_rows = T, scale = 'row', show_rownames = T, labels_row = selected_genes)

我看到你也可以这样做:

labRow <- c(row.names(mat)[1], rep('', length(row.names(mat))-2)) # Selected row2 as example
pheatmap(mat,cluster_rows = T, scale = 'row', show_rownames = T, labels_row = labRow) 

【问题讨论】:

    标签: r rowname pheatmap


    【解决方案1】:

    既然您已经发现使用非打印值填充 label_row 参数,看来您应该尝试一下:

    obj = pheatmap(mat,cluster_rows = T, scale = 'row', show_rownames = T, 
                               labels_row = c(selected_genes,rep("   ",17) ) ) 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-19
      • 1970-01-01
      • 2021-12-25
      • 1970-01-01
      • 2015-05-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多