satijalab / azimuth

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

ValidateAzimuthReference does not recognize full namespace #155

Closed derrik-gratz closed 1 year ago

derrik-gratz commented 1 year ago

I'm using AzimuthReference to generate a custom reference. Using debug, I can see that the line

Tool(object = object) <- ad

Creates a slot called Azimuth::AzimuthReference. But this is not recognized as valid when executing ValidateAzimuthReference at the end of AzimuthReference, as it is looking for AzimuthReference. If I execute the same check with the full namespace, e.g.:

inherits(Tool(object, slot = 'Azimuth::AzimuthReference'), what = 'AzimuthData')

The return is now true and the validation can proceed.

https://github.com/satijalab/azimuth/blob/fa45d4c153d2623b89792f8b57aab333e889cdab/R/azimuth.R#L800

derrik-gratz commented 1 year ago

This only seems to arise if you specify Azimuth::AzimuthReference() Which I did to have explicit calls in a wrapper function as part of a package

Gesmira commented 1 year ago

Hi, thanks for reporting this. I've included a fix on the development branch for the new version of Azimuth that is compatible with Seurat v5. To use this, you will have to install Seurat v5 and its dependencies which is described here: https://satijalab.org/seurat/articles/install.html

z5ouyang commented 6 months ago

Hi @Gesmira and @derrik-gratz, This seems happens again? I can successfully call "AzimuthReference" in the main script, but not in the function. success:

D1 <- readRDS("CCA.rds")
D_ref <- AzimuthReference(D1,refAssay=DefaultAssay(D1),
                            metadata=c("Celltype"))

Fail:

test <- function(){
  D1 <- readRDS("CCA.rds")
  D_ref <- AzimuthReference(D1,refAssay=DefaultAssay(D1),
                            metadata=c("Celltype"))
}
test()
maud-p commented 1 month ago

Hi @z5ouyang, @Gesmira , I am facing the same issue, I cannot source() a script that call AzimuthReference while I am able to run it in the main function. Do you have an idea how to solve it? would be a great help if AzimuthReference can be called inside a function! Thanks!