|
64 | 64 | #' ggplot2::ggtitle("prim6 replicates")
|
65 | 65 | #' tagClustersGR(exampleCAGEexp) |> plotReverseCumulatives()
|
66 | 66 | #'
|
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 |
70 | 68 | #' @importFrom rlang .data
|
71 | 69 | #' @importFrom scales hue_pal
|
72 | 70 | #' @importFrom stats cor median
|
@@ -131,27 +129,30 @@ setGeneric( "plotReverseCumulatives",
|
131 | 129 | reference.slope <- min(median(fit.slopes), -1.05)
|
132 | 130 | reference.library.size <- 10^floor(log10(median(sapply(object, sum))))
|
133 | 131 | reference.intercept <- log10(reference.library.size/VGAM::zeta(-1*reference.slope)) # intercept on log10 scale used for plotting with abline
|
134 |
| - } |
135 | 132 |
|
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 | + |
155 | 156 | if (TOPLOT){
|
156 | 157 | print(plot_out)
|
157 | 158 | }
|
|
0 commit comments