Skip to content

Commit 08583bf

Browse files
committed
address ggplot comments
1 parent 76c68d1 commit 08583bf

File tree

2 files changed

+24
-40
lines changed

2 files changed

+24
-40
lines changed

R/CorrelationMethods.R

+17-19
Original file line numberDiff line numberDiff line change
@@ -540,26 +540,24 @@ pairs.DataFrame <- function (x, labels, panel = points, ..., horInd = 1:nc, verI
540540
points(df, ...)
541541
}
542542

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-
}
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)
555553

556-
# Return a correlation matrix
557-
corr.m <- matrix(1, nr.samples, nr.samples)
558-
colnames(corr.m) <- samples
559-
rownames(corr.m) <- samples
560-
corr.m[lower.tri(corr.m)] <- corr.v
561-
corr.m[upper.tri(corr.m)] <- t(corr.m)[upper.tri(corr.m)]
562-
corr.m
554+
# # Return a correlation matrix
555+
# corr.m <- matrix(1, nr.samples, nr.samples)
556+
# colnames(corr.m) <- samples
557+
# rownames(corr.m) <- samples
558+
# corr.m[lower.tri(corr.m)] <- corr.v
559+
# corr.m[upper.tri(corr.m)] <- t(corr.m)[upper.tri(corr.m)]
560+
# corr.m
563561
}
564562

565563
# Vanja's version of smooth scatter that allows passing range.x argument to grDevices:::.smoothScatterCalcDensity function to calculate 2D kernel smoothed density

R/ExportMethods.R

+7-21
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ NULL
6464
#' ggplot2::ggtitle("prim6 replicates")
6565
#' tagClustersGR(exampleCAGEexp) |> plotReverseCumulatives()
6666
#'
67-
#' @importFrom ggplot2 aes geom_line geom_abline facet_wrap geom_text geom_vline ggplot
67+
#' @importFrom ggplot2 aes geom_line geom_abline facet_wrap geom_text geom_vline ggplot scale_x_log10 scale_y_log10
6868
#' @importFrom rlang .data
6969
#' @importFrom scales hue_pal
7070
#' @importFrom stats cor median
@@ -81,9 +81,7 @@ setGeneric( "plotReverseCumulatives",
8181
.plotReverseCumulatives <-
8282
function( object, values = c("raw", "normalized")
8383
, fitInRange = c(10, 1000)
84-
, group = NULL
85-
, xlim = c(1, 1e5)
86-
, ylim = c(1, 1e6)) {
84+
, group = NULL) {
8785
if (is.null(object@metadata$colData))
8886
stop("Expects a List-like object with a colData DataFrame in its metadata slot.")
8987

@@ -130,14 +128,12 @@ setGeneric( "plotReverseCumulatives",
130128
reference.library.size <- 10^floor(log10(median(sapply(object, sum))))
131129
reference.intercept <- log10(reference.library.size/VGAM::zeta(-1*reference.slope)) # intercept on log10 scale used for plotting with abline
132130

133-
plot_out <- ggplot(intermediate_df) +
131+
ggplot(intermediate_df) +
134132
aes(x=x, y=y) +
135133
geom_line() +
136134
facet_wrap(. ~sampleLabels) +
137-
xlim(xlim[1], xlim[2]) +
138-
ylim(ylim[1], ylim[2]) +
139-
scale_x_continuous(trans='log10') +
140-
scale_y_continuous(trans='log10') +
135+
scale_x_log10() +
136+
scale_y_log10() +
141137
labs(title="Reference distribution:",
142138
subtitle = paste0("alpha= ", sprintf("%.2f", -1*reference.slope), " T= ", reference.library.size),
143139
x =xlab, y = ylab) +
@@ -152,12 +148,7 @@ setGeneric( "plotReverseCumulatives",
152148
# ToDo: what is the intended behaviour?
153149
warning("reference distribution not fitted")
154150
}
155-
156-
if (TOPLOT){
157-
print(plot_out)
158-
}
159-
160-
return(list(plot_out, reference.slope, reference.library.size, reference.intercept))
151+
161152
}
162153

163154
#' @rdname plotReverseCumulatives
@@ -284,7 +275,7 @@ setMethod( "plotInterquantileWidth", "CAGEexp"
284275

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

287-
iqwidth_plot <- ggplot(iqwidths) +
278+
ggplot(iqwidths) +
288279
aes_string(x = "iq_width") +
289280
scale_fill_manual(values = names(sampleLabels(object))) +
290281
geom_histogram(bins = binsize) +
@@ -295,11 +286,6 @@ setMethod( "plotInterquantileWidth", "CAGEexp"
295286
xlab("Interquantile width (bp)") +
296287
ylab("Frequency")
297288

298-
if (TOPLOT){
299-
print(iqwidth_plot)
300-
}
301-
302-
return(iqwidth_plot)
303289
})
304290

305291
#' @name plotExpressionProfiles

0 commit comments

Comments
 (0)