Apply mathematical transformations to matrix elements.
Input:
- PHYLIP distance matrix or pairwise TSV file.
- Use
--input-format pairto read pairwise TSV input; useful for processing data from STDIN.
Notes:
- Available operations (
--op):linear:val = val * scale + offset.inv-linear: off-diagonalval = max - val; diagonal is set to0.log:val = -ln(val)(off-diagonal<= 0becomesInf; diagonal<= 0becomes0).exp:val = exp(-val)(input diagonals of0produce output diagonals of1.0).square:val = val * val.sqrt:val = sqrt(val)(negative values produceNaN).
- Useful for converting similarity matrices to distance matrices.
- Use
--normalizeto normalize based on diagonal elements before transformation:x_norm(i, j) = x(i, j) / sqrt(x(i, i) * x(j, j)).--normalizerequires diagonal data in the input; if absent, every diagonal is treated as0.0, so off-diagonal values become0.0before the selected--opis applied.- Diagonal values less than or equal to
1e-9are treated as zero, producing0.0for the corresponding row/column. - Normalization is applied before the transformation op: off-diagonal
x(i,j) / sqrt(d_i*d_j)then--op, diagonal normalized to1.0(or0.0ifd_i <= 1e-9) then--op.
- When
--input-format pairis used,--sameand--missingcontrol default diagonal and missing-pair values. - Default parameter values:
--max-val 1.0,--scale 1.0,--offset 0.0.
Examples:
-
Convert Identity (0-100) to Distance (0-1)
necom mat transform input.phy --op linear --scale -0.01 --offset 1.0 -o dist.phy -
Convert Identity (0-100) to Distance (0-100)
necom mat transform input.phy --op inv-linear --max-val 100 -o dist.phy -
Convert Similarity (0-1) to Distance (0-1)
necom mat transform input.phy --op inv-linear --max-val 1.0 -o dist.phy -
Probability to distance with log
necom mat transform input.phy --op log -o dist.phy -
Normalize raw scores then convert to distance
necom mat transform raw_scores.phy --normalize --op inv-linear --max-val 1.0 -o dist.phy