View source: R/minDistToCells.R
minDistToCells | R Documentation |
Function to return the distance of the closest cell of interest for each cell in the data. In the case of patched/clustered cells negative distances are returned by default which indicate the distance of the cells of interest to the closest cell that is not of the type of cells of interest.
minDistToCells(
object,
x_cells,
img_id,
name = "distToCells",
coords = c("Pos_X", "Pos_Y"),
return_neg = TRUE,
BPPARAM = SerialParam()
)
object |
a |
x_cells |
logical vector of length equal to the number of cells
contained in |
img_id |
single character indicating the |
name |
character specifying the name of the |
coords |
character vector of length 2 specifying the names of the
|
return_neg |
logical indicating whether negative distances are to be returned for the distances of patched/spatially clustered cells. |
BPPARAM |
a |
returns an object of class(object)
containing a new column
entry to colData(object)[[name]]
. Cells in the object are grouped
by entries in img_id
.
The minDistToCells
function operates on individual images.
Therefore the returned object is grouped by entries in img_id
.
This means all cells of a given image are grouped together in the object.
The ordering of cells within each individual image is the same as the ordering
of these cells in the input object.
Daniel Schulz (daniel.schulz@uzh.ch)
library(cytomapper)
data(pancreasSCE)
# Build interaction graph
pancreasSCE <- buildSpatialGraph(pancreasSCE, img_id = "ImageNb",
type = "expansion",threshold = 20)
# Detect patches of "celltype_B" cells
pancreasSCE <- patchDetection(pancreasSCE,
img_id = "ImageNb",
patch_cells = pancreasSCE$CellType == "celltype_B",
colPairName = "expansion_interaction_graph",
min_patch_size = 20,
expand_by = 1)
plotSpatial(pancreasSCE,
img_id = "ImageNb",
node_color_by = "patch_id",
scales = "free")
# Distance to celltype_B patches
pancreasSCE <- minDistToCells(pancreasSCE,
x_cells = !is.na(pancreasSCE$patch_id),
coords = c("Pos_X","Pos_Y"),
img_id = "ImageNb")
plotSpatial(pancreasSCE,
img_id = "ImageNb",
node_color_by = "distToCells",
scales = "free")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.