VisualizeLabel: Visualize spot labels on the 2D slide

visualizeLabelR Documentation

Visualize spot labels on the 2D slide

Description

Generate and visualize spot labels on the 2D slide as a ggplot2 object. Spot labels can be given via parameter label as external input or one column in the slide slot of the slide object's metadata via label_col. Exactly one of label and label_col must be specified.

Usage

visualizeLabel(object, ...)

## Default S3 method:
visualizeLabel(
  object,
  label = "tissue",
  subset_barcodes = NULL,
  title = "",
  legend_title = NULL,
  ...
)

## S3 method for class 'SummarizedExperiment'
visualizeLabel(
  object,
  label = "tissue",
  subset_barcodes = NULL,
  title = "",
  legend_title = NULL,
  ...
)

Arguments

object

A slide object created or inherited from createSlide(), or a data.frame of slide information with columns: barcodes, tissue, imagerow, imagecol, etc.

...

Arguments passed to other methods

label

(categorical vector or chr) Either a vector of labels for all spots, or the column name in the slide slot of the slide object's metadata. In the former case, the order of values in the vector should match the spot barcodes in the slide object. In the latter case, The column should be categorical with reasonably number of unique labels. Default: "tissue"

subset_barcodes

(vector of chr) A subset of spot barcodes to plot. By default it plots all spots in the slide object. This can be useful when only plotting tissue spots or specific tissue types or regions. Default: NULL

title

(chr) Title of the plot. Default: ""

legend_title

(chr) Title of the legend. Under default, use label as legend title. Default: NULL

Value

A ggplot2 object.

Examples


data(mbrain_raw)
spatial_dir <- system.file(file.path("extdata",
                                     "V1_Adult_Mouse_Brain_spatial"),
                           package = "SpotClean")
mbrain_slide_info <- read10xSlide(tissue_csv_file=file.path(spatial_dir,
                                       "tissue_positions_list.csv"),
             tissue_img_file = file.path(spatial_dir,
                                       "tissue_lowres_image.png"),
             scale_factor_file = file.path(spatial_dir,
                                       "scalefactors_json.json"))
mbrain_obj <- createSlide(mbrain_raw,
                          mbrain_slide_info)
gp <- visualizeLabel(mbrain_obj, label="tissue",
                     title="mbrain", legend_title="tissue or background")
plot(gp)


zijianni/SpotClean documentation built on June 12, 2024, 1:58 a.m.