Skip to content

Commit

Permalink
Create test-3D_UMAP.R
Browse files Browse the repository at this point in the history
  • Loading branch information
lobanovav authored Jun 3, 2024
1 parent eeffc86 commit 5ccfe79
Showing 1 changed file with 92 additions and 0 deletions.
92 changes: 92 additions & 0 deletions tests/testthat/test-3D_UMAP.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#These lines are necessary to launch Kaleido properly (temporary patch):
skip_on_ci()
reticulate::py_run_string(
"import sys;print(sys.version); sys.path.append('/rstudio-files/R_environments/single-cell-rna-seq-r4'); print(sys.path)"
)

test_that("Produce 3D UMAP plot and return tsne coordinates - TEC Data", {
cr.object <- getParam3D("TEC")
output <- do.call(UMAP3D, cr.object)

expected.elements = c("plot", "data")
expect_setequal(names(output), expected.elements)

skip_on_ci()
expect_snapshot_file(
.drawplot(output$plot),
"TEC_plotly.png"
)
}
)

test_that("Run 3DUMAP with error for color selection - TEC Data", {
cr.object <- getParam3D("TEC")
cr.object$color.variable <- "Likely_CellType"
expect_error(output <- do.call(UMAP3D, cr.object),
"^The metadata variable selected for color")

})

test_that("Run 3DUMAP with error for color selection - TEC Data", {
cr.object <- getParam3D("TEC")
cr.object$label.variable <- "Likely_CellType"
expect_error(output <- do.call(UMAP3D, cr.object),
"^The metadata variable selected for labeling")

})

test_that("Produce 3D UMAP plot and return tsne coordinates - Chariou Data", {
cr.object <- getParam3D("Chariou")
output <- do.call(UMAP3D, cr.object)

expected.elements = c("plot", "data")
expect_setequal(names(output), expected.elements)

skip_on_ci()
expect_snapshot_file(
.drawplot(output$plot),
"Chariou_plotly.png"
)
}
)

test_that("Produce 3D UMAP plot and return tsne - PBMC-single Data", {
cr.object <- getParam3D("pbmc-single")
output <- do.call(UMAP3D, cr.object)
expected.elements = c("plot", "data")
expect_setequal(names(output), expected.elements)

skip_on_ci()
expect_snapshot_file(
.drawplot(output$plot),
"PBMC_single_plotly.png"
)
})

test_that("Produce 3D UMAP plot and return tsne - NSCLC-multi Data", {
cr.object <- getParam3D("nsclc-multi")
output <- do.call(UMAP3D, cr.object)

expected.elements = c("plot", "data")
expect_setequal(names(output), expected.elements)

skip_on_ci()
expect_snapshot_file(
.drawplot(output$plot),
"NSCLC_multi_plotly.png"
)
})

test_that("Produce 3D UMAP plot and return tsne - BRCA Data", {
cr.object <- getParam3D("BRCA")
output <- do.call(UMAP3D, cr.object)

expected.elements = c("plot", "data")
expect_setequal(names(output), expected.elements)

skip_on_ci()
expect_snapshot_file(
.drawplot(output$plot),
"BRCA_plotly.png"
)
})

0 comments on commit 5ccfe79

Please sign in to comment.