从 R 中 pheatmap 中未选择的行名中删除 NA

问题描述

我有一组我想绘制的选定基因组,我已将其重命名。但是在绘制它们时,我也会得到未选中的 NA。 我怎样才能删除只绘制我选择的基因的 NAs?

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)

enter image description here

我已经看到您还可以执行以下操作:

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

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...