Skip to contents

Constructs a SpatialCellData-class object from a counts matrix, coordinate data frame, and optional metadata.

Usage

CreateSpatialObject(
  counts,
  coords,
  meta_data = NULL,
  sample_id = "sample1",
  project = "SpatialProject"
)

Arguments

counts

Real numeric matrix (cells x markers), without infinity. Missing values are allowed. Row names are optional. Empty matrices retain their marker columns; all-missing columns in nonempty inputs are dropped with a warning. Logical placeholders with no entries, as produced by zero-row or zero-marker matrices, are stored as numeric matrices.

coords

Data frame with finite numeric columns x and y. Zero-row logical coordinate placeholders are stored as numeric vectors; nonempty logical values and factors are refused.

meta_data

Data frame of per-cell metadata, or NULL.

sample_id

Character. Sample identifier. Default "sample1".

project

Character. Project name. Default "SpatialProject".

Value

A SpatialCellData-class object.

Examples

counts <- matrix(rnorm(50), nrow = 10,
                 dimnames = list(NULL, c("CD3", "CD8", "CD20", "DAPI", "PanCK")))
coords <- data.frame(x = runif(10, 0, 500), y = runif(10, 0, 500))
obj <- CreateSpatialObject(counts, coords, sample_id = "mysample")
obj
#> A SpatialCellData object
#>   10 cells across 1 sample
#>   Markers: CD3, CD8, CD20, DAPI, PanCK 
#>   Normalised: FALSE 
#>   Project: SpatialProject