SydneyBioX / SimBench

14 stars 3 forks source link

Error in vapply(featureCorrDF, nrow, 0): values must be length 1, but FUN(X[[1]]) result is length 0 #1

Open EperLuo opened 1 year ago

EperLuo commented 1 year ago

Hi! I was trying to reproduce the evaluation results in the readme file, and I followed exactly the guidance said:

path <- system.file("extdata", "real.rds", package="SimBench")
real <- readRDS(path)

path <- system.file("extdata", "sim.rds", package="SimBench")
sim <- readRDS(path)

parameter_result <- eval_parameter(real = real, sim = sim, type = "count" , method = "samplemethod")

but then I run into this bug:

Warning message in mclapply(sim_list, function(x) {: “all scheduled cores encountered errors in user code” Error in vapply(featureCorrDF, nrow, 0): values must be length 1, but FUN(X[[1]]) result is length 0 Traceback:

  1. eval_parameter(real = real, sim = sim, type = "count", method = "samplemethod")
  2. countsim_eval(sim_list)
  3. calculateFeatureCorrs(sim_list = obj, ncore = ncore)
  4. vapply(featureCorrDF, nrow, 0)

I have installed all the required dependencies, but I am not very familiar with R and not sure if the versions of these dependencies are all right.

Any help would be much appreciated!~

Diego56104 commented 1 year ago

Hi, I'm having the same issue. Did you figure out what was causing the problem?

krisrs1128 commented 1 year ago

I ran into the same issue. Looking at the code, I guess we're supposed to call it with type = 'raw'? I'm not actually sure, but this seems to be working,

library(SimBench)
library(parallel) # have to explicitly load?

path <- system.file("extdata", "real.rds", package="SimBench")
real <- readRDS(path)

path <- system.file("extdata", "sim.rds", package="SimBench")
sim <- readRDS(path)

parameter_result <- eval_parameter(real = real, sim = sim, type = "raw" , method = "samplemethod")

I also had to install a few other dependencies that don't appear in the NAMESPACE. The main ones were WGCNA and preprocessCore (which is required by WGCNA). For the record, here are all the :: imports, some which don't seem explicitly declared.

(base) MacBook-Pro-de-Kris:R ksankaran$ grep -R '::' .
./countsim_eval_KS.R:      ) %>% dplyr::mutate(EffLibsize = Libsize * TMM)
./countsim_eval_KS.R:  sampleDF <- do.call(rbind, sampleDF) %>%   dplyr::mutate(dataset = rep(names(sampleDF), ns))
./countsim_eval_KS.R:  featureDF <- do.call(rbind, featureDF) %>%   dplyr::mutate(dataset = rep(names(featureDF), ns))
./countsim_eval_KS.R:  })) %>%  dplyr::mutate(dataset = names(obj))
./parameter_estimation.R:    temp <-  thisparameter %>%  dplyr::summarise( sum_kde = sum(abs( temp)) )
./calculateGeneCellCorr.R:    corrs <- WGCNA::cor(cpms,  use =  "pairwise.complete.obs",
./calculateGeneCellCorr.R:  do.call(rbind, sampleCorrDF) %>% dplyr::mutate(dataset = rep(names(sampleCorrDF), ns))
./calculateGeneCellCorr.R:      cpms <- cpms[genefilter::rowVars(cpms) > 0,]
./calculateGeneCellCorr.R:      corrs <- WGCNA::cor(t(cpms),   use =  "pairwise.complete.obs",
./calculateGeneCellCorr.R:    do.call(rbind, featureCorrDF) %>%  dplyr::mutate(dataset = rep(names(featureCorrDF), ns))
./calculateMeanVarLibrary.R:      dge <- edgeR::DGEList(counts = DESeq2::counts(ds))
./calculateMeanVarLibrary.R:      dge <- edgeR::calcNormFactors(dge)
./calculateMeanVarLibrary.R:      dds <- DESeq2::estimateSizeFactors(ds, type = "poscounts")
./generate_DE_prop.R:  design <- stats::model.matrix(~tmp_celltype)
./generate_DE_prop.R:    Matrix::rowMeans(exprsMat@assays$RNA@data[, tmp_celltype == i, drop = FALSE])
./generate_DE_prop.R:    Matrix::rowSums(exprsMat@assays$RNA@data[, tmp_celltype == i,
./generate_DE_prop.R:  y <- methods::new("EList")
./generate_DE_prop.R:  fit <- limma::lmFit(y, design = design)
./generate_DE_prop.R:  fit <- limma::eBayes(fit, trend = TRUE, robust = TRUE)
./generate_DE_prop.R:  tt   <- limma::topTable(fit, n = Inf, adjust.method = "BH", coef = 2)
./generate_DE_prop.R:    Matrix::rowSums(exprsMat@assays$RNA@data[,
./generate_DE_prop.R:    stats::bartlett.test(gene~cellTypes, df)$p.value
./generate_DE_prop.R:  tt  <- stats::p.adjust(tt , method = "BH")
./generate_DE_prop.R:    Matrix::rowSums(exprsMat@assays$RNA@data [,
./generate_DE_prop.R:    stats::ks.test(x1, x2, alternative = "greater")$p.value
./generate_DE_prop.R:  tt <- stats::p.adjust(tt , method = "BH")
./generate_DE_prop.R:    suppressWarnings(stats::chisq.test(tab)$p.value)
./generate_DE_prop.R:  tt <- stats::p.adjust(tt , method = "BH")
./generate_DE_prop.R:    Matrix::rowMeans(exprsMat@assays$RNA@data[, tmp_celltype == i, drop = FALSE])
./generate_DE_prop.R:    apply(exprsMat@assays$RNA@data[, tmp_celltype == i, drop = FALSE], 1, stats::var) 
eijynagai commented 8 months ago

Hello,

I also had the same issue. I installed WCGNA and preprocessCore, but nothing changed. Did anyone figure out how to fix this issue?

Warning message in mclapply(sim_list, function(x) {:
“all scheduled cores encountered errors in user code”
Error in vapply(sampleCorrDF, nrow, 0): values must be length 1,
 but FUN(X[[1]]) result is length 0
Traceback:

1. eval_parameter(real = real, sim = sim, type = "raw", method = "samplemethod")
2. countsim_eval(sim_list)
3. calculateSampleCorrs(sim_list = obj, maxNForCorr = maxNForCorr, 
 .     ncore = ncore)
4. vapply(sampleCorrDF, nrow, 0)
wuyanglinL commented 4 months ago

I debug the SimBench and find it use Seurat v5. Updata your seurat may solve your problem.