Models local microenvironment cues that influence antibody behavior based on the density and structure of nearby data points.
Details
In real immunity, B cell fate is strongly influenced by local signals: chemokines, cytokines, and interactions with stromal cells in specific tissue microenvironments. This module translates that concept into density-dependent adaptation:
High density zones: Promote memory formation (stabilize antibodies, reduce mutation rate)
Low density zones: Promote exploration (increase mutation rate for broader search)
Boundary zones: Trigger class switching (change matching breadth between IgM-like broad and IgG-like specific modes)
Chemokine-like gradients: Bias mutation direction toward higher-density regions
Public fields
density_bandwidthBandwidth for kernel density estimation.
high_density_thresholdDensity percentile above which antibodies stabilize.
low_density_thresholdDensity percentile below which antibodies explore.
stabilization_factorMutation rate multiplier for high-density zones.
exploration_factorMutation rate multiplier for low-density zones.
last_densitiesPer-antibody local density from last assessment.
last_zonesPer-antibody zone classification from last assessment.
Methods
Method new()
Create a new Microenvironment module.
Usage
Microenvironment$new(
density_bandwidth = NULL,
high_density_threshold = 0.75,
low_density_threshold = 0.25,
stabilization_factor = 0.3,
exploration_factor = 2
)Arguments
density_bandwidthNumeric. KDE bandwidth (NULL for auto).
high_density_thresholdNumeric [0,1]. Percentile threshold for stabilization.
low_density_thresholdNumeric [0,1]. Percentile threshold for exploration.
stabilization_factorNumeric. Mutation rate multiplier for stable zones.
exploration_factorNumeric. Mutation rate multiplier for exploration zones.
Method assess()
Assess the microenvironment around each antibody.
Usage
Microenvironment$assess(
repertoire,
X,
affinityFunc = "gaussian",
affinityParams = list(alpha = 1, c = 1, p = 2)
)Arguments
repertoireAn
ImmuneRepertoireobject.XNumeric matrix of training data (n x d).
affinityFuncCharacter. Affinity function.
affinityParamsList. Affinity parameters.
Examples
# Assess microenvironment around antibodies
data(iris)
X <- as.matrix(iris[, 1:4])
me <- Microenvironment$new()
rep <- ImmuneRepertoire$new(X[sample(150, 15), ])
env <- me$assess(rep, X)
table(env$zones) # stable, explore, boundary
#>
#> boundary explore stable
#> 7 4 4
env$mutation_modifiers # per-antibody rate scaling
#> [1] 1.0 2.0 0.3 1.0 1.0 1.0 0.3 1.0 2.0 0.3 1.0 0.3 1.0 2.0 2.0
