This function adds spe$key
to a
SpatialExperiment-class object
which is unique across all spots.
add_key(spe, overwrite = TRUE)
A SpatialExperiment-class object.
A logical(1)
indicating whether to overwrite the spe$key
.
A
SpatialExperiment-class object
with key
added to the colData(spe)
that is unique across all spots.
if (enough_ram()) {
## Obtain the necessary data
if (!exists("spe")) spe <- fetch_data("spe")
## This object already has a 'key'
head(spe$key)
## We can clean it
spe$key <- NULL
## and then add it back
head(add_key(spe)$key)
## Note that the original 'key' order was 'sample_id'_'barcode' and we'
## have since changed it to 'barcode'_'sample_id'.
}
#> 2023-09-05 20:28:53.825497 loading file /github/home/.cache/R/BiocFileCache/152d33414640_Human_DLPFC_Visium_processedData_sce_scran_spatialLIBD.Rdata%3Fdl%3D1
#> [1] "AAACAACGAATAGTTC-1_151507" "AAACAAGTATCTCCCA-1_151507"
#> [3] "AAACAATCTACTAGCA-1_151507" "AAACACCAATAACTGC-1_151507"
#> [5] "AAACAGCTTTCAGAAG-1_151507" "AAACAGGGTCTATATT-1_151507"