Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C stack usage 7972740 is too close to the limit #69

Open
xiekunwhy opened this issue Jun 24, 2024 · 3 comments
Open

C stack usage 7972740 is too close to the limit #69

xiekunwhy opened this issue Jun 24, 2024 · 3 comments

Comments

@xiekunwhy
Copy link

Hi,

I got following errors when using ggVennDiagram, do you known why?

library(ggplot2)
library(ggVennDiagram)
vdat <- read.table(infile, header = F, stringsAsFactors = F)
ids <- unique(vdat$V1)
df1 <- list()
for (id in ids) {
  print(id)
  df1[[id]] <- unique(vdat[vdat$V1 == id,][,2])
}
print(str(df1))
List of 5
 $ KOG      : chr [1:25551] "mikado.Hap1_chr1G1" "mikado.Hap1_chr1G2" "mikado.Hap1_chr1G3" "mikado.Hap1_chr1G4" ...
 $ GO       : chr [1:34959] "mikado.Hap1_chr1G1" "mikado.Hap1_chr1G10" "mikado.Hap1_chr1G100" "mikado.Hap1_chr1G1000" ...
 $ NR       : chr [1:41937] "mikado.Hap1_chr1G1" "mikado.Hap1_chr1G2" "mikado.Hap1_chr1G3" "mikado.Hap1_chr1G4" ...
 $ SwissProt: chr [1:29362] "mikado.Hap1_chr1G1" "mikado.Hap1_chr1G2" "mikado.Hap1_chr1G3" "mikado.Hap1_chr1G4" ...
 $ KEGG     : chr [1:13215] "mikado.Hap1_chr1G100" "mikado.Hap1_chr1G1000" "mikado.Hap1_chr1G10000" "mikado.Hap1_chr1G10003" ...
NULL

ggVennDiagram(df1, label="count", label_alpha=0, edge_size=0.4)

Error: C stack usage  7972740 is too close to the limit
In addition: There were 50 or more warnings (use warnings() to see the first 50)
Execution halted

Best,
Kun

@gaospecial
Copy link
Owner

gaospecial commented Jun 24, 2024

It should be a memory limit problem. I haven't got such a large dataset being tested. So I generate random data for testing.

Generation of large dataset

generate_random_strings <- function(n, length) {
  random_strings <- character(n)
  
  for (i in 1:n) {
    random_strings[i] <- paste0(sample(c(letters, LETTERS, 0:9), length, replace = TRUE), collapse = "")
  }
  
  return(unique(random_strings))
}

set.seed(123) 
random_strings <- generate_random_strings(50000, 10)

length(random_strings) # 50000
[1] 50000
list = lapply(c(25000,35000,42000,30000,13000), sample, x = random_strings)
str(list)
List of 5
 $ : chr [1:25000] "cn7nR4yvWr" "wKgDZZN6PX" "GGq3pl9xOi" "kylHdRzTDe" ...
 $ : chr [1:35000] "wFunJ9AdHz" "KX98DejPF7" "YVSwkSSy9e" "9zuJxKqak8" ...
 $ : chr [1:42000] "8DgtNSr0r5" "RIxXWsUK83" "KhiNn32PnX" "qtCkGvieP3" ...
 $ : chr [1:30000] "WTrpjPIKSk" "xnEAIaXBCx" "ObvmYhjA96" "SgtlQstHsP" ...
 $ : chr [1:13000] "u9Ed1m7CCL" "UkjYywGT78" "LeIBCmA8qq" "mIYJcgCkeX" ...

Plot Venn Diagram

library(ggVennDiagram)
ggVennDiagram(list, label="count", label_alpha=0, edge_size=0.4)

image

In my Laptop with 16G memory, it can give correct result. How many memory do you have?

Besides, you may need to free your memory with rm(list = ls()) and rerun your plotting in a clean env.

@xiekunwhy
Copy link
Author

At leat 18 Gb memory.

Here is the data
venn.rtab.xls.gz

and here is the code

Rscript ggvenn2.r venn.rtab.xls venn.r.tabgg

codes in ggvenn2.r
args <- commandArgs(TRUE)
infile = args[1]
outpfx = args[2]
#library(venn)
library(ggplot2)
library(ggVennDiagram)
#library(ggpolypath)
set.seed(12345)
vdat <- read.table(infile, header = F, stringsAsFactors = F)
ids <- unique(vdat$V1)
df1 <- list()
for (id in ids) {
  print(id)
  df1[[id]] <- unique(vdat[vdat$V1 == id,][,2])
}
print(str(df1))
pdf(file = paste0(outpfx, ".pdf"), width = 5, height = 5)
ggVennDiagram(df1, label="count", label_alpha=0, edge_size=0.4)
#venn(df1, ilabels = TRUE, zcolor = "style", ggplot = TRUE)
dev.off()
png(filename = paste0(outpfx, ".png"), width = 5, height = 5, res = 300, units = "in")
ggVennDiagram(df1, label="count", label_alpha=0, edge_size=0.4)
#venn(df1, ilabels = TRUE, zcolor = "style", ggplot = TRUE)
dev.off()

@gaospecial
Copy link
Owner

Your code is also working here. Therefore, it should depends on your own environment.

set.seed(12345)
vdat <- read.table(infile, header = F, stringsAsFactors = F)
ids <- unique(vdat$V1)
df1 <- list()
for (id in ids) {
  print(id)
  df1[[id]] <- unique(vdat[vdat$V1 == id,][,2])
}
[1] "KOG"
[1] "GO"
[1] "NR"
[1] "SwissProt"
[1] "KEGG"
str(df1)
List of 5
 $ KOG      : chr [1:25551] "mikado.Hap1_chr1G1" "mikado.Hap1_chr1G2" "mikado.Hap1_chr1G3" "mikado.Hap1_chr1G4" ...
 $ GO       : chr [1:34959] "mikado.Hap1_chr1G1" "mikado.Hap1_chr1G10" "mikado.Hap1_chr1G100" "mikado.Hap1_chr1G1000" ...
 $ NR       : chr [1:41937] "mikado.Hap1_chr1G1" "mikado.Hap1_chr1G2" "mikado.Hap1_chr1G3" "mikado.Hap1_chr1G4" ...
 $ SwissProt: chr [1:29362] "mikado.Hap1_chr1G1" "mikado.Hap1_chr1G2" "mikado.Hap1_chr1G3" "mikado.Hap1_chr1G4" ...
 $ KEGG     : chr [1:13215] "mikado.Hap1_chr1G100" "mikado.Hap1_chr1G1000" "mikado.Hap1_chr1G10000" "mikado.Hap1_chr1G10003" ...
ggVennDiagram(df1, label="count", label_alpha=0, edge_size=0.4)

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants