seurat-object
seurat-object copied to clipboard
Unexpected values returned by FetchData() / unsafe programming / change help
Dear Seurat Team,
I used FetchData(object = obj, vars = "UMAP_1")
to retrieve UMAP coordinates in Seurat.utils::AutoNumber.by.UMAP()
.
This worked until Seurat v5. After Seurat v5 it still executed without a warning, but the coordinates returned did not correspond to the umap plotted.
What happens?
- In v5
UMAP_1
got renamed toumap_1
, in@reductions$umap
-
FetchData
now silently returnsUMAP_1
fromobj@reductions$ref.umap
instead fromobj@reductions$umap
. - I did not even know about
ref.umap
, and getting values from it is very unexpected when asking for a umap coordinate. I needed to look through 2MB of "str(obj)" output to get this info. - The solution is that I will not use
FetchData
, bc I rather break the code then get meaningless values to figure out much later.
Solutions
- FetchData is unsafe currently, even if it "works correctly". Please add some reporting or
break early
. - Please change help. Stop recommending in
?FetchData
to use as:pc1 <- FetchData(object = pbmc_small, vars = 'PC_1')
, bc apparently you would need to specify thePCA
slot to be sure what to get. - I encountered now multiple times such unsafe programming in
Seurat
, where sth is returned without message/warning/error, so this is also a general request to increase prudency. See example: NA values inDiscretePalette
needed to be handled by quick and dirtySeurat.utils::DiscretePaletteSafe()
.
Thank you for your time sharing and maintaining the code. Abel