neurorestore / Vespucci

MIT License
0 stars 1 forks source link

Error when running `run_vespucci`. #1

Open unikill066 opened 3 months ago

unikill066 commented 3 months ago

I am encountering an error while trying to run Vespucci- run_vespucci function. The error occurs both when running the function with the basic inputs and when additional parameters are provided.

Error Message:

> vespucci_res = run_vespucci(input = input, meta = meta)
Splitting matrix
As no overdispersion parameters were provided, Poisson count splitting will be performed.
Error in auc@x : 
  no applicable method for `@` applied to an object of class "NULL"
> data('spatial_sim_distance_metrics_df')
> vespucci_res = run_vespucci(
+   input = input,
+   meta = meta,
+   distance_metrics_df = spatial_sim_distance_metrics_df,
+   test_sim = T
+ )
Splitting matrix
As no overdispersion parameters were provided, Poisson count splitting will be performed.
Error in auc@x : 
  no applicable method for `@` applied to an object of class "NULL"

Code:

# Vespucci

# install.packages("devtools")
# install.packages("propr")
# devtools::install_github("tpq/propr")
# install.packages("dismay")
# install.packages("remotes")
# remotes::install_github("skinnider/dismay")
# devtools::install_github("neurorestore/Vespucci")

library(Vespucci)
library(Seurat)

setwd("C:/Users/NXI220005/Downloads/vispu_data")
files <- list.files()
print(files)

load("spatial_sim.rda")
load("spatial_sim_calculated_auc_df.rda")
load("spatial_sim_distance_metrics_df.rda")

ls()

data("spatial_sim")
input = GetAssayData(spatial_sim, slot='counts')
meta = spatial_sim@meta.data

?run_vespucci

vespucci_res = run_vespucci(input = input, meta = meta)

data('spatial_sim_distance_metrics_df')
vespucci_res = run_vespucci(
  input = input,
  meta = meta,
  distance_metrics_df = spatial_sim_distance_metrics_df,
  test_sim = T
)

Despite following the instructions, I keep receiving the Error in auc@x indicating that no applicable method for @ is being applied to an object of class "NULL". Any guidance on what might be causing this issue would be appreciated.

unikill066 commented 3 months ago

It seems we might have identified the issue here.

In utils.R, the function should be updated from:

countsplit_matrix = function(
    input,
    seed = 42
) {
    set.seed(seed)
    split = countsplit(input, epsilon=0.5)
    auc = split$train
    auc@x = as.numeric(auc@x)
    de = split$test
    out_list = list(
        'run_auc' = auc,
        'run_de' = de
    )
    return(out_list)
}

to:

countsplit_matrix = function(
    input,
    seed = 42
) {
    set.seed(seed)
    split = countsplit(input, epsilon=0.5)
    auc = split[[1]]
    auc@x = as.numeric(auc@x)
    de = split[[2]]
    out_list = list(
        'run_auc' = auc,
        'run_de' = de
    )
    return(out_list)
}

We referenced the information from here. Please let me know if this can be implemented as a fix. If so, I will fork the repository. Thanks!

AlanTeoYueYang commented 2 months ago

Hi, thank you for bringing this to our attention. We have implemented the fix as suggested.