Browse code

Merge pull request #57 from FertigLab/plot-pattern-markers-fix

plotPatternMarkers function fix

Jeanette Johnson authored on 19/10/2021 18:33:03 • GitHub committed on 19/10/2021 18:33:03
Showing 1 changed files

... ...
@@ -462,10 +462,12 @@ function(object, GStoGenes, numPerm, Pw, PwNull)
462 462
 #' @param data the original data as a matrix
463 463
 #' @param patternPalette a vector indicating what color should be used
464 464
 #' for each pattern
465
+#' @param patternMarkers pattern markers to be plotted, as generated by the 
466
+#' patternMarkers function
465 467
 #' @param sampleNames names of the samples to use for labeling 
466 468
 #' @param samplePalette  a vector indicating what color should be used
467 469
 #' for each sample
468
-#' @param colDenogram logical indicating whether to display sample denogram
470
+#' @param colDendrogram logical indicating whether to display sample dendrogram
469 471
 #' @param heatmapCol pallelet giving color scheme for heatmap
470 472
 #' @param scale character indicating if the values should be centered and scaled
471 473
 #' in either the row direction or the column direction, or none. The
... ...
@@ -476,8 +478,8 @@ function(object, GStoGenes, numPerm, Pw, PwNull)
476 478
 #' @importFrom gplots bluered
477 479
 #' @importFrom gplots heatmap.2
478 480
 #' @importFrom stats hclust as.dist cor
479
-plotPatternMarkers <- function(object, data, patternPalette, sampleNames,
480
-samplePalette=NULL, heatmapCol=bluered, colDenogram=TRUE, scale="row", ...)
481
+plotPatternMarkers <- function(object, data, patternMarkers, patternPalette, sampleNames,
482
+samplePalette=NULL, heatmapCol=bluered, colDendrogram=TRUE, scale="row", ...)
481 483
 {
482 484
     if (is.null(samplePalette))
483 485
         samplePalette <- rep("black", ncol(data))
... ...
@@ -487,10 +489,10 @@ samplePalette=NULL, heatmapCol=bluered, colDenogram=TRUE, scale="row", ...)
487 489
     names(patternCols) <- unlist(patternMarkers)
488 490
     for (i in 1:length(patternMarkers))
489 491
     {
490
-        patternCols[patternMarkers[[i]]] <- patternPalette[i]
492
+        patternCols[unlist(patternMarkers$PatternMarkers[[i]])] <- patternPalette[i]
491 493
     }
492 494
 
493
-    gplots::heatmap.2(as.matrix(data[unlist(patternMarkers),],...),
495
+    gplots::heatmap.2(as.matrix(data[unlist(patternMarkers$PatternMarkers),],),
494 496
         symkey=FALSE,
495 497
         symm=FALSE, 
496 498
         scale=scale,
... ...
@@ -498,9 +500,9 @@ samplePalette=NULL, heatmapCol=bluered, colDenogram=TRUE, scale="row", ...)
498 500
         distfun=function(x) as.dist((1-cor(t(x)))/2),
499 501
         hclustfun=function(x) stats::hclust(x,method="average"),
500 502
         Rowv=FALSE,
501
-        Colv=colDenogram,
503
+        Colv=colDendrogram,
502 504
         trace='none',
503
-        RowSideColors = as.character(patternCols[unlist(patternMarkers)]),
505
+        RowSideColors = as.character(patternCols[unlist(patternMarkers$PatternMarkers)]),
504 506
         labCol= sampleNames,
505 507
         cexCol=0.8,
506 508
         ColSideColors=as.character(samplePalette),