Skip to content

aggregateAcrossCells Error: "New 'sample_id's must map uniquely" only in SpatialExperiment #35

@lahuuki

Description

@lahuuki

Hi scuttle team,

I have found an issue with scuttle::aggregateAcrossCells() . Trying to pseudobulk a SpatialExperiment object on a single variable in colData results in the error Error in .local(x, ..., value) : New 'sample_id's must map uniquely.

The traceback() on this error is unhelpful, and the error message leaves me unsure of what to change.

However if I convert the object to a SingleCellExperiment the function runs as expected.

library("spatialLIBD")
library("scuttle")

spe <- fetch_data("spe")
class(spe)
# [1] "SpatialExperiment"

table(spe$spatialLIBD)
# L1    L2    L3    L4    L5    L6    WM 
# 5322  2858 17587  3547  7300  6201  4514

spe_pseudo <- scuttle::aggregateAcrossCells(spe, id = spe$spatialLIBD)
# Error in .local(x, ..., value) : New 'sample_id's must map uniquely

## conver to single cell 
spatialCoords(spe) <- NULL
imgData(spe) <- NULL

spe <- as(spe, "SingleCellExperiment")

## runs successfully
spe_pseudo <- scuttle::aggregateAcrossCells(spe, id = spe$spatialLIBD)


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions