XiaoLuo-boy / ggheatmap

ggplot2 version of heatmap
79 stars 12 forks source link

Error when running examples #6

Open dansmith01 opened 2 years ago

dansmith01 commented 2 years ago

I've tried both the development version of ggheatmap and the version on CRAN. Both encounter the same error.

library(ggheatmap)
library(tidyr)
set.seed(123)
df <- matrix(runif(225,0,10),ncol = 15)
colnames(df) <- paste("sample",1:15,sep = "")
rownames(df) <- sapply(1:15, function(x)paste(sample(LETTERS,3,replace = F),collapse = ""))
df[1:4,1:4]

row_metaData <- data.frame(exprtype=sample(c("Up","Down"),15,replace = T),
                           genetype=sample(c("Metabolism","Immune","None"),15,replace = T))
rownames(row_metaData) <- rownames(df)
col_metaData <- data.frame(tissue=sample(c("Normal","Tumor"),15,replace = T),
                           risklevel=sample(c("High","Low"),15,replace = T))
rownames(col_metaData) <- colnames(df)
exprcol <- c("#EE0000FF","#008B45FF" )
names(exprcol) <- c("Up","Down")
genecol <- c("#EE7E30","#5D9AD3","#D0DFE6FF")
names(genecol) <- c("Metabolism","Immune","None")
tissuecol <- c("#98D352","#FF7F0E")
names(tissuecol) <- c("Normal","Tumor")
riskcol <- c("#EEA236FF","#46B8DAFF")
names(riskcol) <- c("High","Low")
col <- list(exprtype=exprcol,genetype=genecol,tissue=tissuecol,risklevel=riskcol)
text_rows <- sample(rownames(df),3)

p<- ggheatmap(df,cluster_rows = T,cluster_cols = T,scale = "row",
              text_show_rows = text_rows,
              cluster_num = c(3,3),
              tree_color_rows = c("#008B45FF","#631879FF","#008280FF"),
              tree_color_cols = c("#1F77B4FF","#FF7F0EFF","#2CA02CFF"),
              annotation_rows = row_metaData,
              annotation_cols = col_metaData,
              annotation_color = col
)
p
Warning messages:
1: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead. 
2: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead. 
Error in `ggplot_add()`:
! Can't add `x[[i]]` to a ggplot object.

No plot is generated.

XiaoLuo-boy commented 2 years ago

Thanks for you feedback. This problem can be solved by updating the aplot package.

qianghuazhou commented 7 months ago

I have an error when running example.

Error in if (zero_range(as.numeric(limits))) { : missing value where TRUE/FALSE needed In addition: Warning message: In zero_range(as.numeric(limits)) : NAs introduced by coercion

vertesy commented 3 months ago

As of today, the running the example generates the plot, so I think you can close this issue:

image

I suggest a small change to readme: using ```r instead of just ``` allows R syntax highighting in the code block.

```r col <- list(exprtype=exprcol,genetype=genecol,tissue=tissuecol,risklevel=riskcol) ```

bake0831 commented 3 months ago

I have an error when running example.

Error in if (zero_range(as.numeric(limits))) { : missing value where TRUE/FALSE needed In addition: Warning message: In zero_range(as.numeric(limits)) : NAs introduced by coercion

I was having the same issue - was an issue with the dendogram! Add the following arguments: show_cluster_cols = F, show_cluster_rows = F

This resolved my issue!