add_key: Create a unique spot identifier

View source: R/add_key.R

add_keyR Documentation

Create a unique spot identifier

Description

This function adds spe$key to a SpatialExperiment-class object which is unique across all spots.

Usage

add_key(spe, overwrite = TRUE)

Arguments

spe

A SpatialExperiment-class object.

overwrite

A logical(1) indicating whether to overwrite the spe$key.

Value

A SpatialExperiment-class object with key added to the colData(spe) that is unique across all spots.

Examples

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'.
}

LieberInstitute/spatialLIBD documentation built on April 21, 2024, 6:47 p.m.