Open xiekunwhy opened 5 months ago
It should be a memory limit problem. I haven't got such a large dataset being tested. So I generate random data for testing.
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" ...
library(ggVennDiagram)
ggVennDiagram(list, label="count", label_alpha=0, edge_size=0.4)
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.
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()
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)
Hi,
I got following errors when using ggVennDiagram, do you known why?
Best, Kun