Skip to content

Commit 76c68d1

Browse files
committed
standardize imports, add warning when no range is defined for fitting the values, to be fixed
1 parent 7446eae commit 76c68d1

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

R/ExportMethods.R

+24-23
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ NULL
6464
#' ggplot2::ggtitle("prim6 replicates")
6565
#' tagClustersGR(exampleCAGEexp) |> plotReverseCumulatives()
6666
#'
67-
#' @importFrom ggplot2 aes geom_abline geom_step geom_vline ggplot ggtitle
68-
#' @importFrom ggplot2 guides guide_legend labs
69-
#' @importFrom ggplot2 scale_color_manual scale_x_log10 scale_y_log10
67+
#' @importFrom ggplot2 aes geom_line geom_abline facet_wrap geom_text geom_vline ggplot
7068
#' @importFrom rlang .data
7169
#' @importFrom scales hue_pal
7270
#' @importFrom stats cor median
@@ -131,27 +129,30 @@ setGeneric( "plotReverseCumulatives",
131129
reference.slope <- min(median(fit.slopes), -1.05)
132130
reference.library.size <- 10^floor(log10(median(sapply(object, sum))))
133131
reference.intercept <- log10(reference.library.size/VGAM::zeta(-1*reference.slope)) # intercept on log10 scale used for plotting with abline
134-
}
135132

136-
plot_out <- ggplot2::ggplot(intermediate_df) +
137-
ggplot2::aes(x=x, y=y) +
138-
ggplot2::geom_line() +
139-
ggplot2::facet_wrap(. ~sampleLabels) +
140-
xlim(xlim[1], xlim[2]) +
141-
ylim(ylim[1], ylim[2]) +
142-
scale_x_continuous(trans='log10') +
143-
scale_y_continuous(trans='log10') +
144-
labs(title="Reference distribution:",
145-
subtitle = paste0("alpha= ", sprintf("%.2f", -1*reference.slope), " T= ", reference.library.size),
146-
x =xlab, y = ylab) +
147-
ggplot2::geom_text(data = intermediate_df,
148-
mapping= aes(
149-
x=10, y= 10,
150-
label = paste0("alpha= ", formatC(-1*fit.slopes[sampleLabels], format = "f", digits = 2)))) +
151-
ggplot2::geom_vline(xintercept=fitInRange, linetype="dotted") +
152-
ggplot2::geom_abline(slope = reference.slope, intercept = reference.intercept,
153-
linetype="longdash", colour="#7F7F7F7F")
154-
133+
plot_out <- ggplot(intermediate_df) +
134+
aes(x=x, y=y) +
135+
geom_line() +
136+
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') +
141+
labs(title="Reference distribution:",
142+
subtitle = paste0("alpha= ", sprintf("%.2f", -1*reference.slope), " T= ", reference.library.size),
143+
x =xlab, y = ylab) +
144+
geom_text(data = intermediate_df,
145+
mapping= aes(
146+
x=10, y= 10,
147+
label = paste0("alpha= ", formatC(-1*fit.slopes[sampleLabels], format = "f", digits = 2)))) +
148+
geom_vline(xintercept=fitInRange, linetype="dotted") +
149+
geom_abline(slope = reference.slope, intercept = reference.intercept,
150+
linetype="longdash", colour="#7F7F7F7F")
151+
} else{
152+
# ToDo: what is the intended behaviour?
153+
warning("reference distribution not fitted")
154+
}
155+
155156
if (TOPLOT){
156157
print(plot_out)
157158
}

0 commit comments

Comments
 (0)