BayesSpace icon indicating copy to clipboard operation
BayesSpace copied to clipboard

imagerow imagecol names in colData

Open jaredslosberg opened this issue 3 years ago • 4 comments

For doing clustering with spatialCluster(), the vignette makes it clear that colData() must have columns named "row" and "col" (#34, #40). When calling spatialEnhance() with visium, it now expects the columns to be "imagerow" and "imagecol":

function (sce, q, platform = c("Visium", "ST"), use.dimred = "PCA", 
    d = 15, init = NULL, init.method = c("spatialCluster", "mclust", 
        "kmeans"), model = c("t", "normal"), nrep = 2e+05, gamma = NULL, 
    mu0 = NULL, lambda0 = NULL, alpha = 1, beta = 0.01, save.chain = FALSE, 
    chain.fname = NULL, burn.in = 10000, jitter_scale = 5, jitter_prior = 0.3, 
    verbose = FALSE) 
{
    assert_that(nrep >= 100)
    assert_that(burn.in >= 0)
    if (burn.in >= nrep) 
        stop("Please specify a burn-in period shorter than the total number of iterations.")
    thin <- 100
    if (length(platform) > 1) {
        platform <- .bsData(sce, "platform", match.arg(platform))
    }
    else {
        platform <- match.arg(platform)
    }
    if (platform == "Visium") {
        position.cols <- c("imagecol", "imagerow")
        xdist <- ydist <- NULL
    }
    else if (platform == "ST") {
        position.cols <- c("col", "row")
        xdist <- ydist <- 1
    }

This wasn't clear to me and the error (same as issues referenced above) isn't informative about what the specific issue is. Adding these columns to colData() manually fixes the problem.

jaredslosberg avatar Feb 23 '22 20:02 jaredslosberg

Adding error message:

Error: subscript contains invalid names

jaredslosberg avatar Feb 23 '22 20:02 jaredslosberg

Sorry for the delayed response. With Visium data, we use the image coordinates to calculate distance instead of the array coordinates. These should be a part of the SpaceRanger output in the tissue_positions_list.csv, though they might be under another name if you used another package to load in the data. I'll try to clarify this in our next verison.

edward130603 avatar Mar 15 '22 05:03 edward130603

@edward130603 is spatialEnhance expecting imagecol to be the image pixel column? I'm having the same issue described here and it's not clear to me what is needed for this function since .compute_interspot_distances is looking for all of the following "row", "col", "imagerow", "imagecol" in colnames(colData(sce)

Currently SpaceRanger tissue_positions.csv defines array_col, array_row and pxl_row_in_fullres, pxl_col_in_fullres. Further complicating things, the pixel x,y coordinates are no longer stored in the SpatialExperiment colData slot, but are instead saved in int_colData$spatialCoords.

jmvera255 avatar Jan 25 '23 22:01 jmvera255

Yes, 10x has renamed those columns since we wrote the code. BayesSpace doesn't directly support the SpatialExperiment format yet, aside from the SingleCellExperiment functionality that it inherits..

edward130603 avatar Jan 25 '23 22:01 edward130603