R6 class representing a collection of antibodies (immune cells) with associated metadata. Core data structure for bHIVE algorithms.
Details
An ImmuneRepertoire holds a matrix of antibody vectors (each row is one antibody in feature space) plus per-antibody metadata (isotype, state, age, lineage). All heavy computation is dispatched to C++ via RcppArmadillo.
Public fields
cellsNumeric matrix (nAntibodies x nFeatures).
metadataData frame with per-antibody attributes.
Methods
Method affinity_matrix()
Compute affinity matrix between data X and antibodies.
Usage
ImmuneRepertoire$affinity_matrix(
X,
method = "gaussian",
params = list(alpha = 1, c = 1, p = 2)
)Method distance_matrix()
Compute distance matrix between data X and antibodies.
Usage
ImmuneRepertoire$distance_matrix(
X,
method = "euclidean",
params = list(p = 2, Sigma = NULL)
)Method suppress()
Network suppression: remove redundant antibodies.
Usage
ImmuneRepertoire$suppress(
epsilon,
method = "euclidean",
params = list(p = 2, Sigma = NULL)
)Method subset()
Subset the repertoire.
Method add()
Add antibodies to the repertoire.
Examples
# Create a repertoire from random antibodies
A <- matrix(rnorm(50), nrow = 10, ncol = 5)
rep <- ImmuneRepertoire$new(A)
print(rep)
#> <ImmuneRepertoire> 10 antibodies x 5 features
#> Isotypes: 10
#> States: 10
# Compute affinity to data
X <- matrix(rnorm(100), nrow = 20, ncol = 5)
aff <- rep$affinity_matrix(X, "gaussian", list(alpha = 1))
dim(aff) # 20 x 10
#> [1] 20 10
# Network suppression
rep$suppress(epsilon = 1.5, method = "euclidean")
rep$size() # fewer antibodies after suppression
#> [1] 8
