From 9e4c9c5518c0d9598c36fbd9b3fd83e29ac23130 Mon Sep 17 00:00:00 2001 From: lcolladotor Date: Fri, 19 Jul 2024 17:21:18 -0400 Subject: [PATCH] Update tests for spe_to_seurat() based on the new structure of the function. Should resolve the issue noted at https://github.com/LieberInstitute/visiumStitched/actions/runs/10014189676/job/27683384513#step:21:271. --- tests/testthat/test-spe_to_seurat.R | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/tests/testthat/test-spe_to_seurat.R b/tests/testthat/test-spe_to_seurat.R index bb90b3c..be3cbc5 100644 --- a/tests/testthat/test-spe_to_seurat.R +++ b/tests/testthat/test-spe_to_seurat.R @@ -3,22 +3,28 @@ test_that( { spe <- fetch_data(type = "spatialDLPFC_Visium_example_subset") - # Should be missing several "transformed" colData columns expect_error( spe_to_seurat(spe, verbose = FALSE), - "Expected the following columns" + "Seurat requires colnames\\(spe\\) to be unique" ) - # Add the required transformed columns - spe$array_row_transformed <- spe$array_row - spe$array_col_transformed <- spe$array_col - spe$pxl_row_in_fullres_transformed <- spatialCoords(spe)[, "pxl_row_in_fullres"] - spe$pxl_col_in_fullres_transformed <- spatialCoords(spe)[, "pxl_col_in_fullres"] + ## Make the column names unique + colnames(spe) <- spatialLIBD::add_key(spe)$key # Should be missing several "transformed" colData columns expect_error( - spe_to_seurat(spe, verbose = FALSE), - "Seurat requires colnames\\(spe\\) to be unique" + spe_to_seurat( + spe, + spatial_cols = c( + "tissue" = "in_tissue", + "row" = "array_row_transformed", + "col" = "array_col_transformed", + "imagerow" = "pxl_row_in_fullres_transformed", + "imagecol" = "pxl_col_in_fullres_transformed" + ), + verbose = FALSE + ), + "Expected the following columns" ) # Now (apparently) remove low-res images