View source: R/aggregateNeighbors.R
aggregateNeighbors | R Documentation |
Function to summarize categorical or expression values of all neighbors of each cell.
aggregateNeighbors(
object,
colPairName,
aggregate_by = c("metadata", "expression"),
count_by = NULL,
proportions = TRUE,
assay_type = NULL,
subset_row = NULL,
statistic = c("mean", "median", "sd", "var"),
name = NULL
)
object |
a |
colPairName |
single character indicating the |
aggregate_by |
character specifying whether the neighborhood should be
summarized by cellular features stored in |
count_by |
for |
proportions |
single logical indicating whether aggregated metadata should be returned in form of proportions instead of absolute counts. |
assay_type |
for |
subset_row |
for |
statistic |
for |
name |
single character specifying the name of the data frame to be
saved in the |
returns an object of class(object)
containing the aggregated
values in form of a DataFrame
object in
colData(object)[[name]]
.
Daniel Schulz (daniel.schulz@uzh.ch)
library(cytomapper)
data(pancreasSCE)
sce <- buildSpatialGraph(pancreasSCE, img_id = "ImageNb",
type = "knn", k = 3)
# Aggregating neighboring cell-types
sce <- aggregateNeighbors(sce, colPairName = "knn_interaction_graph",
aggregate_by = "metadata",
count_by = "CellType")
sce$aggregatedNeighbors
# Aggregating neighboring expression values
sce <- aggregateNeighbors(sce, colPairName = "knn_interaction_graph",
aggregate_by = "expression",
assay_type = "exprs",
statistic = "mean")
sce$mean_aggregatedExpression
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.