10 Changes in marker expression
Sometimes, cells that appear similar based on marker expression alone can behave very differently depending on their surroundings. Subtle shifts in marker levels—too faint or variable to be captured through clustering—may hold important clues about a cell’s functional state. For example, immune cells may only become activated when positioned near tumour or infected cells, and these changes may not be detectable when cells are analysed in isolation. Technical noise and overlapping expression patterns further complicate efforts to distinguish such nuanced subpopulations using conventional approaches.
In these cases, spatial context becomes a critical lens. By analysing how marker expression varies in relation to a cell’s neighbourhood—such as its proximity to other cell types or tissue structures—we can uncover functional diversity that would otherwise remain hidden. This spatial perspective reveals how cells adapt to their microenvironment, transition between states, or participate in local interactions, offering a richer understanding of tissue dynamics and disease mechanisms.
The SpatioMark
method, implemented in the Statial
package, is designed for exactly this purpose. It detects markers whose expression levels change within a given cell type depending on their spatial context—highlighting activation, suppression, or other state changes that are missed by standard clustering.
# set parameters
set.seed(51773)
# whether to use multiple cores (recommended)
use_mc = TRUE
is_windows = .Platform$OS.type == "windows"
if (use_mc) {
nCores = max(ceiling(parallel::detectCores() / 2), 1)
if (nCores == 1) {
BPPARAM = BiocParallel::SerialParam()
} else if (is_windows) {
BPPARAM = BiocParallel::SnowParam(workers = nCores, type = "SOCK")
} else {
BPPARAM = BiocParallel::MulticoreParam(workers = nCores)
}
} else {
BPPARAM = BiocParallel::SerialParam()
}
theme_set(theme_classic())
10.1 Statial: Marker means
Before diving into spatially contextualised marker changes with SpatioMark
, it’s useful to understand how more conventional marker expression summaries—like marker means—can still offer valuable insight, especially when stratified by spatial features. A marker mean provides a simple but effective way to quantify expression: we calculate the average intensity of a marker across a set of cells, and then compare these averages across experimental conditions. While this can be done at the whole-image level, much more meaningful biological comparisons emerge when we stratify by cell type, spatial domain, or both.
For example, if you’re interested in understanding how CD163 expression changes in infiltrating macrophages located specifically within tumour regions across treatment groups, you would focus on the marker mean for macrophages confined to that domain. This allows you to ask precise questions about functional changes in well-defined spatial and cellular contexts.
For this demonstration, we will use the Keren 2018 dataset.
kerenSPE <- SpatialDatasets::spe_Keren_2018()
# Removing patients without survival data.
kerenSPE <- kerenSPE[,!is.na(kerenSPE$`Survival_days_capped*`)]
# identify spatial domains with lisaClust
kerenSPE <- lisaClust(kerenSPE,
k = 5,
BPPARAM = BPPARAM)
kerenSPE$event = 1 - kerenSPE$Censored
kerenSPE$survival = Surv(kerenSPE$`Survival_days_capped*`, kerenSPE$event)
# Extracting survival data
survData <- kerenSPE |>
colData() |>
data.frame() |>
select(imageID, survival) |>
unique()
kerenSPE$survival <- NULL
# Creating survival vector
kerenSurv <- survData$survival
names(kerenSurv) <- survData$imageID
kerenSurv <- kerenSurv[!is.na(kerenSurv)]
Our Statial
package provides functionality to identify the average marker expression of a given cell type in a given region, using the getMarkerMeans
function. Similar to spicyR
and lisaClust
, these features can also be used for survival analysis.
cellTypeRegionMeans <- getMarkerMeans(kerenSPE,
imageID = "imageID",
cellType = "cellType",
region = "region")
cellTypeRegionMeans[1:3, 1:3]
Na__Keratin_Tumour__region_2 Si__Keratin_Tumour__region_2
1 -0.7775969 -0.5503253
2 0.1489698 -0.2596228
3 -0.7918177 -0.5268896
P__Keratin_Tumour__region_2
1 -1.1306943
2 -0.8310180
3 -0.4678555
The output is a dataframe containing the average expression of each marker in each cell type in each region. The column names are formatted as: marker__cell_type__region
.
We can use the colTest
function from spicyR to check whether average marker expression in each cell type in each region is associated with survival probability. colTest
requires three arguments: i) df
specifies the dataframe containing marker means, ii) condition
specifies the outcome of interest, and iii) type
specifies the type of test to perform (wilcox, t-test, or survival). In the code below, we’ve specified condition
to be our Surv
vector and type = survival
indicates we are performing survival analysis.
survivalResults <- colTest(df = cellTypeRegionMeans[names(kerenSurv), ],
condition = kerenSurv,
type = "survival")
head(survivalResults)
coef se.coef pval adjPval
B7H3__CD4_T_cell__region_1 270.0 76.00 0.00038 0.42
CD163__CD4_T_cell__region_1 67.0 19.00 0.00038 0.42
FoxP3__CD4_T_cell__region_1 25.0 7.20 0.00052 0.42
Si__Unidentified__region_4 -3.1 0.89 0.00053 0.42
CD56__CD4_T_cell__region_1 28.0 8.10 0.00067 0.42
Keratin6__Keratin_Tumour__region_3 1.6 0.47 0.00074 0.42
cluster
B7H3__CD4_T_cell__region_1 B7H3__CD4_T_cell__region_1
CD163__CD4_T_cell__region_1 CD163__CD4_T_cell__region_1
FoxP3__CD4_T_cell__region_1 FoxP3__CD4_T_cell__region_1
Si__Unidentified__region_4 Si__Unidentified__region_4
CD56__CD4_T_cell__region_1 CD56__CD4_T_cell__region_1
Keratin6__Keratin_Tumour__region_3 Keratin6__Keratin_Tumour__region_3
Our most significant relationship appears to be B7H3__CD4_T_cell__region_1
, which represents the average expression of the B7H3 marker in CD4 T cells in region 1. The positive coefficient associated with this relationship indicates that higher expression of B7H3 in CD4 T cells in this region is associated with poorer survival outcomes for patients.
We can examine this relationship in more detail by plotting a Kaplan-Meier curve.
# Selecting the most significant relationship
survRelationship <- cellTypeRegionMeans[["B7H3__CD4_T_cell__region_1"]]
survRelationship <- ifelse(survRelationship > median(survRelationship), "Higher expression", "Lower expression")
# Plotting Kaplan-Meier curve
survfit2(kerenSurv ~ survRelationship) |>
ggsurvfit() +
add_pvalue() +
ggtitle("B7H3__CD4_T_cell__region_1")
We can also look at cell types alone, without separating by region. To do this, we simply do not specify region
.
cellTypeMeans <- getMarkerMeans(kerenSPE,
imageID = "imageID",
cellType = "cellType")
survivalResults <- colTest(cellTypeMeans[names(kerenSurv), ], kerenSurv, type = "survival")
head(survivalResults)
coef se.coef pval adjPval cluster
CD56__Tregs 15.0 4.20 0.00051 0.41 CD56__Tregs
HLA_Class_1__Mono_or_Neu -1.4 0.47 0.00230 0.51 HLA_Class_1__Mono_or_Neu
FoxP3__Endothelial 120.0 40.00 0.00350 0.51 FoxP3__Endothelial
CD138__Macrophages 1.1 0.39 0.00490 0.51 CD138__Macrophages
HLA_Class_1__CD8_T_cell -1.3 0.48 0.00520 0.51 HLA_Class_1__CD8_T_cell
CD138__dn_T_CD3 0.4 0.15 0.00570 0.51 CD138__dn_T_CD3
# Selecting the most significant relationship
survRelationship <- cellTypeMeans[["CD56__Tregs"]]
survRelationship <- ifelse(survRelationship > median(survRelationship), "Higher expression", "Lower expression")
# Plotting Kaplan-Meier curve
survfit2(kerenSurv ~ survRelationship) |>
ggsurvfit() +
add_pvalue() +
ggtitle("CD56__Tregs")
The coefficient associated with CD56__Tregs
is positive, which indicates that higher expression is associated with poorer survival outcomes for patients, and this is also reflected in the KM curve.
10.2 SpatioMark: Identifying continuous changes in cell state
Marker means summarised per cell type or per spatial region can offer valuable insights into how expression levels vary across conditions or anatomical compartments. However, these summaries treat cells as independent units and often miss finer-grained, dynamic patterns that arise from cell-cell interactions.
This is where SpatioMark
becomes particularly powerful. Instead of averaging across broad groups, SpatioMark
captures how marker expression in a given cell type changes in a continuous fashion based on proximity to other cell types. This allows us to detect context-dependent expression shifts—revealing, for instance, how the presence of neighbouring immune or tumour cells can influence a cell’s functional state. By focusing on these spatial gradients in marker expression, SpatioMark provides a framework for understanding how local microenvironments modulate cell behaviour in situ.
10.2.1 Continuous cell state changes within a single image
The first step in analysing these changes is to calculate the spatial proximity and abundance of each cell to every cell type. getDistances
calculates the Euclidean distance from each cell to the nearest cell of each cell type. getAbundances
calculates the K-function value for each cell with respect to each cell type. Both metrics are stored in the reducedDims
slot of the SpatialExperiment
object.
# assign spatial coordinates
kerenSPE$x = spatialCoords(kerenSPE)[, 1]
kerenSPE$y = spatialCoords(kerenSPE)[, 2]
# calculate distances for a maximum distance of 200
kerenSPE <- getDistances(kerenSPE,
maxDist = 200)
# calculate K-function for a radius of 200
kerenSPE <- getAbundances(kerenSPE,
r = 200,
nCores = nCores)
reducedDims(kerenSPE)
List of length 2
names(2): distances abundances
First, let’s examine the same effect observed earlier with Kontextual
- the localisation between p53+ keratin/tumour cells and macrophages in the context of total keratin/tumour cells for image 6 of the Keren 2018 dataset.
Statial provides two main functions to assess this relationship - calcStateChanges
and plotStateChanges
. We can use calcStateChanges
to examine the relationship between two cell types for one marker in a specific image. In this case, we’re examining the relationship between keratin/tumour cells (from = Keratin_Tumour
) and macrophages (to = "Macrophages"
) for the marker p53 (marker = "p53"
) in image = "6"
. We can appreciate that the fdr
statistic for this relationship is significant, with a negative t-value, indicating that the expression of p53 in keratin/tumour cells decreases as distance from macrophages increases.
stateChanges <- calcStateChanges(
cells = kerenSPE,
type = "distances",
image = "6",
from = "Keratin_Tumour",
to = "Macrophages",
marker = "p53",
nCores = nCores)
stateChanges
imageID primaryCellType otherCellType marker coef tval
1 6 Keratin_Tumour Macrophages p53 -0.001402178 -7.010113
pval fdr
1 2.868257e-12 2.868257e-12
Statial also provides a convenient function for visualising this interaction - plotStateChanges
. Here, again we can specify image = 6
and our main cell types of interest, keratin/tumour cells and macrophages, and our marker p53, in the same format as calcStateChanges
.
Through this analysis, we can observe that keratin/tumour cells closer to a group of macrophages tend to have higher expression of p53, as observed in the first graph. This relationship is quantified with the second graph, showing an overall decrease of p53 expression in keratin/tumour cells as distance from macrophages increases.
These results allow us to essentially arrive at the same result as Kontextual, which calculated a localisation between p53+ keratin/tumour cells and macrophages in the wider context of keratin/tumour cells.
p <- plotStateChanges(
cells = kerenSPE,
type = "distances",
image = "6",
from = "Keratin_Tumour",
to = "Macrophages",
marker = "p53",
size = 1,
shape = 19,
interactive = FALSE,
plotModelFit = FALSE,
method = "lm")
# plot the image
p$image
# plot the scatter plot
p$scatter
10.2.2 Continuous cell state changes across all images
Beyond looking at single cell-to-cell interactions for a single image, we can also look at all interactions across all images. The calcStateChanges
function provided by Statial can be expanded for this exact purpose - by not specifying cell types, a marker, or an image, calcStateChanges
will examine the most significant correlations between distance and marker expression across the entire dataset. Here, we’ve filtered out the most significant interactions to only include those found within image 6 of the Keren 2018 dataset.
stateChanges <- calcStateChanges(
cells = kerenSPE,
type = "distances",
nCores = nCores,
minCells = 100
)
stateChanges |>
filter(imageID == 6) |>
head(n = 10)
imageID primaryCellType otherCellType marker coef tval
1 6 Keratin_Tumour Unidentified Na 0.004218419 25.03039
2 6 Keratin_Tumour Macrophages HLA_Class_1 -0.003823497 -24.69629
3 6 Keratin_Tumour CD4_T_cell HLA_Class_1 -0.003582774 -23.87797
4 6 Keratin_Tumour Unidentified Beta.catenin 0.005893120 23.41953
5 6 Keratin_Tumour CD8_T_cell HLA_Class_1 -0.003154544 -23.13804
6 6 Keratin_Tumour DC_or_Mono HLA_Class_1 -0.003353834 -22.98944
7 6 Keratin_Tumour dn_T_CD3 HLA_Class_1 -0.003123446 -22.63197
8 6 Keratin_Tumour Tumour HLA_Class_1 0.003684079 21.94265
9 6 Keratin_Tumour CD4_T_cell Fe -0.003457338 -21.43550
10 6 Keratin_Tumour CD4_T_cell phospho.S6 -0.002892457 -20.50767
pval fdr
1 6.971648e-127 3.361087e-123
2 7.814253e-124 3.408521e-120
3 1.745242e-116 5.328836e-113
4 1.917245e-112 5.488145e-109
5 5.444541e-110 1.424922e-106
6 1.053130e-108 2.679645e-105
7 1.237988e-105 2.870893e-102
8 8.188258e-100 1.630540e-96
9 1.287478e-95 2.246354e-92
10 3.928912e-88 5.712544e-85
In image 6, the majority of the top 10 most significant interactions occur between keratin/tumour cells and an immune population, and many of these interactions appear to involve the HLA class I ligand.
We can examine some of these interactions further with the plotStateChanges
function.
p <- plotStateChanges(
cells = kerenSPE,
type = "distances",
image = "6",
from = "Keratin_Tumour",
to = "Macrophages",
marker = "HLA_Class_1",
size = 1,
shape = 19,
interactive = FALSE,
plotModelFit = FALSE,
method = "lm"
)
# plot the image
p$image
# plot the scatter plot
p$scatter
The plot above shows us a clear visual correlation - as the distance from macrophages decreases, keratin/tumour cells increase their expression HLA class I. Biologically, HLA Class I molecules are ligands present on all nucleated cells, responsible for presenting internal cell antigens to the immune system. Their role is to mark abnormal cells for destruction by CD8+ T cells or NK cells, facilitating immune surveillance and response.
Next, let’s take a look at the top 10 most significant results across all images.
stateChanges |> head(n = 10)
imageID primaryCellType otherCellType marker coef
69468 37 Endothelial Tumour Lag3 -0.001621517
150351 11 Neutrophils NK CD56 -0.059936866
16402 35 CD4_T_cell B_cell CD20 -0.029185750
16498 35 CD4_T_cell DC_or_Mono CD20 0.019125946
4891 35 B_cell DC_or_Mono phospho.S6 0.005282065
16507 35 CD4_T_cell DC_or_Mono phospho.S6 0.004033218
4885 35 B_cell DC_or_Mono HLA.DR 0.011120703
5043 35 B_cell Other_Immune P 0.011182182
16354 35 CD4_T_cell dn_T_CD3 CD20 0.016349492
4888 35 B_cell DC_or_Mono H3K9ac 0.005096632
tval pval fdr
69468 -1.082138e+14 0.000000e+00 0.000000e+00
150351 -1.419485e+14 0.000000e+00 0.000000e+00
16402 -4.057355e+01 7.019343e-282 4.286502e-277
16498 4.053436e+01 1.891267e-281 8.662052e-277
4891 4.041385e+01 5.306590e-278 1.944345e-273
16507 3.472882e+01 4.519947e-219 1.380098e-214
4885 3.415344e+01 8.401034e-212 2.198683e-207
5043 3.414375e+01 1.056403e-211 2.419176e-207
16354 3.391901e+01 1.219488e-210 2.482349e-206
4888 3.399856e+01 3.266533e-210 5.984320e-206
Immediately, we can appreciate that a couple of these interactions are not biologically plausible. One of the most significant interactions occurs between B cells and CD4 T cells in image 35, where CD4 T cells are found to increase CD20 expression when in close proximity to B cells. Biologically, CD20 is a highly specific marker for B cells, and under healthy circumstances are usually not expressed in T cells.
Could this potentially be an artefact of calcStateChanges
? We can examine the image through the plotStateChanges
function, where we indeed observe a strong increase in CD20 expression in T cells nearby B cell populations.
p <- plotStateChanges(
cells = kerenSPE,
type = "distances",
image = "35",
from = "CD4_T_cell",
to = "B_cell",
marker = "CD20",
size = 1,
shape = 19,
interactive = FALSE,
plotModelFit = FALSE,
method = "lm")
# plot the image
p$image
# plot the scatter plot
p$scatter
`geom_smooth()` using formula = 'y ~ x'
Warning: Removed 26 rows containing missing values or values outside the scale range
(`geom_smooth()`).
So why are T cells expressing CD20? This brings us to a key problem of cell segmentation - contamination.
10.2.3 Contamination (Lateral marker spill over)
Contamination, or lateral marker spill over, is an issue that results in a cell’s marker expressions being wrongly attributed to another adjacent cell. This issue arises from incorrect segmentation where components of one cell are wrongly determined as belonging to another cell. Alternatively, this issue can arise when antibodies used to tag and measure marker expressions don’t latch on properly to a cell of interest, thereby resulting in residual markers being wrongly assigned as belonging to a cell near the intended target cell. It is important that we either correct or account for this incorrect attribution of markers in our modelling process. This is critical in understanding whether significant cell-cell interactions detected are an artefact of technical measurement errors driven by spill over or are real biological changes that represent a shift in a cell’s state.
To circumvent this problem, Statial provides a function that predicts the probability that a cell is any particular cell type - calcContamination
. calcContamination
returns a dataframe of probabilities demarcating the chance of a cell being any particular cell type. This dataframe is stored under contaminations
in the reducedDim
slot of the SingleCellExperiment
object. It also provides the rfMainCellProb
column, which provides the probability that a cell is indeed the cell type it has been designated. For example, for a cell designated as CD8, rfMainCellProb
could give a 80% chance that the cell is indeed CD8, due to contamination.
We can then introduce these probabilities as covariates into our linear model by setting contamination = TRUE
as a parameter in our calcStateChanges
function.
kerenSPE <- calcContamination(kerenSPE)
Growing trees.. Progress: 93%. Estimated remaining time: 2 seconds.
stateChangesCorrected <- calcStateChanges(
cells = kerenSPE,
type = "distances",
nCores = 1,
minCells = 100,
contamination = TRUE
)
stateChangesCorrected |> head(n = 10)
imageID primaryCellType otherCellType marker coef
69468 37 Endothelial Tumour Lag3 -0.001621517
150351 11 Neutrophils NK CD56 -0.059936866
16402 35 CD4_T_cell B_cell CD20 -0.025114581
16498 35 CD4_T_cell DC_or_Mono CD20 0.016154346
4891 35 B_cell DC_or_Mono phospho.S6 0.004312579
16507 35 CD4_T_cell DC_or_Mono phospho.S6 0.003593907
88516 3 Keratin_Tumour DC Ca -0.014151972
16354 35 CD4_T_cell dn_T_CD3 CD20 0.013728798
16357 35 CD4_T_cell dn_T_CD3 HLA.DR 0.010329232
3697 28 B_cell NK Na -0.004480367
tval pval fdr
69468 -6.030700e+13 0.000000e+00 0.000000e+00
150351 -1.522794e+14 0.000000e+00 0.000000e+00
16402 -3.515983e+01 2.259264e-223 1.379665e-218
16498 3.402099e+01 1.677480e-211 7.682901e-207
4891 2.994786e+01 1.340822e-169 4.912800e-165
16507 2.958522e+01 6.665852e-167 1.959134e-162
88516 -3.004738e+01 7.485733e-167 1.959134e-162
16354 2.955635e+01 1.271559e-166 2.911886e-162
16357 2.886146e+01 6.506249e-160 1.324390e-155
3697 -2.904572e+01 1.101584e-157 2.018113e-153
However, this is not a perfect solution for the issue of contamination. As we can see, despite factoring in contamination into our linear model, the correlation between B cell density and CD20 expression in CD4 T cells remains one of the most significant interactions in our model.
However, this does not mean factoring in contamination into our linear model was ineffective.
Whilst our correction attempts do not rectify every relationship which arises due to contamination, we show that a significant portion of these relationships are rectified. We can show this by plotting a ROC curve of true positives against false positives. In general, cell type specific markers such as CD4 (specific to T helper cells), CD8 (specific to cytotoxic T cells), and CD20 should not change in cells they are not specific to. Therefore, relationships detected to be significant involving these cell type markers are likely false positives and will be treated as such for the purposes of evaluation. Meanwhile, cell state markers are predominantly likely to be true positives.
Plotting the relationship between false positives and true positives, we’d expect the contamination correction to be greatest in the relationships with the top 100 lowest p values, where we indeed see more true positives than false positives with contamination correction.
cellTypeMarkers <- c("CD3", "CD4", "CD8", "CD56", "CD11c", "CD68", "CD45", "CD20")
values <- c("blue", "red")
names(values) <- c("None", "Corrected")
df <- rbind(
data.frame(TP = cumsum(stateChanges$marker %in% cellTypeMarkers),
FP = cumsum(!stateChanges$marker %in% cellTypeMarkers), type = "None"),
data.frame(TP = cumsum(stateChangesCorrected$marker %in% cellTypeMarkers),
FP = cumsum(!stateChangesCorrected$marker %in% cellTypeMarkers), type = "Corrected"))
ggplot(df, aes(x = TP, y = FP, colour = type)) +
geom_line() +
labs(y = "Cell state marker (FP)", x = "Cell type marker (TP)") +
scale_colour_manual(values = values)
Below, we zoom in on the ROC curve where the top 100 lowest p values occur, where we indeed see more true positives than false positives with contamination correction.
10.2.4 Associate continuous state changes with survival outcomes
Similiar to Kontextual
, we can run a similar survival analysis using our SpatioMark
results. Here, prepMatrix
extracts the coefficients, or the coef
column of stateChanges
by default. To use the t-values instead, specify column = "tval"
in the prepMatrix
function. As before, we use colTest
to build the CoxPH model.
# Preparing features for Statial
stateMat <- prepMatrix(stateChanges)
# Ensuring rownames of stateMat match up with rownames of the survival vector
stateMat <- stateMat[names(kerenSurv), ]
# Remove some very small values
stateMat <- stateMat[, colMeans(abs(stateMat) > 0.0001) > .8]
survivalResults <- colTest(stateMat, kerenSurv, type = "survival")
head(survivalResults)
coef se.coef pval adjPval
Keratin_Tumour__Mono_or_Neu__Pan.Keratin -280 89 0.0018 0.63
Macrophages__Keratin_Tumour__HLA_Class_1 220 75 0.0034 0.63
Keratin_Tumour__CD8_T_cell__Keratin6 -220 77 0.0036 0.63
Macrophages__Other_Immune__HLA_Class_1 -480 170 0.0057 0.75
Keratin_Tumour__Mesenchymal__dsDNA -810 310 0.0094 0.80
Keratin_Tumour__Unidentified__H3K27me3 490 190 0.0100 0.80
cluster
Keratin_Tumour__Mono_or_Neu__Pan.Keratin Keratin_Tumour__Mono_or_Neu__Pan.Keratin
Macrophages__Keratin_Tumour__HLA_Class_1 Macrophages__Keratin_Tumour__HLA_Class_1
Keratin_Tumour__CD8_T_cell__Keratin6 Keratin_Tumour__CD8_T_cell__Keratin6
Macrophages__Other_Immune__HLA_Class_1 Macrophages__Other_Immune__HLA_Class_1
Keratin_Tumour__Mesenchymal__dsDNA Keratin_Tumour__Mesenchymal__dsDNA
Keratin_Tumour__Unidentified__H3K27me3 Keratin_Tumour__Unidentified__H3K27me3
Keratin_Tumour__Mono_or_Neu__Pan.Keratin
is the most significant pairwise relationship which contributes to patient survival. That is, the relationship between pan-keratin expression in keratin/tumour cells and their spatial proximity to monocytes/neutrophils. The negative coefficient associated with this relationship tells us that higher pan-keratin expression in keratin/tumour cells nearby monocyte/neutrophil cell populations leads to better survival outcomes for patients.
# Selecting the most significant relationship
survRelationship <- stateMat[["Keratin_Tumour__Mono_or_Neu__Pan.Keratin"]]
survRelationship <- ifelse(survRelationship > median(survRelationship), "Higher expression in close cells", "Lower expression in close cells")
# Plotting Kaplan-Meier curve
survfit2(kerenSurv ~ survRelationship) |>
ggsurvfit() +
add_pvalue() +
ggtitle("Keratin_Tumour__Mono_or_Neu__Pan.Keratin")
We conclude the section on spatial quantification metrics here. So far, we have identified 7 metrics to quantify spatial relationships -
- Cell type proportions (FuseSOM)
- Co-localisation between pairs of cell types using the L-function (spicyR)
- Cell type co-localisation with respect to a parent population using
Kontextual
(Statial) - Regions of co-localisation, or spatial domains (lisaClust)
- Marker means in each cell type (Statial)
- Marker means in each cell type in each region (Statial)
- Proximity-associated changes in marker expression using SpatioMark (Statial)
10.3 sessionInfo
R version 4.5.0 (2025-04-11)
Platform: aarch64-apple-darwin20
Running under: macOS Sonoma 14.4.1
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.1
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
time zone: Australia/Sydney
tzcode source: internal
attached base packages:
[1] stats4 stats graphics grDevices utils datasets methods
[8] base
other attached packages:
[1] SpatialDatasets_1.6.3 SpatialExperiment_1.18.1
[3] ExperimentHub_2.16.0 AnnotationHub_3.16.0
[5] BiocFileCache_2.16.0 dbplyr_2.5.0
[7] treekoR_1.16.0 tibble_3.2.1
[9] ggsurvfit_1.1.0 ggplot2_3.5.2
[11] SingleCellExperiment_1.30.1 dplyr_1.1.4
[13] lisaClust_1.16.0 ClassifyR_3.12.0
[15] survival_3.8-3 BiocParallel_1.42.0
[17] MultiAssayExperiment_1.34.0 SummarizedExperiment_1.38.1
[19] Biobase_2.68.0 GenomicRanges_1.60.0
[21] GenomeInfoDb_1.44.0 IRanges_2.42.0
[23] MatrixGenerics_1.20.0 matrixStats_1.5.0
[25] S4Vectors_0.46.0 BiocGenerics_0.54.0
[27] generics_0.1.4 spicyR_1.20.1
[29] Statial_1.10.0
loaded via a namespace (and not attached):
[1] fs_1.6.6 spatstat.sparse_3.1-0
[3] httr_1.4.7 hopach_2.68.0
[5] RColorBrewer_1.1-3 doParallel_1.0.17
[7] numDeriv_2016.8-1.1 tools_4.5.0
[9] doRNG_1.8.6.2 backports_1.5.0
[11] R6_2.6.1 lazyeval_0.2.2
[13] mgcv_1.9-3 GetoptLong_1.0.5
[15] withr_3.0.2 coxme_2.2-22
[17] cli_3.6.5 spatstat.explore_3.4-3
[19] sandwich_3.1-1 labeling_0.4.3
[21] mvtnorm_1.3-3 spatstat.data_3.1-6
[23] systemfonts_1.2.3 yulab.utils_0.2.0
[25] ggupset_0.4.1 colorRamps_2.3.4
[27] dichromat_2.0-0.1 limma_3.64.1
[29] flowCore_2.20.0 rstudioapi_0.17.1
[31] RSQLite_2.3.11 gridGraphics_0.5-1
[33] shape_1.4.6.1 spatstat.random_3.4-1
[35] car_3.1-3 scam_1.2-19
[37] Matrix_1.7-3 RProtoBufLib_2.20.0
[39] abind_1.4-8 lifecycle_1.0.4
[41] yaml_2.3.10 multcomp_1.4-28
[43] edgeR_4.6.2 carData_3.0-5
[45] SparseArray_1.8.0 Rtsne_0.17
[47] grid_4.5.0 blob_1.2.4
[49] crayon_1.5.3 bdsmatrix_1.3-7
[51] lattice_0.22-6 KEGGREST_1.48.0
[53] magick_2.8.5 pillar_1.10.2
[55] knitr_1.50 ComplexHeatmap_2.24.0
[57] dcanr_1.24.0 rjson_0.2.23
[59] boot_1.3-31 codetools_0.2-20
[61] glue_1.8.0 ggiraph_0.8.13
[63] ggfun_0.1.8 spatstat.univar_3.1-3
[65] data.table_1.17.4 vctrs_0.6.5
[67] png_0.1-8 treeio_1.32.0
[69] Rdpack_2.6.4 gtable_0.3.6
[71] cachem_1.1.0 xfun_0.52
[73] mime_0.13 rbibutils_2.3
[75] S4Arrays_1.8.0 ConsensusClusterPlus_1.72.0
[77] reformulas_0.4.1 pheatmap_1.0.12
[79] iterators_1.0.14 cytolib_2.20.0
[81] statmod_1.5.0 TH.data_1.1-3
[83] nlme_3.1-168 ggtree_3.16.0
[85] bit64_4.6.0-1 filelock_1.0.3
[87] colorspace_2.1-1 DBI_1.2.3
[89] tidyselect_1.2.1 curl_6.2.3
[91] bit_4.6.0 compiler_4.5.0
[93] diffcyt_1.28.0 DelayedArray_0.34.1
[95] plotly_4.10.4 scales_1.4.0
[97] rappdirs_0.3.3 stringr_1.5.1
[99] digest_0.6.37 goftest_1.2-3
[101] spatstat.utils_3.1-4 minqa_1.2.8
[103] rmarkdown_2.29 XVector_0.48.0
[105] htmltools_0.5.8.1 pkgconfig_2.0.3
[107] lme4_1.1-37 fastmap_1.2.0
[109] rlang_1.1.6 GlobalOptions_0.1.2
[111] htmlwidgets_1.6.4 ggthemes_5.1.0
[113] UCSC.utils_1.4.0 ggh4x_0.3.0
[115] farver_2.1.2 zoo_1.8-14
[117] jsonlite_2.0.0 magrittr_2.0.3
[119] Formula_1.2-5 GenomeInfoDbData_1.2.14
[121] ggplotify_0.1.2 patchwork_1.3.0
[123] Rcpp_1.0.14 ape_5.8-1
[125] ggnewscale_0.5.1 stringi_1.8.7
[127] MASS_7.3-65 plyr_1.8.9
[129] parallel_4.5.0 deldir_2.0-4
[131] Biostrings_2.76.0 splines_4.5.0
[133] tensor_1.5 circlize_0.4.16
[135] locfit_1.5-9.12 igraph_2.1.4
[137] ggpubr_0.6.0 uuid_1.2-1
[139] ranger_0.17.0 spatstat.geom_3.4-1
[141] ggsignif_0.6.4 rngtools_1.5.2
[143] reshape2_1.4.4 BiocVersion_3.21.1
[145] XML_3.99-0.18 evaluate_1.0.3
[147] BiocManager_1.30.25 nloptr_2.2.1
[149] foreach_1.5.2 tweenr_2.0.3
[151] tidyr_1.3.1 purrr_1.0.4
[153] polyclip_1.10-7 clue_0.3-66
[155] BiocBaseUtils_1.10.0 ggforce_0.4.2
[157] broom_1.0.8 tidytree_0.4.6
[159] rstatix_0.7.2 viridisLite_0.4.2
[161] class_7.3-23 lmerTest_3.1-3
[163] aplot_0.2.5 AnnotationDbi_1.70.0
[165] memoise_2.0.1 FlowSOM_2.16.0
[167] cluster_2.1.8.1 concaveman_1.1.0