ce9a3ef198cf80041f596e00943bcc775806d429 max Thu Nov 6 06:33:09 2025 -0800 flipping x and y for seurat diff --git src/cbPyLib/cellbrowser/R/cellbrowser.R src/cbPyLib/cellbrowser/R/cellbrowser.R index 6b62d4a..b7c23e9 100644 --- src/cbPyLib/cellbrowser/R/cellbrowser.R +++ src/cbPyLib/cellbrowser/R/cellbrowser.R @@ -118,31 +118,31 @@ message("Writing image ", imgPath) #writePNG(img, imgPath); # JPEG seems like a better choice here, 4x smaller at default quality settings. writeJPEG(img, target=imgPath, quality=0.95); yMax = dim(img)[1]; xMax = dim(img)[2]; # there is a difference of 3 pixels on height when comparing "identify file.jpeg" with this. NO IDEA WHY! coordsPath <- file.path(outDir, paste0(name, ".coords.tsv")) message("Writing coords for image to ", coordsPath) coords <- GetTissueCoordinates(object = obj[[name]]) if (all(c("imagecol", "imagerow") %in% colnames(coords))) { # Seurat-style naming: reverse order coordsRev <- coords[, c("imagecol", "imagerow")] colnames(coordsRev) <- c("x", "y") } else if (all(c("x", "y") %in% colnames(coords))) { # Already in standard x/y format - coordsRev <- coords[, c("x", "y")] + coordsRev <- coords[, c("y", "x")] } else { stop("Error: coordinates must have either (imagecol, imagerow) or (x, y) columns.") } write.table(coordsRev, coordsPath, sep="\t", row.names=T, quote=F, col.names=NA) conf <- sprintf( ' {\n "file": "%s",\n "shortLabel": "Spatial %s",\n "flipY":True,\n "images" : [{"file":"%s"}],\n "minX":0, "minY":0, "maxX":%d, "maxY":%d\n }', coordsPath, name, imgPath, xMax, yMax ) embeddings.conf <- c(conf, embeddings.conf) }