fetch_reduction appears to behave inconsistently across objects when invalid dimension names are requested. This should be corrected, and tests should be written to monitor behavior.
The Seurat and SingleCell Experiment methods return an error with invalid dims requests:
> object <- AML_Seurat
# Third entry in dims does not exist
> fetch_reduction(object = object, reduction = "umap", dims = c(2, 3)) |> str()
Error in Embeddings(object = object[[reduction]])[cells, dims] :
subscript out of bounds
> object <- AML_SCE()
> fetch_reduction(object = object, reduction = "UMAP", dims = c(2, 3)) |> str()
Error in reducedDims(object)[[reduction]][cells, dims] :
subscript out of bounds
The anndata method returns a warning:
> object <- AML_h5ad()
> fetch_reduction(object = object, reduction = "X_umap", dims = c(2, 3)) |>
+ str()
'data.frame': 250 obs. of 1 variable:
$ X_umap_2: num 9.9 10.13 10.21 10.51 3.39 ...
Warning message:
The following requested variables were not found : X_umap_3
And the MuData method simply returns the inputs that are valid, with no warning:
> object <- AML_h5mu()
> fetch_reduction(object = object, reduction = "RNA_X_umap", dims = c(2, 3)) |>
+ str()
'data.frame': 250 obs. of 1 variable:
$ 2: num 9.9 10.13 10.21 10.51 3.39 ...
fetch_reduction appears to behave inconsistently across objects when invalid dimension names are requested. This should be corrected, and tests should be written to monitor behavior.
The Seurat and SingleCell Experiment methods return an error with invalid dims requests:
The anndata method returns a warning:
And the MuData method simply returns the inputs that are valid, with no warning: