jbergenstrahle / STUtility

Other
46 stars 12 forks source link

ST.FeaturePlot export #14

Open nmatigian opened 2 years ago

nmatigian commented 2 years ago

Hi When I run the code below all works fine and looks ok with no borders around spots (pt.border = F), when

However, if export, saved as pdf or eps black borders are added. Does anyone know why?

ST.FeaturePlot(object = se features = "res.0.3", dark.theme = F, pt.size = 1, split.labels = F, indices = 1:3, ncol = 3, pt.border = F, cols = palette) + ggtitle('') + guides(fill=guide_legend(nrow=1)) + theme(legend.position="bottom")

sessionInfo() R version 4.1.0 (2021-05-18) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04.2 LTS

Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

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

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

other attached packages: [1] RColorBrewer_1.1-2 STutility_0.1.0 tibble_3.1.2 scater_1.20.1 scran_1.20.1 scuttle_1.2.0 [7] SingleCellExperiment_1.14.1 SummarizedExperiment_1.22.0 Biobase_2.52.0 GenomicRanges_1.44.0 GenomeInfoDb_1.28.0 IRanges_2.26.0 [13] S4Vectors_0.30.2 BiocGenerics_0.38.0 MatrixGenerics_1.4.3 matrixStats_0.61.0 clustree_0.4.3 ggraph_2.0.5 [19] tidyr_1.1.3 dplyr_1.0.7 ggplot2_3.3.5 SeuratObject_4.0.2 Seurat_4.0.3 pander_0.6.4 [25] knitr_1.33

loaded via a namespace (and not attached): [1] utf8_1.2.1 reticulate_1.20 tidyselect_1.1.1 htmlwidgets_1.5.3 grid_4.1.0 BiocParallel_1.26.0 Rtsne_0.15 [8] munsell_0.5.0 ScaledMatrix_1.0.0 units_0.7-2 codetools_0.2-18 ica_1.0-2 statmod_1.4.36 future_1.21.0 [15] miniUI_0.1.1.1 withr_2.4.2 colorspace_2.0-2 uuid_0.1-4 rstudioapi_0.13 ROCR_1.0-11 tensor_1.5 [22] listenv_0.8.0 labeling_0.4.2 GenomeInfoDbData_1.2.6 polyclip_1.10-0 farver_2.1.0 LearnBayes_2.15.1 coda_0.19-4 [29] parallelly_1.26.1 vctrs_0.3.8 generics_0.1.0 xfun_0.24 R6_2.5.0 doParallel_1.0.16 ggbeeswarm_0.6.0 [36] graphlayouts_0.7.1 rsvd_1.0.5 locfit_1.5-9.4 Morpho_2.8 ggiraph_0.7.10 manipulateWidget_0.11.0 bitops_1.0-7 [43] spatstat.utils_2.2-0 DelayedArray_0.18.0 assertthat_0.2.1 promises_1.2.0.1 scales_1.1.1 imager_0.42.10 beeswarm_0.4.0 [50] gtable_0.3.0 beachmat_2.8.0 globals_0.14.0 bmp_0.3 goftest_1.2-2 tidygraph_1.2.0 rlang_0.4.11 [57] zeallot_0.1.0 systemfonts_1.0.2 akima_0.6-2.1 splines_4.1.0 lazyeval_0.2.2 spatstat.geom_2.2-0 rgl_0.106.8 [64] yaml_2.2.1 reshape2_1.4.4 abind_1.4-5 crosstalk_1.1.1 httpuv_1.6.1 tools_4.1.0 spData_0.3.10 [71] ellipsis_0.3.2 spatstat.core_2.2-0 raster_3.4-13 proxy_0.4-26 Rvcg_0.19.2 ggridges_0.5.3 Rcpp_1.0.7 [78] plyr_1.8.6 sparseMatrixStats_1.4.0 zlibbioc_1.38.0 classInt_0.4-3 purrr_0.3.4 RCurl_1.98-1.3 rpart_4.1-15 [85] dbscan_1.1-8 deldir_0.2-10 pbapply_1.4-3 viridis_0.6.1 cowplot_1.1.1 zoo_1.8-9 ggrepel_0.9.1 [92] cluster_2.1.2 colorRamps_2.3 magrittr_2.0.1 magick_2.7.2 data.table_1.14.0 scattermore_0.7 readbitmap_0.1.5 [99] gmodels_2.18.1 lmtest_0.9-38 RANN_2.6.1 fitdistrplus_1.1-5 shinyjs_2.0.0 patchwork_1.1.1 mime_0.11 [106] evaluate_0.14 xtable_1.8-4 jpeg_0.1-8.1 gridExtra_2.3 compiler_4.1.0 KernSmooth_2.23-20 crayon_1.4.1 [113] htmltools_0.5.1.1 spdep_1.1-8 tiff_0.1-8 mgcv_1.8-36 later_1.2.0 expm_0.999-6 DBI_1.1.1 [120] tweenr_1.0.2 MASS_7.3-54 boot_1.3-28 sf_1.0-0 Matrix_1.3-4 gdata_2.18.0 metapod_1.0.0 [127] igraph_1.2.6 pkgconfig_2.0.3 sp_1.4-5 plotly_4.9.4.1 spatstat.sparse_2.0-0 foreach_1.5.1 vipor_0.4.5 [134] dqrng_0.3.0 XVector_0.32.0 stringr_1.4.0 digest_0.6.27 sctransform_0.3.2 RcppAnnoy_0.0.18 spatstat.data_2.1-0 [141] rmarkdown_2.9 leiden_0.3.8 uwot_0.1.10 edgeR_3.34.0 DelayedMatrixStats_1.14.3 gtools_3.9.2 shiny_1.6.0 [148] lifecycle_1.0.0 nlme_3.1-152 jsonlite_1.7.2 BiocNeighbors_1.10.0 viridisLite_0.4.0 limma_3.48.3 fansi_0.5.0 [155] pillar_1.6.1 lattice_0.20-44 fastmap_1.1.0 httr_1.4.2 survival_3.2-11 glue_1.4.2 png_0.1-7 [162] iterators_1.0.13 bluster_1.2.1 class_7.3-19 ggforce_0.3.3 stringi_1.6.2 BiocSingular_1.8.1 e1071_1.7-7 [169] irlba_2.3.3 future.apply_1.7.0

ludvigla commented 2 years ago

One solution is to set the useDingbats option to TRUE in the pdf device. Here's a small example I tried on a mouse brain tissue data set:

p <- ST.FeaturePlot(se, features = "Nrgn", ncol = 2, pt.border = FALSE)

pdf(file = "test.pdf", width = 8, height = 4, useDingbats = TRUE)
print(p)
dev.off()

test.pdf

This works fine when opened in Adobe Acrobat Reader, but the borders still show up when I open the file in Google Chrome.