-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from PixelgenTechnologies/plot3dgraph
Plot3dgraph
- Loading branch information
Showing
5 changed files
with
370 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
pxl_file <- system.file("extdata/PBMC_10_cells", | ||
"Sample01_test.pxl", | ||
package = "pixelatorR") | ||
seur_obj <- ReadMPX_Seurat(pxl_file, overwrite = TRUE) | ||
seur_obj <- LoadCellGraphs(seur_obj, cells = colnames(seur_obj)[1:2]) | ||
seur_obj[["mpxCells"]] <- KeepLargestComponent(seur_obj[["mpxCells"]]) | ||
seur_obj <- ComputeLayout(seur_obj, layout_method = "pmds", dim = 3) | ||
|
||
test_that("Plot3DGraph works as expected", { | ||
expect_no_error({layout_plot <- Plot3DGraph(seur_obj, cell_id = colnames(seur_obj)[1], layout_method = "pmds", marker = "CD14", colors = c("blue", "red"))}) | ||
expect_no_error({layout_plot <- Plot3DGraph(seur_obj, cell_id = colnames(seur_obj)[1], layout_method = "pmds", marker = "CD14", colors = c("blue", "red"), use_palette = "Viridis")}) | ||
expect_s3_class(layout_plot, "plotly") | ||
expect_no_error({layout_plot <- Plot3DGraph(seur_obj, cell_id = colnames(seur_obj)[1], layout_method = "pmds", marker = "CD14")}) | ||
expect_equal(layout_plot$x$layoutAttrs[[1]]$annotations$text, "CD14") | ||
|
||
# Test with showBnodes active | ||
expect_no_error({layout_plot <- Plot3DGraph(seur_obj, cell_id = colnames(seur_obj)[1], layout_method = "pmds", show_Bnodes = TRUE, marker = "CD14")}) | ||
|
||
# Test with project active | ||
expect_no_error({layout_plot <- Plot3DGraph(seur_obj, cell_id = colnames(seur_obj)[1], layout_method = "pmds", project = TRUE, marker = "CD14")}) | ||
}) | ||
|
||
test_that("Plot3DGraph fails with invalid input", { | ||
expect_error({layout_plot <- Plot3DGraph(seur_obj, cell_id = colnames(seur_obj)[1], layout_method = "invalid", marker = "CD14")}) | ||
expect_error({layout_plot <- Plot3DGraph(seur_obj, cell_id = colnames(seur_obj)[1])}) | ||
expect_error({layout_plot <- Plot3DGraph(seur_obj, cell_id = colnames(seur_obj)[1], layout_method = "pmds", colors = c("red"), marker = "CD14")}, | ||
"'colors' must be a character vector with 2 color names") | ||
expect_error({layout_plot <- Plot3DGraph(seur_obj, cell_id = colnames(seur_obj)[1:2], layout_method = "pmds", node_size = 2, marker = "CD14")}, | ||
"'cell_id' must be a non-empty character vector with a single cell ID") | ||
}) |