cluster_import: Import cluster results

View source: R/cluster_import.R

cluster_importR Documentation

Import cluster results

Description

This function imports previously exported clustering results with cluster_export() and adds them to the colData() slot of your SpatialExperiment-class object.

Usage

cluster_import(
  spe,
  cluster_dir = file.path(tempdir(), "exported_clusters"),
  prefix = "imported_",
  overwrite = TRUE
)

Arguments

spe

Defaults to the output of fetch_data(type = 'spe'). This is a SpatialExperiment-class object with the spot-level Visium data and information required for visualizing the histology. See fetch_data() for more details.

cluster_dir

A character(1) specifying the output directory, similar to the outs/analysis/clustering produced by SpaceRanger.

prefix

A character(1) specifying the prefix to use when naming these new cluster variables.

overwrite

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

Value

A SpatialExperiment-class object with the imported clusters appended on the colData().

See Also

Other cluster export/import utility functions: cluster_export()

Examples

if (enough_ram()) {
    ## Obtain the necessary data
    if (!exists("spe")) spe <- fetch_data("spe")

    ## Export two cluster variables
    cluster_export(spe, "spatialLIBD")
    cluster_export(spe, "GraphBased")

    ## Re-import them
    colData(cluster_import(spe))
}

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