Skip to content

Commit

Permalink
added modifications for iqwidth and correlation plots
Browse files Browse the repository at this point in the history
  • Loading branch information
ferenckata committed Sep 17, 2024
1 parent fa1432a commit f7aaf1d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 24 deletions.
28 changes: 15 additions & 13 deletions R/CorrelationMethods.R
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,10 @@ pairs.DataFrame <- function (x, labels, panel = points, ..., horInd = 1:nc, verI
, tagCountThreshold, applyThresholdBoth
, digits) {
# Select samples
if (all(samples %in% colnames(expr.table))) {
expr.table <- expr.table[,samples]
} else if(samples == "all"){
if(samples == "all"){
samples <- colnames(expr.table)
} else if (all(samples %in% colnames(expr.table))) {
expr.table <- expr.table[,samples]
} else stop("'samples' parameter must be either \"all\" or a character vector of valid sample labels!")
nr.samples <- length(samples)

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

pairs( expr.table
, lower.panel = pointsUnique
, upper.panel = panel.cor
, pch = "."
, cex = 4
, log = "xy"
, las = 1
, xaxp = c(1,10,1)
, yaxp = c(1,10,1)
, labels = samples)
if (TOPLOT){
pairs( expr.table
, lower.panel = pointsUnique
, upper.panel = panel.cor
, pch = "."
, cex = 4
, log = "xy"
, las = 1
, xaxp = c(1,10,1)
, yaxp = c(1,10,1)
, labels = samples)
}

# Return a correlation matrix
corr.m <- matrix(1, nr.samples, nr.samples)
Expand Down
28 changes: 17 additions & 11 deletions R/ExportMethods.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ setGeneric( "plotReverseCumulatives",
group <- "group"
}

# no need for colors if a multi-facet plot and many colors
if (is.null(object@metadata$colData$Colors)) {
object@metadata$colData$Colors <- scales::hue_pal()(length(object))
}
Expand Down Expand Up @@ -230,8 +231,8 @@ setMethod("plotReverseCumulatives", "GRanges",
#' @family CAGEr plot functions
#' @family CAGEr clusters functions
#'
#' @importFrom ggplot2 ggplot scale_fill_manual geom_histogram facet_wrap
#' @importFrom ggplot2 ggtitle xlab ylab labs
#' @importFrom ggplot2 ggplot aes_string scale_fill_manual geom_histogram facet_wrap
#' @importFrom ggplot2 ggtitle xlab ylab
#'
#' @examples
#'
Expand Down Expand Up @@ -278,17 +279,22 @@ setMethod( "plotInterquantileWidth", "CAGEexp"

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

ggplot2::ggplot(iqwidths) +
ggplot2::aes_string(x = "iq_width", fill = "sampleName") +
ggplot2::scale_fill_manual(values = names(sampleLabels(object))) +
ggplot2::geom_histogram(bins = binsize) +
ggplot2::facet_wrap("~sampleName") +
ggplot2::ggtitle(paste0(
iqwidth_plot <- ggplot(iqwidths) +
aes_string(x = "iq_width") +
scale_fill_manual(values = names(sampleLabels(object))) +
geom_histogram(bins = binsize) +
facet_wrap("~sampleName") +
ggtitle(paste0(
switch(clusters, tagClusters = "Tag Clusters", consensusClusters = "Consenss Clusters"),
" interquantile width (quantile ", qLow, " to ", qUp, ")")) +
ggplot2::xlab("Interquantile width (bp)") +
ggplot2::ylab("Frequency") +
ggplot2::labs(fill = "Sample name")
xlab("Interquantile width (bp)") +
ylab("Frequency")

if (TOPLOT){
print(iqwidth_plot)
}

return(iqwidth_plot)
})

#' @name plotExpressionProfiles
Expand Down

0 comments on commit f7aaf1d

Please sign in to comment.