Skip to content

Instantly share code, notes, and snippets.

View chunyangbao's full-sized avatar

Chunyang Bao chunyangbao

View GitHub Profile
@chunyangbao
chunyangbao / basicOncoPrint.R
Created March 26, 2018 00:38 — forked from armish/basicOncoPrint.R
A simple R script to visualize OncoPrints out of an alteration matrix
# This function sorts the matrix for better visualization of mutual exclusivity across genes
memoSort <- function(M) {
geneOrder <- sort(rowSums(M), decreasing=TRUE, index.return=TRUE)$ix;
scoreCol <- function(x) {
score <- 0;
for(i in 1:length(x)) {
if(x[i]) {
score <- score + 2^(length(x)-i);
}
}