For a matrix expressing the cross-similarity between two (possibly different) sets of entities, this produces better results than clustering (e.g. as done by pheatmap). This is because clustering does not care about the order of each two sub-partitions. That is, clustering is as happy with ((2, 1), (4, 3)) as it is with the more sensible ((1, 2), (3, 4)). As a result, visualizations of similarities using naive clustering can be misleading.

slanted_orders(
data,
order_rows = TRUE,
order_cols = TRUE,
squared_order = TRUE,
same_order = FALSE,
discount_outliers = TRUE,
max_spin_count = 10
)

## Arguments

data A rectangular matrix containing non-negative values. Whether to reorder the rows. Whether to reorder the columns. Whether to reorder to minimize the l2 norm (otherwise minimizes the l1 norm). Whether to apply the same order to both rows and columns. Whether to do a final order phase discounting outlier values far from the diagonal. How many times to retry improving the solution before giving up.

## Value

A list with two keys, rows and cols, which contain the order.

## Examples

slanter::slanted_orders(cor(t(mtcars)))
#> $rows #> [1] 15 25 4 16 8 22 6 5 23 17 14 12 13 7 24 1 2 9 29 11 10 27 19 21 3 #> [26] 32 26 18 31 20 30 28 #> #>$cols
#>  [1] 15 25  4 16  8 22  6  5 23 17 14 12 13  7 24  1  2  9 29 11 10 27 19 21  3
#> [26] 32 26 18 31 20 30 28
#>