satijalab / azimuth

A Shiny web app for mapping datasets using Seurat v4
https://satijalab.org/azimuth
GNU General Public License v3.0
106 stars 30 forks source link

Error 'could not find function "Key<-"' when using docker #195

Open qianxuans opened 9 months ago

qianxuans commented 9 months ago

Hi, I followed the introduction of running the app using Docker. In which I git clone the repo and use "docker build -t azimuth ." to create the docker image. I also followed the step of "docker run -it -p 3838:3838 -v /path/to/reference:/reference-data:ro azimuth" to mount the reference to the container. However, when I open the webpage of the app, this error appeared and the webpage turned grey.

> Azimuth::AzimuthApp(reference='/reference-data')
Registered S3 method overwritten by 'SeuratDisk':
  method            from  
  as.sparse.H5Group Seurat

Attaching shinyBS
Loading required package: shiny

Listening on http://0.0.0.0:3838
Warning: Overwriting miscellanous data for model
Warning: Adding a dimensional reduction (refUMAP) without the associated assay being present
Warning: Error in <-: could not find function "Key<-"
  47: GetPlotRef.AzimuthData
  45: LoadReference
  41: server
   4: runApp
   1: Azimuth::AzimuthApp
Error in Key(plotref) <- gsub("\\.", "", Key(plotref)) : 
  could not find function "Key<-"

Any idea how to fix this? Thank you so much!!

andynkili commented 2 months ago

@qianxuans,

I am having also the same issue, when running azimuth inside a Rmd:

future_2 <- future({
  set.seed(12345678)
  mydata <- RunAzimuth(mydata, reference = '/annotation_pipeline/')
  saveRDS(mydata, paste0(tools::file_path_sans_ext(basename(file_name)), '_Azimuth_annotated.rds'))
  l=list()
  l[[1]]=mydata[["prediction.score.annotation"]]
  l[[2]]=subset(mydata@meta.data, select=c('predicted.annotation','predicted.annotation.score'))
  l
  })
Quitting from lines  at lines 51-197 [runPipeline] (annotation.Rmd)
Error in `Key(plotref) <- gsub("\\.", "", Key(plotref))`:
! could not find function "Key<-"
Backtrace:
 1. future::value(future_2)
 2. future:::value.Future(future_2)
 3. future:::signalConditions(...)

The same chunk of code work inside the R console though. The error suggest Seurat library is not properly loaded but inside that Rmd I am using other Seurat function without errors. Does anyone have a clue?

Best, Andy

chengwenxuan1997 commented 2 months ago

The Key function is exported from R package SeuratObject. So I think you should library(Seurat) before RunAzimuth. (At least it works for me)