R 如何扩展包创建的热图以实现美观

R 如何扩展包创建的热图以实现美观,r,heatmap,R,Heatmap,我安装了一个软件包(CellCODE),其中定义了一个函数(称为“getAllSPVs”),允许我将其指定为参数之一 输出应为打印格式: getAllSPVs(data, plot=TRUE) 但是,功能的定义方式是图例覆盖了图形的一部分,图例和轴上的文字太小,无法读取: 我尝试手动重新定义函数,以便将图例移出绘图,使文字更清晰。我的修改结果如下: 但我只是在一定程度上把图例从图表上移开了,它仍然部分地覆盖了丹多格拉姆。我还更改了Y轴上书写的大小(下面是如何指定的-仍在进行此操作,以使其不

我安装了一个软件包(CellCODE),其中定义了一个函数(称为“getAllSPVs”),允许我将其指定为参数之一 输出应为打印格式:

getAllSPVs(data, plot=TRUE)
但是,功能的定义方式是图例覆盖了图形的一部分,图例和轴上的文字太小,无法读取:

我尝试手动重新定义函数,以便将图例移出绘图,使文字更清晰。我的修改结果如下:

但我只是在一定程度上把图例从图表上移开了,它仍然部分地覆盖了丹多格拉姆。我还更改了Y轴上书写的大小(下面是如何指定的-仍在进行此操作,以使其不会混乱)。箭头表示我希望图形穿孔的空间。但无论我如何处理边缘,热图都不会扩大

下面是我修改的代码,以进行迄今为止所做的调整(请特别注意我评论为“重要”的部分):

getAllSPV
 getAllSPVs<-function (data, plot = F) #output in form of plot when specified in command is set to TRUE
  {

  (.......)
  if (plot) {
    parlast = par(mar=c(1,1,1,1),no.readonly = T) ####IMPORTANT inserted the par argument here.
    datatmp = rbind(data[rownames(dataTag), ], t(SPVs))##### Don't Understand
    datatmp = resid(datatmp, grp)                          # any of this
    labGenes = c(apply(dataTag, 1, function(x) {           # but it might be
        which(x > 0)[1]                                    # important for
    }), rep(ncol(dataTag) + 1, ncol(SPVs)))################# expanding the heatmap

    mycol = c(rainbow(ncol(dataTag))[sample(ncol(dataTag))], 
              "black")
    corplot(datatmp, usecordist = T, ColSideColors = mycol[labGenes], 
            labRow = c(rep("", nrow(dataTag)), colnames(dataTag)), 
            density.info = "none", cexRow = 2, dendrogram = "column", #changed cexRow to value of '2'
            key = F)
    par(mar=c(0,0,0,0)) ##### IMPORTANT:changed from the original par(mfg = c(1, par()$mfcol[2]))
    legend("topright", fill = mycol, legend = colnames(dataTag), #specifying it to be top-right (or any other corners doesn't stop it from covering the graph data
           ncol = 1, xpd = NA, cex = 0.7, inset = 0) # here I changed the 'cex' argument to 0.7 from 1
    par(parlast)
}
colnames(SPVs) = colnames(dataTag)
SPVs
}