topRank() can quickly identify the top `n` rows for each column of a matrix. For example, this can be useful for identifying the top `n` features per cell.
topRank(matrix, n = 25, margin = 2, threshold = 0, decreasing = TRUE)
matrix | Numeric matrix. |
---|---|
n | Integer. Maximum number of items above `threshold` returned for each ranked row or column. |
margin | Integer. Dimension of `matrix` to rank, with 1 for rows, 2 for columns. Default 2. |
threshold | Numeric. Only return ranked rows or columns in the matrix that are above this threshold. If NULL, then no threshold will be applied. Default 0. |
decreasing | Logical. Specifies if the rank should be decreasing. Default TRUE. |
List. The `index` variable provides the top `n` row (feature) indices contributing the most to each column (cell). The `names` variable provides the rownames corresponding to these indexes.
data(sampleCells) topRanksPerCell <- topRank(sampleCells, n = 5) topFeatureNamesForCell <- topRanksPerCell$names[1]