Closed zhanghao-njmu closed 9 months ago
The following data and code can reproduce this issue. Note that the latest ggplot2 and ggforce are used.
library(ggplot2) library(ggforce) x <- c(-4.46798966620377, -2.1090312453605, -1.84601768294516, 5.79499827429486, 0.43592398267521, -3.01641689187153, -4.10398493436269, -1.53467832497444, -1.64403248330696, 1.88866969350521, -1.10071376022678, -0.732424476000914, 4.9355457310868, 7.16901087881661, -11.1749760466164, -0.330647142722807, 4.99431746262638, 3.99350248184654, 5.57024373532071, -4.9003441612954, -2.70964164932524, -3.13827001445066, 8.98938301829994, 1.15304888846147, -4.10835606970075, -3.80814439783665, -1.11500667144161, -4.01741501531724, 0.600033270173348, -1.80874358837064, -0.381658708050097, 6.46574124184736, 6.37340082097916, 0.273747698054138, 4.90249513991362, 6.16139025975088, 2.62462429559324, 5.36868924362433, -6.21295925665591, -2.27676433338093, -1.23143424193455, 5.79794917170878, 1.39159889636088, -3.27991565841227, -3.32113773742275, -1.89630876814511, -3.93776678590554, 0.785189427950814, -0.794902846480633, -0.628082507785516, 5.74575717936985, 7.04070961795171, 0.788392068682478, 5.60989643609462, 4.22291712058141, 2.10055019294984, 5.85725439334508) y <- c(-1.88979052125517, -3.99859032133039, 2.88794711532744, 1.04400982509528, -9.20071736934793, -0.874436876290539, -5.01035759345655, 1.56129515932716, -2.28617788003896, 1.46927851645699, -1.23088074711093, -0.0512634990258398, 0.855694107232475, 5.24359789459775, -5.19349234505035, -5.80406825757198, 2.0373710339048, 3.66304250612958, 2.47355081727165, -2.91698101544892, -3.68956634231607, 5.84439063122804, 0.596732520647421, -8.31179169039804, -0.63493227634592, -5.93821117884396, 1.019956220117, -3.25066580239872, 1.34229087097502, -1.24120130291848, 1.55903028956034, 2.09890123632997, 4.16912629275164, -7.18715263054722, 3.06941990106059, 3.14300986520884, 3.17857513049073, 4.73226062353877, -3.44527637667008, -3.41082697427231, 3.63529860825317, 1.63130316772536, -9.30339326171906, -0.196903044477533, -5.23904552721807, 0.814520292592067, -2.58187687963695, 0.83932864039429, -1.73754258868063, 0.524089051459452, 0.100885472398243, 4.28702335064132, -5.19405687460876, 3.27950050157283, 2.34740358671191, 3.9834926184684, 5.45626038770104) celltype <- c("Amnion", "Endoderm", "Endothelial & erythroid cell", "Ependymal cell", "Epiblast", "Epithelium", "ExE endoderm", "ExE mesoderm", "Gut", "Limb bud mesenchyme cell", "Mesoderm", "MSC/Fib", "Neural ectoderm", "Neuron", "PGC", "Primitive streak", "Radial glial cell", "Retinal pigmented epithelium", "Retinal progenitor cell", "Amnion & PGC", "Endoderm", "Endothelial & erythroid cell", "Ependymal cell", "Epiblast", "Epithelium", "ExE endoderm", "ExE mesoderm", "Gut", "Limb bud mesenchyme cell", "Mesoderm", "MSC/Fib", "Neural ectoderm", "Neuron", "Primitive streak", "Radial glial cell", "Retinal progenitor cell", "Schwann cell", "Sensory neuron", "Amnion & PGC", "Endoderm", "Endothelial & erythroid cell", "Ependymal cell", "Epiblast", "Epithelium", "ExE endoderm", "ExE mesoderm", "Gut", "Limb bud mesenchyme cell", "Mesoderm", "MSC/Fib", "Neural ectoderm", "Neuron", "Primitive streak", "Radial glial cell", "Retinal progenitor cell & RPE", "Schwann cell", "Sensory neuron")
When plotting with all the data above, geom_mark_hull only works for certain points.
df <- data.frame(x = x, y = y, celltype = celltype) ggplot(data = df, aes(x, y)) + geom_point(mapping = aes(color = celltype)) + geom_mark_hull(mapping = aes(fill = celltype))
However, when plotting with a subset of data (<40 data points), geom_mark_hull works without any omissions.
ggplot(data = df[1:39,], aes(x, y)) + geom_point(mapping = aes(color = celltype)) + geom_mark_hull(mapping = aes(fill = celltype))
R version 4.2.0 (2022-04-22) Platform: x86_64-pc-linux-gnu (64-bit) Running under: CentOS Linux 8 Matrix products: default BLAS/LAPACK: /usr/lib64/libopenblasp-r0.3.12.so locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 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 LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] grid stats graphics grDevices utils datasets methods base other attached packages: [1] concaveman_1.1.0 ggforce_0.4.1 ggraph_2.1.0 igraph_1.3.5 RcppParallel_5.1.5 SCP_0.2.5.9010 openxlsx_4.2.5 [8] plotly_4.10.1 scales_1.2.1 circlize_0.4.15 ComplexHeatmap_2.15.1 stringr_1.5.0 UCell_2.0.1 dplyr_1.0.10 [15] cowplot_1.1.1 ggplot2_3.4.0 SeuratDisk_0.0.0.9019 SeuratObject_4.1.3 Seurat_4.3.0 loaded via a namespace (and not attached): [1] vcd_1.4-10 ica_1.0-3 class_7.3-20 V8_4.2.1 foreach_1.5.2 lmtest_0.9-40 [7] rprojroot_2.0.3 crayon_1.5.2 laeken_0.5.2 MASS_7.3-58.1 Matrix.utils_0.9.8 nlme_3.1-160 [13] rlang_1.0.6 XVector_0.38.0 ROCR_1.0-11 irlba_2.3.5.1 limma_3.52.4 smoother_1.1 [19] filelock_1.0.2 BiocParallel_1.32.4 rjson_0.2.21 bit64_4.0.5 glue_1.6.2 sctransform_0.3.5 [25] parallel_4.2.0 spatstat.sparse_3.0-0 AnnotationDbi_1.60.0 BiocGenerics_0.44.0 classInt_0.4-8 yaImpute_1.0-33 [31] spatstat.geom_3.0-3 tidyselect_1.2.0 SummarizedExperiment_1.28.0 fitdistrplus_1.1-8 XML_3.99-0.13 tidyr_1.2.1 [37] zoo_1.8-11 sf_1.0-9 xtable_1.8-4 RcppHNSW_0.4.1 magrittr_2.0.3 cli_3.4.1 [43] zlibbioc_1.44.0 rstudioapi_0.14 miniUI_0.1.1.1 sp_1.5-1 parallelDist_0.2.6 RcppEigen_0.3.3.9.3 [49] shiny_1.7.4 clue_0.3-63 cluster_2.1.4 tidygraph_1.2.2 pcaMethods_1.88.0 KEGGREST_1.38.0 [55] tibble_3.1.8 ggrepel_0.9.2 listenv_0.9.0 Biostrings_2.66.0 png_0.1-8 future_1.30.0 [61] withr_2.5.0 bitops_1.0-7 ranger_0.14.1 plyr_1.8.8 e1071_1.7-12 pillar_1.8.1 [67] GlobalOptions_0.1.2 cachem_1.0.6 scatterplot3d_0.3-42 hdf5r_1.3.7 TTR_0.24.3 GetoptLong_1.0.5 [73] xts_0.12.1 vctrs_0.5.1 ellipsis_0.3.2 generics_0.1.3 rgdal_1.5-32 tools_4.2.0 [79] munsell_0.5.0 tweenr_2.0.2 proxy_0.4-27 DelayedArray_0.24.0 fastmap_1.1.0 compiler_4.2.0 [85] abind_1.4-5 httpuv_1.6.7 sessioninfo_1.2.2 rgeos_0.5-9 GenomeInfoDbData_1.2.9 gridExtra_2.3 [91] lattice_0.20-45 ggnewscale_0.4.8 deldir_1.0-6 utf8_1.2.2 later_1.3.0 BiocFileCache_2.6.0 [97] jsonlite_1.8.4 ggplot.multistats_1.0.0 princurve_2.1.6 pbapply_1.6-0 carData_3.0-5 lazyeval_0.2.2 [103] promises_1.2.0.1 car_3.1-0 doParallel_1.0.17 R.utils_2.12.2 goftest_1.2-3 spatstat.utils_3.0-1 [109] reticulate_1.26 Rtsne_0.16 Biobase_2.58.0 uwot_0.1.14 proxyC_0.3.3 yaml_2.3.6 [115] survival_3.4-0 systemfonts_1.0.4 htmltools_0.5.4 memoise_2.0.1 graphlayouts_0.8.4 IRanges_2.32.0 [121] destiny_3.10.0 viridisLite_0.4.1 digest_0.6.31 assertthat_0.2.1 mime_0.12 rappdirs_0.3.3 [127] units_0.8-1 RSQLite_2.2.19 future.apply_1.10.0 intrinsicDimension_1.2.0 data.table_1.14.6 blob_1.2.3 [133] S4Vectors_0.36.1 R.oo_1.25.0 styler_1.7.0 splines_4.2.0 labeling_0.4.2 rematch2_2.1.2 [139] Cairo_1.6-0 RCurl_1.98-1.9 hms_1.1.2 colorspace_2.0-3 GenomicRanges_1.50.2 shape_1.4.6 [145] nnet_7.3-18 GEOquery_2.64.2 Rcpp_1.0.9 RANN_2.6.1 fansi_1.0.3 tzdb_0.3.0 [151] VIM_6.2.2 parallelly_1.33.0 R6_2.5.1 ggridges_0.5.4 lifecycle_1.0.3 zip_2.2.1 [157] curl_4.3.3 leiden_0.4.3 robustbase_0.95-0 Matrix_1.5-1 RcppAnnoy_0.0.20 RColorBrewer_1.1-3 [163] iterators_1.0.14 spatstat.explore_3.0-5 R.cache_0.16.0 htmlwidgets_1.6.0 polyclip_1.10-4 biomaRt_2.54.0 [169] purrr_0.3.5 crosstalk_1.2.0 globals_0.16.2 SCopeLoomR_0.13.0 patchwork_1.1.2 spatstat.random_3.0-1 [175] slingshot_2.6.0 progressr_0.12.0 codetools_0.2-18 matrixStats_0.63.0 prettyunits_1.1.1 SingleCellExperiment_1.20.0 [181] dbplyr_2.2.1 RSpectra_0.16-1 R.methodsS3_1.8.2 GenomeInfoDb_1.34.4 gtable_0.3.1 DBI_1.1.3 [187] stats4_4.2.0 tensor_1.5 httr_1.4.4 KernSmooth_2.23-20 stringi_1.7.8 progress_1.2.2 [193] reshape2_1.4.4 farver_2.1.1 viridis_0.6.2 ggthemes_4.2.4 hexbin_1.28.2 magick_2.7.3 [199] xml2_1.3.3 boot_1.3-28 grr_0.9.5 readr_2.1.3 scattermore_1.0 DEoptimR_1.0-11 [205] bit_4.0.5 MatrixGenerics_1.10.0 spatstat.data_3.0-0 pkgconfig_2.0.3 TrajectoryUtils_1.6.0
temporary bypass method... https://github.com/thomasp85/ggforce/pull/312#issuecomment-1859660060
The following data and code can reproduce this issue. Note that the latest ggplot2 and ggforce are used.
When plotting with all the data above, geom_mark_hull only works for certain points.
However, when plotting with a subset of data (<40 data points), geom_mark_hull works without any omissions.