CFeregrino / scWGCNA

scWGCNA
GNU General Public License v3.0
54 stars 10 forks source link

Error running scWGNA.report(), Error in hclust(as.dist(dissTOM), method = "average"): NaN dissimilarity value #4

Open sofiapuvogelvittini opened 3 years ago

sofiapuvogelvittini commented 3 years ago

Hello, i am super interested in using your package! I am working with a seurat object But I have error while running scWGNA.report() function

My input:

scWGNA.report(data = ps.seurat_object,sc.data = seurat_object, gene.names=gnames, project.name = "test", sp="Hs",GO=T, ask=F)

Output:

processing file: scWGCNA_report.Rmd

|... | 4% inline R code fragments

|...... | 8% label: Set up (with options) List of 3 $ message: logi FALSE $ warning: logi FALSE $ results: chr "hide"

|......... | 12% ordinary text without R code

|............ | 17% label: From above (with options) List of 3 $ message: logi FALSE $ warning: logi FALSE $ results: chr "hide"

|............... | 21% ordinary text without R code

|.................. | 25% label: pre-process the data |.................... | 29% ordinary text without R code

|....................... | 33% label: soft-thresholding power (with options) List of 2 $ echo : logi FALSE $ message: logi FALSE

|.......................... | 38% ordinary text without R code

|............................. | 42% label: WGCNA

Quitting from lines 217-405 (scWGCNA_report.Rmd)

Error in hclust(as.dist(dissTOM), method = "average"): NaN dissimilarity value. Traceback:

scWGNA.report(data = ps.vasculature, sc.data = vasculature, gene.names = gnames,
. project.name = "test", sp = "Hs", GO = T, ask = F)
rmarkdown::render(system.file("WGCNA_scripts", "scWGCNA_report.Rmd",
. package = "scWGCNA"), params = list(data = data, sc.data = sc.data,
. gene.names = gene.names, project.name = project.name, sp = sp,
. cells = cells, features = features, reduction = reduction,
. dir = dir, is.pseudocell = is.pseudocell, GO = GO), output_file = paste0(dir,
. "WGCNA_report_", project.name, "_", format(Sys.Date(), "%d%m%y"),
. ".html"), output_format = "html_document")
knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
process_file(text, output)
withCallingHandlers(if (tangle) process_tangle(group) else process_group(group),
. error = function(e) {
. setwd(wd)
. cat(res, sep = "\n", file = output %n% "")
. message("Quitting from lines ", paste(current_lines(i),
. collapse = "-"), " (", knit_concord$get("infile"),
. ") ")
. })
process_group(group)
process_group.block(group)
call_block(x)
block_exec(params)
in_dir(input_dir(), evaluate(code, envir = env, new_device = FALSE,
. keep_warning = !isFALSE(options$warning), keep_message = !isFALSE(options$message),
. stop_on_error = if (options$error && options$include) 0L else 2L,
. output_handler = knit_handlers(options$render, options)))
evaluate(code, envir = env, new_device = FALSE, keep_warning = !isFALSE(options$warning),
. keep_message = !isFALSE(options$message), stop_on_error = if (options$error &&
. options$include) 0L else 2L, output_handler = knit_handlers(options$render,
. options))
evaluate::evaluate(...)
evaluate_call(expr, parsed$src[[i]], envir = envir, enclos = enclos,
. debug = debug, last = i == length(out), use_try = stop_on_error !=
. 2L, keep_warning = keep_warning, keep_message = keep_message,
. output_handler = output_handler, include_timing = include_timing)
timing_fn(handle(ev <- withCallingHandlers(withVisible(eval(expr,
. envir, enclos)), warning = wHandler, error = eHandler, message = mHandler)))
handle(ev <- withCallingHandlers(withVisible(eval(expr, envir,
. enclos)), warning = wHandler, error = eHandler, message = mHandler))
withCallingHandlers(withVisible(eval(expr, envir, enclos)), warning = wHandler,
. error = eHandler, message = mHandler)
withVisible(eval(expr, envir, enclos))
eval(expr, envir, enclos)
eval(expr, envir, enclos)
hclust(as.dist(dissTOM), method = "average") # at line 24 of file

Could you help me please to solve it? Kind regards, Sofia

safabio commented 3 years ago

Hi Sofia,

So it is a bit a hacky solution, but if you go into the scWGCNA_report.Rmd file in your scWGCNA package, there are two lines (115 and 116) that are commented out:

if (is.pseudocell) {

  datExpr=Wdata@assays$RNA@counts[Expr,]
  # datExpr = datExpr[which(rowSums(as.matrix(datExpr))>0),]
  # Expr = rownames(datExpr)

} else{datExpr=Wdata@assays$RNA@data[Expr,]}

Try removing the comments on those two lines, save the file and then run the report again. I ran into the same error as you did and this fixed it for me.

Fabio