Converts a cell by cell type likelihood matrix to a probability matrix by setting negative values to zero and normalizing each row to sum to 1.

Score2Prob(PhiSc)

Arguments

PhiSc

A numeric matrix containing values ranging from -1 to 1. Rows typically represent cells and columns represent cell types.

Value

A numeric matrix of the same dimensions as the input, where:

  • All negative values are set to zero

  • Each row sums to 1 (forms a probability distribution)

  • Row and column names are preserved from the input

Details

The function performs the following steps:

  1. Sets all negative similarity values to zero

  2. Calculates the sum of each row

  3. Divides each element in a row by the row sum to create probabilities

  4. Handles edge cases where rows sum to zero after removing negatives

For rows that contain all negative values (resulting in zero sums after transformation), the function will issue a warning and set those rows to all zeros. Alternative behavior could be implemented to assign uniform probabilities.