Error: node stack overflow when trying to plot large dataset using Complexheatmap
2
0
Entering edit mode
AB ▴ 100
@ab-8975
Last seen 2.1 years ago
United States

Hi,

I have a massive dataset that I want to use to make a heatmap using the Complexheatmap package. However, I'm getting the following error

Error: node stack overflow
Error during wrapup: node stack overflow

I am not at liberty to share my original dataset and hence here is a sample data.

new_df=data.frame("Spock2"=rep(0,10),"Col4a3"=c(rep(0,3),rep(2,2),rep(0,5)),"Syt1"=c(rep(0,8),rep(4,2)),"Pacrg"=c(rep(0,4),4,rep(0,2),rep(3,3)))

new_df=new_df[rep(seq_len(nrow(new_df)), each=300),]
Heatmap(as.matrix(new_df), row_labels = rep("",3000))

How do I fix this issue ? Any ideas ?

Thanks, Apoorva

Complexheatmap • 1.6k views
ADD COMMENT
0
Entering edit mode

It is because you have too many rows which are identical. The internal function ComplexHeatmap:::grid.dendrogram() that draws the dendrogram can handle a matrix with a few identical rows, but it gives errors with too many of that. I will look at this and try to fix it soon.

ADD REPLY
0
Entering edit mode

I find a similar case when making heatmaps with too many identical rows with gplots package. https://stackoverflow.com/questions/16559250/error-in-heatmap-2-gplots

ADD REPLY
0
Entering edit mode
Zuguang Gu ▴ 210
@zuguang-gu-7797
Last seen 11 days ago
Germany / Heidelberg / DKFZ

I cannot solve this problem, but you can add small random values to the original matrix to make no duplicated rows:

m = as.matrix(new_df)
m = m + runif(length(m), min = 0, max = 1e-10)
Heatmap(m, show_row_names = FALSE)

To control the legend, set proper values in heatmap_legend_param argument.

https://jokergoo.github.io/ComplexHeatmap-reference/book/legends.html#heatmap-and-annotation-legends

ADD COMMENT
0
Entering edit mode
Zuguang Gu ▴ 210
@zuguang-gu-7797
Last seen 11 days ago
Germany / Heidelberg / DKFZ

Now I add a new argument jitter in Heatmap() which internally adds random shift to the original matrix. The matrix is only modified when making the dendrograms. The heatmap bodies and the legends are not affected:

m = as.matrix(new_df)
Heatmap(m, show_row_names = FALSE, jitter = TRUE)

or

m = as.matrix(new_df)
Heatmap(m, show_row_names = FALSE, jitter = 1e-10)

The random values are generated from the uniform distribution within (0, jitter) or (0, 1e-10).

Please update the package from GitHub:

library(devtools)
install_github("jokergoo/ComplexHeatmap")
ADD COMMENT
0
Entering edit mode

Hi. I had the same problem, I used the jitter argument now, but the error persists.

ADD REPLY
0
Entering edit mode

Indeed, I dont have any repeated value i.e.:

head(sort(table(HTdt$TotPC_FC), decreasing=TRUE))

-2.7531024129286 -2.60239600129202 -2.59882399747114 -2.50057728006338 -2.43532405332128 1 1 1 1 1 -2.35119425790377 1

head(sort(table(HTdt$SynPC_FC), decreasing=TRUE))

-12.8575440204269 -11.1288535950429 -8.36119814307584 -6.06653571829438 -5.52828129172012 1 1 1 1 1 -4.07528353549578 1

head(sort(table(HTdt$DegcrFC), decreasing=TRUE))

-8.74608567657745 -8.45771966702432 -7.94509403518839 -7.85642773252236 -7.42725845984559 1 1 1 1 1 -7.2987419615091 1

What could be causing the error then?

ADD REPLY

Login before adding your answer.

Traffic: 289 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6