seurat icon indicating copy to clipboard operation
seurat copied to clipboard

Segmentation artifact with Xenium samples

Open PaulaNietoG opened this issue 6 months ago • 5 comments

Hello,

I have a few Xenium samples and have encountered a plotting artifact when using the segmentation. This happens for all samples (cell numbers ranging from 4800 to over 125000, so quite a wide range) only when plotting categorical variables with ImageDimPlot. You can see in the example below how the segmentation produces this weird angles and straight lines but it does produce the correct segmentation when plotting genes or continuous variables with ImageFeaturePlot.

# No segmentation artifact
ImageFeaturePlot( 
    xenium_obj,  
    features = "MKI67",
    size = 1.5
) +
xlim(c(750, 1000)) +
ylim(c(1250, 1500))

xenium_no_artifact

# Segmentation artifact
DefaultBoundary(xenium_obj[["fov"]]) <- "segmentation"
xenium_obj$random_var <- sample(c("True", "False", NA), ncol(xenium_obj), replace = TRUE)
ImageDimPlot(  
    xenium_obj,       
    group.by = "random_var",
    border.size = 0.01
    ) +
xlim(c(750, 1000)) +
ylim(c(1250, 1500))

xenium_artifact

This is only one of my xenium samples and I have done no normalization or any kind of pre-processing at this point other than removing cells with no transcripts. Also note that in the example provided I have zoomed in with xlim and ylim, but it happens with or without the zooming in. Please let me know if you need further information and how could I fix this visualization issue.

Best,

Paula

sessionInfo()

R version 4.4.1 (2024-06-14)
Platform: x86_64-conda-linux-gnu
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /scratch_isilon/groups/singlecell/pnieto/conda_env/seurat5/lib/libopenblasp-r0.3.27.so;  LAPACK version 3.12.0

locale:
[1] C

time zone: Europe/Madrid
tzcode source: system (glibc)

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

other attached packages:
 [1] AUCell_1.26.0      decoupleR_2.10.0   glue_1.7.0         Matrix_1.6-5      
 [5] patchwork_1.2.0    scRepertoire_2.0.0 magrittr_2.0.3     lubridate_1.9.3   
 [9] forcats_1.0.0      stringr_1.5.1      dplyr_1.1.4        purrr_1.0.2       
[13] readr_2.1.5        tidyr_1.3.1        tibble_3.2.1       ggplot2_3.5.1     
[17] tidyverse_2.0.0    Seurat_5.1.0       SeuratObject_5.0.2 sp_2.1-4          

loaded via a namespace (and not attached):
  [1] cubature_2.1.1              RcppAnnoy_0.0.22           
  [3] splines_4.4.1               later_1.3.2                
  [5] pbdZMQ_0.3-11               R.oo_1.26.0                
  [7] polyclip_1.10-7             graph_1.82.0               
  [9] XML_3.99-0.17               fastDummies_1.7.3          
 [11] lifecycle_1.0.4             globals_0.16.3             
 [13] lattice_0.22-6              MASS_7.3-60.0.1            
 [15] openxlsx_4.2.6.1            plotly_4.10.4              
 [17] httpuv_1.6.15               sctransform_0.4.1          
 [19] zip_2.3.1                   spam_2.10-0                
 [21] spatstat.sparse_3.1-0       reticulate_1.38.0          
 [23] DBI_1.2.3                   cowplot_1.1.3              
 [25] pbapply_1.7-2               RColorBrewer_1.1-3         
 [27] abind_1.4-5                 zlibbioc_1.50.0            
 [29] Rtsne_0.17                  GenomicRanges_1.56.1       
 [31] R.utils_2.12.3              ggraph_2.2.1               
 [33] BiocGenerics_0.50.0         tweenr_2.0.3               
 [35] evmix_2.12                  GenomeInfoDbData_1.2.12    
 [37] IRanges_2.38.1              S4Vectors_0.42.1           
 [39] ggrepel_0.9.5               irlba_2.3.5.1              
 [41] listenv_0.9.1               spatstat.utils_3.0-5       
 [43] iNEXT_3.0.1                 MatrixModels_0.5-3         
 [45] goftest_1.2-3               RSpectra_0.16-2            
 [47] annotate_1.82.0             spatstat.random_3.3-1      
 [49] fitdistrplus_1.2-1          parallelly_1.38.0          
 [51] DelayedMatrixStats_1.26.0   leiden_0.4.3.1             
 [53] codetools_0.2-20            DelayedArray_0.30.1        
 [55] ggforce_0.4.2               tidyselect_1.2.1           
 [57] UCSC.utils_1.0.0            farver_2.1.2               
 [59] viridis_0.6.5               matrixStats_1.3.0          
 [61] stats4_4.4.1                base64enc_0.1-3            
 [63] spatstat.explore_3.3-1      jsonlite_1.8.8             
 [65] tidygraph_1.3.1             progressr_0.14.0           
 [67] ggridges_0.5.6              ggalluvial_0.12.5          
 [69] survival_3.7-0              tools_4.4.1                
 [71] stringdist_0.9.12           ica_1.0-3                  
 [73] Rcpp_1.0.13                 gridExtra_2.3              
 [75] SparseArray_1.4.8           MatrixGenerics_1.16.0      
 [77] GenomeInfoDb_1.40.1         IRdisplay_1.1              
 [79] withr_3.0.1                 fastmap_1.2.0              
 [81] fansi_1.0.6                 SparseM_1.84-2             
 [83] digest_0.6.36               timechange_0.3.0           
 [85] R6_2.5.1                    mime_0.12                  
 [87] colorspace_2.1-1            scattermore_1.2            
 [89] tensor_1.5                  RSQLite_2.3.7              
 [91] spatstat.data_3.1-2         R.methodsS3_1.8.2          
 [93] utf8_1.2.4                  generics_0.1.3             
 [95] data.table_1.15.4           graphlayouts_1.1.1         
 [97] httr_1.4.7                  htmlwidgets_1.6.4          
 [99] S4Arrays_1.4.1              uwot_0.2.2                 
[101] pkgconfig_2.0.3             gtable_0.3.5               
[103] blob_1.2.4                  lmtest_0.9-40              
[105] SingleCellExperiment_1.26.0 XVector_0.44.0             
[107] htmltools_0.5.8.1           dotCall64_1.1-1            
[109] GSEABase_1.66.0             scales_1.3.0               
[111] Biobase_2.64.0              png_0.1-8                  
[113] spatstat.univar_3.0-0       ggdendro_0.2.0             
[115] rjson_0.2.21                tzdb_0.4.0                 
[117] reshape2_1.4.4              uuid_1.2-1                 
[119] nlme_3.1-165                repr_1.1.7                 
[121] zoo_1.8-12                  cachem_1.1.0               
[123] KernSmooth_2.23-24          parallel_4.4.1             
[125] miniUI_0.1.1.1              AnnotationDbi_1.66.0       
[127] pillar_1.9.0                grid_4.4.1                 
[129] vctrs_0.6.5                 RANN_2.6.1                 
[131] VGAM_1.1-11                 promises_1.3.0             
[133] xtable_1.8-4                cluster_2.1.6              
[135] evaluate_0.24.0             truncdist_1.0-2            
[137] cli_3.6.3                   compiler_4.4.1             
[139] rlang_1.1.4                 crayon_1.5.3               
[141] future.apply_1.11.2         labeling_0.4.3             
[143] plyr_1.8.9                  stringi_1.8.4              
[145] BiocParallel_1.38.0         viridisLite_0.4.2          
[147] deldir_2.0-4                Biostrings_2.72.1          
[149] munsell_0.5.1               gsl_2.1-8                  
[151] lazyeval_0.2.2              spatstat.geom_3.3-2        
[153] quantreg_5.98               IRkernel_1.3.2             
[155] RcppHNSW_0.6.0              hms_1.1.3                  
[157] sparseMatrixStats_1.16.0    bit64_4.0.5                
[159] future_1.34.0               KEGGREST_1.44.1            
[161] shiny_1.9.1                 SummarizedExperiment_1.34.0
[163] evd_2.3-7                   ROCR_1.0-11                
[165] igraph_2.0.3                memoise_2.0.1              
[167] bit_4.0.5                  

PaulaNietoG avatar Aug 21 '24 08:08 PaulaNietoG