Gives each row of a score matrix the name of the column with the highest score, or the names of the labPerSample highest-scoring columns. This function was called getClass() before PhiSpace 0.99.0; it was renamed because that name masked methods::getClass().

getLabels(X, labPerSample = NULL)

Arguments

X

Matrix of scores, one row per sample (for example per cell) and one named column per label.

labPerSample

Positive integer: the number of labels per row. The default NULL gives one label.

Value

With one label per row, a character vector of column names, one per row of X. With more, a character matrix with one row per row of X, labels in decreasing order of score.

Examples

set.seed(1)
scores <- matrix(rnorm(20), 5, 4, dimnames = list(NULL, LETTERS[1:4]))
getLabels(scores)
getLabels(scores, labPerSample = 2)