convPairs: Converts colPairs object into an abundance matrix based on...

View source: R/convPairs.R

convPairsR Documentation

Converts colPairs object into an abundance matrix based on number of nearby interactions for every cell type.

Description

Converts colPairs object into an abundance matrix based on number of nearby interactions for every cell type.

Usage

convPairs(cells, colPair, cellType = "cellType", imageID = "imageID")

Arguments

cells

A SingleCellExperiment that contains objects in the colPairs slot.

colPair

The name of the object in the colPairs slot for which the dataframe is constructed from.

cellType

The cell type if using SingleCellExperiment.

imageID

The image ID if using SingleCellExperiment.

Value

Matrix of abundances

Examples

data("diabetesData_SCE")

diabetesData_SPE <- SpatialExperiment::SpatialExperiment(diabetesData_SCE,
  colData = SingleCellExperiment::colData(diabetesData_SCE)
)
SpatialExperiment::spatialCoords(diabetesData_SPE) <- data.frame(
  SingleCellExperiment::colData(diabetesData_SPE)$x,
  SingleCellExperiment::colData(diabetesData_SPE)$y
) |>
  as.matrix()

SpatialExperiment::spatialCoordsNames(diabetesData_SPE) <- c("x", "y")

diabetesData_SPE <- imcRtools::buildSpatialGraph(diabetesData_SPE,
  img_id = "imageID",
  type = "knn",
  k = 20,
  coords = c("x", "y")
)

pairAbundances <- convPairs(diabetesData_SPE,
  colPair = "knn_interaction_graph"
)


ellispatrick/spicyR documentation built on April 27, 2024, 10:14 a.m.