Skip to content

Commit

Permalink
add legend_height argument #346
Browse files Browse the repository at this point in the history
  • Loading branch information
PoisonAlien committed Feb 2, 2020
1 parent 66b2a66 commit 28be08b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 34 deletions.
65 changes: 33 additions & 32 deletions R/oncomatrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -346,74 +346,75 @@ bubble_plot = function(plot_dat, lab_dat = NULL, x_var = NULL, y_var = NULL,

#Get plot layout for oncoplot
plot_layout = function(clinicalFeatures = NULL, drawRowBar = TRUE,
drawColBar = TRUE, draw_titv = FALSE, exprsTbl = NULL){
drawColBar = TRUE, draw_titv = FALSE, exprsTbl = NULL, legend_height = 4){

if(is.null(clinicalFeatures)){
if(draw_titv){
if(!drawRowBar & !drawColBar){
if(is.null(exprsTbl)){
mat_lo = matrix(data = c(1,2,3), nrow = 3, ncol = 1, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, heights = c(12, 4, 4))
lo = graphics::layout(mat = mat_lo, heights = c(12, 4, legend_height))
}else{
mat_lo = matrix(data = c(1,2,3,4,5,5), nrow = 3, ncol = 2, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, heights = c(12, 4, 4), widths = c(1, 4))
lo = graphics::layout(mat = mat_lo, heights = c(12, 4, legend_height), widths = c(1, 4))
}
}else if(!drawRowBar){
if(is.null(exprsTbl)){
mat_lo = matrix(data = c(1,2,3, 4), nrow = 4, ncol = 1, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, heights = c(4, 12, 4, 4))
lo = graphics::layout(mat = mat_lo, heights = c(4, 12, 4, legend_height))
}else{
mat_lo = matrix(data = c(1,2,3,4,5,6,7,7), nrow = 4, ncol = 2, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, heights = c(4, 12, 4, 4), widths = c(1, 4))
lo = graphics::layout(mat = mat_lo, heights = c(4, 12, 4, legend_height), widths = c(1, 4))
}
}else if(!drawColBar){
if(is.null(exprsTbl)){
mat_lo = matrix(data = c(1,2,3,4,5,5), nrow = 3, ncol = 2, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, heights = c(12, 4, 4), widths = c(4, 1))
}else{
mat_lo = matrix(data = c(1,2,3,4,5,6,7,7,7), nrow = 3, ncol = 3, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, heights = c(12, 4, 4), widths = c(1, 4, 1))
lo = graphics::layout(mat = mat_lo, heights = c(12, 4, legend_height), widths = c(1, 4, 1))
}
}else{
if(is.null(exprsTbl)){
mat_lo = matrix(data = c(1,2,3,4,5,6,7,7), nrow = 4, ncol = 2, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, widths = c(4, 1), heights = c(4, 12, 4, 4))
lo = graphics::layout(mat = mat_lo, widths = c(4, 1), heights = c(4, 12, 4, legend_height))
}else{
mat_lo = matrix(data = c(1,2,3,4,5,6,7,8,9,10,10,10), nrow = 4, ncol = 3, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, widths = c(1,4, 1), heights = c(4, 12, 4, 4))
lo = graphics::layout(mat = mat_lo, widths = c(1,4, 1), heights = c(4, 12, 4, legend_height))
}
}
}else{
if(!drawRowBar & !drawColBar){
if(is.null(exprsTbl)){
mat_lo = matrix(data = c(1,2), nrow = 2, ncol = 1, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, heights = c(12, 4))
lo = graphics::layout(mat = mat_lo, heights = c(12, legend_height))
}else{
mat_lo = matrix(data = c(1,2,3,3), nrow = 2, ncol = 2, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, heights = c(12, 4), widths = c(1, 4))
lo = graphics::layout(mat = mat_lo, heights = c(12, legend_height), widths = c(1, 4))
}
}else if(!drawRowBar){
if(is.null(exprsTbl)){
mat_lo = matrix(data = c(1,2,3), nrow = 3, ncol = 1, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, heights = c(4, 12, 4))
lo = graphics::layout(mat = mat_lo, heights = c(4, 12, legend_height))
}else{
mat_lo = matrix(data = c(1,2,3,4,5,5), nrow = 3, ncol = 2, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, heights = c(4, 12, 4), widths = c(1, 4))
lo = graphics::layout(mat = mat_lo, heights = c(4, 12, legend_height), widths = c(1, 4))
}
}else if(!drawColBar){
if(is.null(exprsTbl)){
mat_lo = matrix(data = c(1,2,3,3), nrow = 2, ncol = 2, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, heights = c(12, 4), widths = c(4, 1))
lo = graphics::layout(mat = mat_lo, heights = c(12, legend_height), widths = c(4, 1))
}else{
mat_lo = matrix(data = c(1,2,3,4,4,4), nrow = 2, ncol = 3, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, heights = c(12, 4), widths = c(1, 4, 1))
lo = graphics::layout(mat = mat_lo, heights = c(12, legend_height), widths = c(1, 4, 1))
}
}else{
if(is.null(exprsTbl)){
mat_lo = matrix(data = c(1,2,3,4,5,5), nrow = 3, ncol = 2, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, widths = c(4, 1), heights = c(4, 12, 4))
lo = graphics::layout(mat = mat_lo, widths = c(4, 1), heights = c(4, 12, legend_height))
}else{
mat_lo = matrix(data = c(1,2,3,4,5,6,7,7,7), nrow = 3, ncol = 3, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, widths = c(1, 4, 1), heights = c(4, 12, 4))
lo = graphics::layout(mat = mat_lo, widths = c(1, 4, 1), heights = c(4, 12, legend_height))
}
}
}
Expand All @@ -422,68 +423,68 @@ plot_layout = function(clinicalFeatures = NULL, drawRowBar = TRUE,
if(!drawRowBar & !drawColBar){
if(is.null(exprsTbl)){
mat_lo = matrix(data = c(1,2,3,4), nrow = 4, ncol = 1, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, heights = c(12, 1, 4, 4))
lo = graphics::layout(mat = mat_lo, heights = c(12, 1, 4, legend_height))
}else{
mat_lo = matrix(data = c(1,2,3,4,5,6,7,7), nrow = 4, ncol = 2, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, heights = c(12, 1, 4, 4), widths = c(1, 4))
lo = graphics::layout(mat = mat_lo, heights = c(12, 1, 4, legend_height), widths = c(1, 4))
}
}else if(!drawRowBar){
if(is.null(exprsTbl)){
mat_lo = matrix(data = c(1,2,3,4,5), nrow = 5, ncol = 1, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, heights = c(4, 12, 1, 4, 4))
lo = graphics::layout(mat = mat_lo, heights = c(4, 12, 1, 4, legend_height))
}else{
mat_lo = matrix(data = c(1,2,3,4,5,6,7,8,9,9), nrow = 5, ncol = 2, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, heights = c(4, 12, 1, 4, 4), widths = c(1, 4))
lo = graphics::layout(mat = mat_lo, heights = c(4, 12, 1, 4, legend_height), widths = c(1, 4))
}
}else if(!drawColBar){
if(is.null(exprsTbl)){
mat_lo = matrix(data = c(1,2,3,4,5,6,7,7), nrow = 4, ncol = 2, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, heights = c(12, 1, 4, 4), widths = c(4, 1))
lo = graphics::layout(mat = mat_lo, heights = c(12, 1, 4, legend_height), widths = c(4, 1))
}else{
mat_lo = matrix(data = c(1,2,3,4,5,6,7,8,9,10,10,10), nrow = 4, ncol = 3, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, heights = c(12, 1, 4, 4), widths = c(1, 4, 1))
lo = graphics::layout(mat = mat_lo, heights = c(12, 1, 4, legend_height), widths = c(1, 4, 1))
}
}else{
if(is.null(exprsTbl)){
mat_lo = matrix(data = c(1,2,3,4,5,6,7,8,9,9), nrow = 5, ncol = 2, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, widths = c(4, 1), heights = c(4, 12, 1, 4, 4))
lo = graphics::layout(mat = mat_lo, widths = c(4, 1), heights = c(4, 12, 1, 4, legend_height))
}else{
mat_lo = matrix(data = c(1,2,3,4,5,6,7,8,9,10,11,12,13,13,13), nrow = 5, ncol = 3, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, widths = c(1, 4, 1), heights = c(4, 12, 1, 4, 4))
lo = graphics::layout(mat = mat_lo, widths = c(1, 4, 1), heights = c(4, 12, 1, 4, legend_height))
}
}
}else{
if(!drawRowBar & !drawColBar){
if(is.null(exprsTbl)){
mat_lo = matrix(data = c(1,2,3), nrow = 3, ncol = 1, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, heights = c(12, 1, 4))
lo = graphics::layout(mat = mat_lo, heights = c(12, 1, legend_height))
}else{
mat_lo = matrix(data = c(1,2,3,4,5,5), nrow = 3, ncol = 2, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, heights = c(12, 1, 4), widths = c(1, 4))
lo = graphics::layout(mat = mat_lo, heights = c(12, 1, legend_height), widths = c(1, 4))
}
}else if(!drawRowBar){
if(is.null(exprsTbl)){
mat_lo = matrix(data = c(1,2,3,4), nrow = 4, ncol = 1, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, heights = c(4, 12, 1, 4))
lo = graphics::layout(mat = mat_lo, heights = c(4, 12, 1, legend_height))
}else{
mat_lo = matrix(data = c(1,2,3,4,5,6,7,7), nrow = 4, ncol = 2, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, heights = c(4, 12, 1, 4), widths = c(1, 4))
lo = graphics::layout(mat = mat_lo, heights = c(4, 12, 1, legend_height), widths = c(1, 4))
}
}else if(!drawColBar){
if(is.null(exprsTbl)){
mat_lo = matrix(data = c(1,2,3,4,5,5), nrow = 3, ncol = 2, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, heights = c(12, 1, 4), widths = c(4, 1))
lo = graphics::layout(mat = mat_lo, heights = c(12, 1, legend_height), widths = c(4, 1))
}else{
mat_lo = matrix(data = c(1,2,3,4,5,6,7,7,7), nrow = 3, ncol = 3, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, heights = c(12, 1, 4), widths = c(1, 4, 1))
lo = graphics::layout(mat = mat_lo, heights = c(12, 1, legend_height), widths = c(1, 4, 1))
}
}else{
if(is.null(exprsTbl)){
mat_lo = matrix(data = c(1,2,3,4,5,6,7,7), nrow = 4, ncol = 2, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, widths = c(4, 1), heights = c(4, 12, 1, 4))
lo = graphics::layout(mat = mat_lo, widths = c(4, 1), heights = c(4, 12, 1, legend_height))
}else{
mat_lo = matrix(data = c(1,2,3,4,5,6,7,8,9,10,10,10), nrow = 4, ncol = 3, byrow = TRUE)
lo = graphics::layout(mat = mat_lo, widths = c(1, 4, 1), heights = c(4, 12, 1, 4))
lo = graphics::layout(mat = mat_lo, widths = c(1, 4, 1), heights = c(4, 12, 1, legend_height))
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions R/oncoplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#' @param showTumorSampleBarcodes logical to include sample names.
#' @param barcode_mar Default 4
#' @param gene_mar Default 5
#' @param legend_height Height of plotting area for legend. Default 4
#' @param clinicalFeatures columns names from `clinical.data` slot of \code{MAF} to be drawn in the plot. Dafault NULL.
#' @param additionalFeature a vector of length two indicating column name in the MAF and the factor level to be highlighted.
#' @param additionalFeaturePch Default 20
Expand Down Expand Up @@ -75,7 +76,7 @@
#' @export
oncoplot = function(maf, top = 20, genes = NULL, altered = FALSE, mutsig = NULL, mutsigQval = 0.1, drawRowBar = TRUE, drawColBar = TRUE, includeColBarCN = TRUE, draw_titv = FALSE, logColBar = FALSE,
clinicalFeatures = NULL, exprsTbl = NULL, additionalFeature = NULL, additionalFeaturePch = 20, additionalFeatureCol = "white", additionalFeatureCex = 0.9, annotationDat = NULL, annotationColor = NULL, genesToIgnore = NULL,
showTumorSampleBarcodes = FALSE, barcode_mar = 4, gene_mar = 5, removeNonMutated = TRUE, fill = TRUE, cohortSize = NULL, colors = NULL,
showTumorSampleBarcodes = FALSE, barcode_mar = 4, gene_mar = 5, legend_height = 4, removeNonMutated = TRUE, fill = TRUE, cohortSize = NULL, colors = NULL,
sortByMutation = FALSE, sortByAnnotation = FALSE, numericAnnoCol = NULL, groupAnnotationBySize = TRUE, annotationOrder = NULL, keepGeneOrder = FALSE,
GeneOrderSort = TRUE, sampleOrder = NULL, writeMatrix = FALSE, sepwd_genes = 0.5, sepwd_samples = 0.25, fontSize = 0.8, SampleNamefontSize = 1,
showTitle = TRUE, titleText = NULL, titleFontSize = 1.5, legendFontSize = 1.2, annotationFontSize = 1.2, bgCol = "#CCCCCC", borderCol = 'white', colbar_pathway = FALSE){
Expand Down Expand Up @@ -247,7 +248,7 @@ oncoplot = function(maf, top = 20, genes = NULL, altered = FALSE, mutsig = NULL,

#Plot layout
plot_layout(clinicalFeatures = clinicalFeatures, drawRowBar = drawRowBar,
drawColBar = drawColBar, draw_titv = draw_titv, exprsTbl = exprsTbl)
drawColBar = drawColBar, draw_titv = draw_titv, exprsTbl = exprsTbl, legend_height = legend_height)

#01: Draw scale axis for expression table
if(!is.null(exprsTbl)){
Expand Down
1 change: 1 addition & 0 deletions inst/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ENHANCEMENTS
o Pairwise t-test and muttaional load in `tcgaCompare` Issue: #453
o Added `titleText` argument to `oncoplot` Issue: #448
o Highlight mutated genes on gisticChromplot Issue: #443
o Added `legend_height` argument to `oncoplot` Issue: #346

CHANGES IN VERSION 2.2.10
-------------------------
Expand Down
3 changes: 3 additions & 0 deletions man/oncoplot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 28be08b

Please sign in to comment.