R/barplots.R

Defines functions barplotMutations reorderMutations

Documented in barplotMutations

reorderMutations<-function( mutations ){
  ronames<- rownames(mutations)
  tmp <- unlist( strsplit( ronames, "") ) 
  n<-length(tmp)
  tmp<-paste( paste( tmp[ seq(3,n,7) ],tmp[ seq(5,n,7) ] ,sep=""),
              paste(  tmp[ seq(1,n,7) ],tmp[ seq(7,n,7) ], sep="."),
              sep=" ")
  o<- order( tmp )
  return( mutations[o,, drop=F] )
}

barplotMutations<-function(mutations, 
                           sigcol=c( rep("lightblue",16), rep("black", 16) , 
                                     rep("red", 16), rep( "gray",16), 
                                     rep("green", 16), rep("pink",16 )), ... ){
  if( is.null( dim(mutations) ) ){ stop("mutations must be a data.frame\n") }
  if( ncol( mutations )>1 ){ stop("only one column allowed in mutations\n") }
  
  # mutations is a data frame with rownames like A[C>G]T
  mutations <- reorderMutations( mutations )
  barplot( mutations[,1], col=sigcol, las=2 , border=NA , cex.names=.75 , 
           names.arg=rownames( mutations ) ,...  )
  
}
mathieu-lemire/cosmicSignnls documentation built on June 7, 2017, 3:40 a.m.