Genes are ordered by descending alteration frequency, then samples are ordered so that the most frequently altered gene's carriers come first, ties broken by the next gene down. This is the "memo sort" cBioPortal popularised; it is what makes mutual exclusivity between drivers visible as a staircase.
Details
Exposed separately so a caller can compute the order once and reuse it for
both an interactive oncoplot() and a static rendering, so two
implementations cannot tie-break differently. Remaining ties go by name in
code point order, whatever the locale, which is the order Python's
memo_sort() uses.
Examples
alt <- data.frame(
gene = c("TP53", "TP53", "KRAS", "KRAS", "EGFR"),
sample = c("S1", "S2", "S2", "S3", "S1"),
class = "missense"
)
oncoplot_memo_sort(alt)
#> $genes
#> [1] "KRAS" "TP53" "EGFR"
#>
#> $samples
#> [1] "S2" "S3" "S1"
#>