Learn R Programming

topolow (version 1.0.0)

dist_to_titer_table: Convert Distance Matrix to Titer Panel Format

Description

Converts a distance matrix to a titer panel format, handling threshold measurements and logarithmic transformations common in antigenic cartography. The function identifies reference points (typically antisera) and challenge points (typically antigens) based on row/column name prefixes.

Usage

dist_to_titer_table(input_matrix, base = exp(1), tens = 1)

Value

A matrix of titers with:

  • Rows corresponding to antigen strains (without "V/" prefix)

  • Columns corresponding to antisera (without "S/" prefix)

  • Values as character strings including threshold indicators where applicable

  • NA values replaced with "*"

Arguments

input_matrix

Matrix of distances, with row/column names prefixed with "V/" for antigens and "S/" for sera

base

Numeric. Base for logarithmic transformation. Default exp(1). For HI Assay 2

tens

Numeric. Scaling factor for final titers. Default 1. For HI Assay 10

Details

The function:

  1. Identifies antigen and serum entries from matrix row/column names

  2. Creates titer table from antigen-serum pairs

  3. Handles threshold indicators (< and >) in distance values

  4. Applies appropriate transformations to convert distances to titers

Transformation steps:

  1. Extract numeric values from thresholded measurements

  2. Convert distances to titers via logarithmic transformation

  3. Apply scaling factor

  4. Reapply threshold indicators to transformed values

Examples

Run this code
# Create sample distance matrix
dist_mat <- matrix(c(0, 2, ">3", 2, 0, 4, "3", 4, 0), nrow=3)
rownames(dist_mat) <- c("V/strain1", "V/strain2", "S/serum1")
colnames(dist_mat) <- c("V/strain1", "V/strain2", "S/serum1")

# Convert to titer panel
titer_panel <- dist_to_titer_table(dist_mat)

Run the code above in your browser using DataLab