Skip to content

Commit f7aaf1d

Browse files
committed
added modifications for iqwidth and correlation plots
1 parent fa1432a commit f7aaf1d

File tree

2 files changed

+32
-24
lines changed

2 files changed

+32
-24
lines changed

R/CorrelationMethods.R

+15-13
Original file line numberDiff line numberDiff line change
@@ -486,10 +486,10 @@ pairs.DataFrame <- function (x, labels, panel = points, ..., horInd = 1:nc, verI
486486
, tagCountThreshold, applyThresholdBoth
487487
, digits) {
488488
# Select samples
489-
if (all(samples %in% colnames(expr.table))) {
490-
expr.table <- expr.table[,samples]
491-
} else if(samples == "all"){
489+
if(samples == "all"){
492490
samples <- colnames(expr.table)
491+
} else if (all(samples %in% colnames(expr.table))) {
492+
expr.table <- expr.table[,samples]
493493
} else stop("'samples' parameter must be either \"all\" or a character vector of valid sample labels!")
494494
nr.samples <- length(samples)
495495

@@ -540,16 +540,18 @@ pairs.DataFrame <- function (x, labels, panel = points, ..., horInd = 1:nc, verI
540540
points(df, ...)
541541
}
542542

543-
pairs( expr.table
544-
, lower.panel = pointsUnique
545-
, upper.panel = panel.cor
546-
, pch = "."
547-
, cex = 4
548-
, log = "xy"
549-
, las = 1
550-
, xaxp = c(1,10,1)
551-
, yaxp = c(1,10,1)
552-
, labels = samples)
543+
if (TOPLOT){
544+
pairs( expr.table
545+
, lower.panel = pointsUnique
546+
, upper.panel = panel.cor
547+
, pch = "."
548+
, cex = 4
549+
, log = "xy"
550+
, las = 1
551+
, xaxp = c(1,10,1)
552+
, yaxp = c(1,10,1)
553+
, labels = samples)
554+
}
553555

554556
# Return a correlation matrix
555557
corr.m <- matrix(1, nr.samples, nr.samples)

R/ExportMethods.R

+17-11
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ setGeneric( "plotReverseCumulatives",
101101
group <- "group"
102102
}
103103

104+
# no need for colors if a multi-facet plot and many colors
104105
if (is.null(object@metadata$colData$Colors)) {
105106
object@metadata$colData$Colors <- scales::hue_pal()(length(object))
106107
}
@@ -230,8 +231,8 @@ setMethod("plotReverseCumulatives", "GRanges",
230231
#' @family CAGEr plot functions
231232
#' @family CAGEr clusters functions
232233
#'
233-
#' @importFrom ggplot2 ggplot scale_fill_manual geom_histogram facet_wrap
234-
#' @importFrom ggplot2 ggtitle xlab ylab labs
234+
#' @importFrom ggplot2 ggplot aes_string scale_fill_manual geom_histogram facet_wrap
235+
#' @importFrom ggplot2 ggtitle xlab ylab
235236
#'
236237
#' @examples
237238
#'
@@ -278,17 +279,22 @@ setMethod( "plotInterquantileWidth", "CAGEexp"
278279

279280
binsize <- round(max(iqwidths$iq_width)/2)
280281

281-
ggplot2::ggplot(iqwidths) +
282-
ggplot2::aes_string(x = "iq_width", fill = "sampleName") +
283-
ggplot2::scale_fill_manual(values = names(sampleLabels(object))) +
284-
ggplot2::geom_histogram(bins = binsize) +
285-
ggplot2::facet_wrap("~sampleName") +
286-
ggplot2::ggtitle(paste0(
282+
iqwidth_plot <- ggplot(iqwidths) +
283+
aes_string(x = "iq_width") +
284+
scale_fill_manual(values = names(sampleLabels(object))) +
285+
geom_histogram(bins = binsize) +
286+
facet_wrap("~sampleName") +
287+
ggtitle(paste0(
287288
switch(clusters, tagClusters = "Tag Clusters", consensusClusters = "Consenss Clusters"),
288289
" interquantile width (quantile ", qLow, " to ", qUp, ")")) +
289-
ggplot2::xlab("Interquantile width (bp)") +
290-
ggplot2::ylab("Frequency") +
291-
ggplot2::labs(fill = "Sample name")
290+
xlab("Interquantile width (bp)") +
291+
ylab("Frequency")
292+
293+
if (TOPLOT){
294+
print(iqwidth_plot)
295+
}
296+
297+
return(iqwidth_plot)
292298
})
293299

294300
#' @name plotExpressionProfiles

0 commit comments

Comments
 (0)