drieslab / Giotto

Spatial omics analysis toolbox
https://drieslab.github.io/Giotto_website/
Other
240 stars 94 forks source link

Creating Polygons with Interactive Selection Tool #964

Closed jweis3 closed 3 weeks ago

jweis3 commented 4 weeks ago

Experiencing issues with the polygon selection feature within Giotto. After I go to click the first point of the first polygon within the interactive viewer, the image disappears and the error "[Object Objec}" appears. Can't do anything except cancel the interactive browser once the error occurs. ...

Error Message

image
# Error: [object Object]

Expected behavior

Should just be able to click and add polygons as usual.

System Information

Session Info: R version 4.4.0 (2024-04-24) Platform: x86_64-pc-linux-gnu Running under: AlmaLinux 8.9 (Midnight Oncilla)

Matrix products: default BLAS/LAPACK: FlexiBLAS NETLIB; LAPACK version 3.11.0

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

time zone: America/New_York tzcode source: system (glibc)

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] shiny_1.8.1.1 Giotto_4.0.8 GiottoClass_0.3.1

loaded via a namespace (and not attached): [1] RColorBrewer_1.1-3 rstudioapi_0.16.0 jsonlite_1.8.8
[4] magrittr_2.0.3 magick_2.8.3 farver_2.1.2
[7] rmarkdown_2.26 fs_1.6.4 zlibbioc_1.50.0
[10] ragg_1.3.0 vctrs_0.6.5 memoise_2.0.1
[13] GiottoUtils_0.1.8 terra_1.7-78 htmltools_0.5.8.1
[16] S4Arrays_1.4.1 usethis_2.2.3 SparseArray_1.4.8
[19] sass_0.4.9 bslib_0.7.0 htmlwidgets_1.6.4
[22] plyr_1.8.9 plotly_4.10.4 cachem_1.1.0
[25] igraph_2.0.3 mime_0.12 lifecycle_1.0.4
[28] pkgconfig_2.0.3 Matrix_1.7-0 R6_2.5.1
[31] fastmap_1.2.0 GenomeInfoDbData_1.2.12 MatrixGenerics_1.16.0
[34] digest_0.6.35 colorspace_2.1-0 S4Vectors_0.42.0
[37] ps_1.7.6 pkgload_1.3.4 textshaping_0.3.7
[40] GenomicRanges_1.56.0 labeling_0.4.3 fansi_1.0.6
[43] httr_1.4.7 abind_1.4-5 compiler_4.4.0
[46] remotes_2.5.0 withr_3.0.0 backports_1.5.0
[49] pak_0.7.2 pkgbuild_1.4.4 R.utils_2.12.3
[52] rappdirs_0.3.3 DelayedArray_0.30.1 sessioninfo_1.2.2
[55] rjson_0.2.21 gtools_3.9.5 GiottoVisuals_0.2.3
[58] tools_4.4.0 httpuv_1.6.15 R.oo_1.26.0
[61] glue_1.7.0 dbscan_1.1-12 callr_3.7.6
[64] promises_1.3.0 grid_4.4.0 checkmate_2.3.1
[67] reshape2_1.4.4 generics_0.1.3 gtable_0.3.5
[70] R.methodsS3_1.8.2 tidyr_1.3.1 data.table_1.15.4
[73] sp_2.1-4 utf8_1.2.4 XVector_0.44.0
[76] BiocGenerics_0.50.0 ggrepel_0.9.5 pillar_1.9.0
[79] stringr_1.5.1 later_1.3.2 dplyr_1.1.4
[82] lattice_0.22-6 deldir_2.0-4 tidyselect_1.2.1
[85] SingleCellExperiment_1.26.0 miniUI_0.1.1.1 knitr_1.47
[88] IRanges_2.38.0 SummarizedExperiment_1.34.0 scattermore_1.2
[91] stats4_4.4.0 xfun_0.44 Biobase_2.64.0
[94] devtools_2.4.5 matrixStats_1.3.0 stringi_1.8.3
[97] UCSC.utils_1.0.0 lazyeval_0.2.2 yaml_2.3.8
[100] evaluate_0.23 codetools_0.2-20 tibble_3.2.1
[103] colorRamp2_0.1.0 cli_3.6.2 xtable_1.8-4
[106] reticulate_1.37.0 systemfonts_1.0.6 munsell_0.5.1
[109] processx_3.8.4 jquerylib_0.1.4 Rcpp_1.0.12
[112] GenomeInfoDb_1.40.0 png_0.1-8 parallel_4.4.0
[115] ellipsis_0.3.2 ggplot2_3.5.1 profvis_0.3.8
[118] urlchecker_1.0.1 SpatialExperiment_1.14.0 viridisLite_0.4.2
[121] scales_1.3.0 purrr_1.0.2 crayon_1.5.2
[124] rlang_1.1.3 cowplot_1.1.3

josschavezf commented 4 weeks ago

Hi @jweis3 could you please share the code you are running? I just tested the interactive tool and didn't see any error.

jweis3 commented 4 weeks ago

tma_002path <- '/restricted/projectnb/decamp/jweis/TMA002_SpaceRanger/TMA_002_outs/outs' tma_002 <- createGiottoVisiumObject(visium_dir = tma_002path, expr_data = 'raw', png_name = 'tissue_hires_image.png', gene_column_index = 2, instructions = myinstructions) tma_002 <- filterGiotto(tma_002, expression_threshold = 1, feat_det_in_min_cells = 50, min_det_feats_per_cell = 300, expression_values = c('raw'), verbose = T) tma_002 <- normalizeGiotto(tma_002) tma_002 <- addStatistics(tma_002)

tma_002 <- filterGiotto(tma_002, expression_threshold = 1, feat_det_in_min_cells = 50, min_det_feats_per_cell = 300, expression_values = c('raw'), verbose = T) tma_002 <- normalizeGiotto(tma_002) tma_002 <- addStatistics(tma_002)

josschavezf commented 4 weeks ago

@jweis3 the code you just shared is for processing the object but would be helpful to see the code you are using for running the interactive tool. You can run a small example of the polygon selection following this code:

g <- GiottoData::loadGiottoMini("visium") sp <- spatPlot2D(g, return_plot = TRUE) plotInteractivePolygons(sp)

jweis3 commented 4 weeks ago

Sorry thought i included the last few lines- here they are:

tma_002_spatplot <- spatPlot2D(tma_002, cell_color = 'nr_feats', color_as_factor = F, point_size = 1.0, point_alpha = 0.8, show_image = TRUE) tma_002_poly_coords <- plotInteractivePolygons(tma_002_spatplot,height = 500, width = 500)

josschavezf commented 4 weeks ago

@jweis3 I see, it seems like the continuous scale from cell_color = 'nr_feats' is breaking something in the app. I'll fix it asap.

In the meantime, If the nr_feats is not critical for your selection, you can create the spatial plot without the cell color or without the argument color_as_factor = F. Without the continuous scale, the app will work.

jweis3 commented 4 weeks ago

Gotcha, thanks Jocelyn!

josschavezf commented 3 weeks ago

hi @jweis3 I just fixed the error. For now, the change is reflected in the development branch, you can install it using remotes::install_github("drieslab/Giotto@suite_dev") We will release the updated version in the main branch in a few days.