Assigns phenotype labels to cells based on marker intensity thresholds. A cell is considered positive for a marker if its intensity exceeds the given threshold.
Arguments
- dt
A
data.tableas returned byread_spatial()ornormalise_markers().- thresholds
A named list where names are marker column names and values are numeric thresholds. Example:
list(CD3 = 0.5, CD8 = 0.3).- labels
A named character vector mapping phenotype signatures to labels, or
NULLfor automatic labelling. WhenNULL, phenotypes are labelled by concatenating positive marker names with"+".
Examples
dt <- data.table::data.table(
sample_id = "s1", cell_id = 1:6,
x = runif(6), y = runif(6),
CD3 = c(0.8, 0.1, 0.9, 0.2, 0.7, 0.05),
CD8 = c(0.1, 0.6, 0.7, 0.05, 0.8, 0.02)
)
result <- phenotype_cells(dt, thresholds = list(CD3 = 0.5, CD8 = 0.5))
table(result$phenotype)
#>
#> CD3+ CD3+/CD8+ CD8+ Negative
#> 1 2 1 2