Error in (function (msg) : TopologyException: unable to assign free hole to a shell at 5376.6752999999999 -2471.8000000000002
Traceback:
1. plotSpatialFeature(sfe, features = rownames(sfe)[1], bbox = bbox_use,
. size = 4, colGeometryName = "cell", dark = TRUE, image_id = imgData(sfe)$image_id[1],
. )
2. .plotSpatialFeature(sfe, values, colGeometryName, sample_id,
. ncol, ncol_sample, annotGeometryName, annot_aes, annot_fixed,
. bbox, image_id, aes_use, divergent, diverge_center, annot_divergent,
. annot_diverge_center, size, shape, linewidth, linetype, alpha,
. color, fill, scattermore, pointsize, bins, summary_fun, hex,
. maxcell, dark, ...)
3. .crop(df, bbox)
4. .bbox_sample(df, bbox)
5. suppressWarnings(df <- st_intersection(df, bbox_use))
6. withCallingHandlers(expr, warning = function(w) if (inherits(w,
. classes)) tryInvokeRestart("muffleWarning"))
7. st_intersection(df, bbox_use)
8. st_intersection.sf(df, bbox_use)
9. geos_op2_df(x, y, geos_op2_geom("intersection", x, y, ...))
10. geos_op2_geom("intersection", x, y, ...)
11. st_sfc(CPL_geos_op2(op, x, y), crs = st_crs(x))
12. CPL_geos_op2(op, x, y)
13. (function (msg)
. {
. on.exit(stop(msg))
. lst = strsplit(msg, " at ")[[1]]
. pts = scan(text = lst[[length(lst)]], quiet = TRUE)
. if (length(pts) == 2 && is.numeric(pts))
. assign(".geos_error", st_point(pts), envir = .sf_cache)
. })("TopologyException: unable to assign free hole to a shell at 5376.6752999999999 -2471.8000000000002")
14. stop(msg)
Error in scan(text = lst[[length(lst)]], quiet = TRUE): scan() expected 'a real', got '-1677.7229097180282.'
Traceback:
1. SpatialFeatureExperiment::crop(sfe, colGeometryName = "cell",
. sample_id = "test_xenium", y = bbox_use)
2. lapply(colGeometries(out), .crop_geometry, y = y, samples_use = samples_use,
. op = op, id_col = "barcode", sample_col = colData(out)$sample_id)
3. FUN(X[[i]], ...)
4. lapply(names(gs), function(s) {
. if (s %in% samples_use) {
. if ("sample_id" %in% names(y)) {
. y_use <- st_geometry(y[y$sample_id == s, ])
. }
. else {
. y_use <- st_geometry(y)
. }
. .g <- gs[[s]][, c("geometry", id_col)]
. st_agr(.g) <- "constant"
. o <- op(.g, y_use)
. if (is(o, "sgbp")) {
. inds <- lengths(o) > 0L
. return(gs[[s]][inds, ])
. }
. else {
. if (any(!rownames(o) %in% rownames(.g))) {
. o <- aggregate(o, by = setNames(list(id = o[[id_col]]),
. id_col), FUN = unique)
. }
. return(merge(o, st_drop_geometry(gs[[s]]), by = id_col,
. all = TRUE))
. }
. }
. else {
. return(gs[[s]])
. }
. })
5. FUN(X[[i]], ...)
6. op(.g, y_use)
7. st_intersection.sf(.g, y_use)
8. geos_op2_df(x, y, geos_op2_geom("intersection", x, y, ...))
9. geos_op2_geom("intersection", x, y, ...)
10. st_sfc(CPL_geos_op2(op, x, y), crs = st_crs(x))
11. CPL_geos_op2(op, x, y)
12. (function (msg)
. {
. on.exit(stop(msg))
. lst = strsplit(msg, " at ")[[1]]
. pts = scan(text = lst[[length(lst)]], quiet = TRUE)
. if (length(pts) == 2 && is.numeric(pts))
. assign(".geos_error", st_point(pts), envir = .sf_cache)
. })("TopologyException: side location conflict at 1870.8501000000001 -1677.7229097180282. This can occur if the input geometry is invalid.")
13. scan(text = lst[[length(lst)]], quiet = TRUE)