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

A SpatialExperiment-class object. See fetch_data() for how to download some example objects or read10xVisiumWrapper() to read in spaceranger --count output files and build your own spe object.

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 Dec. 19, 2024, 7:12 p.m.