Skip to content

Test for fetch_reduction with invalid dimnames #159

@wish1832

Description

@wish1832

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 ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Teststestthat scripts for packagebugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions