Skip to content

Commit

Permalink
start moving away from aes_string()
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnMount committed Apr 14, 2023
1 parent 8e18212 commit 3e8aad1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
6 changes: 3 additions & 3 deletions R/BinaryYScatterPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ BinaryYScatterPlot = function(frame, xvar, yvar, title, ...,
if(use_glm) {
model = glm(frame[[yvar]] == max(frame[[yvar]]) ~ frame[[xvar]], family=binomial(link="logit"))
frame$smooth = predict(model, type="response")
ggplot2::ggplot(frame, ggplot2::aes_string(x=xvar)) +
ggplot2::geom_point(ggplot2::aes_string(y=yvar), color=point_color,
ggplot2::ggplot(data = frame, mapping = ggplot2::aes(!!!simulate_aes_string(x=xvar))) +
ggplot2::geom_point(ggplot2::aes(!!!simulate_aes_string(y=yvar)), color=point_color,
position=ggplot2::position_jitter(height=0.01), alpha=0.5) +
ggplot2::geom_line(ggplot2::aes(y=smooth), color=smooth_color) +
ggplot2::ggtitle(title)
} else {
ggplot2::ggplot(frame, ggplot2::aes_string(x=xvar, y=yvar)) +
ggplot2::ggplot(data = frame, mapping = ggplot2::aes(!!!simulate_aes_string(x=xvar, y=yvar))) +
ggplot2::geom_point(color=point_color, position=ggplot2::position_jitter(height=0.01), alpha=0.5) +
ggplot2::geom_smooth(color=smooth_color, se=se, method = 'loess', formula = y ~ x) +
ggplot2::ggtitle(title)
Expand Down
4 changes: 2 additions & 2 deletions R/ClevelandDotPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ ClevelandDotPlot = function(frm, xvar, title, ...,
}
frm$count = 1
if(stem) {
p = ggplot2::ggplot(frm, ggplot2::aes_string(x=xvar, y="count")) +
p = ggplot2::ggplot(data = frm, mapping = ggplot2::aes(!!!simulate_aes_string(x=xvar, y="count"))) +
ggplot2::stat_summary(fun.data=stemdotstats, geom="pointrange", color=color)
} else {
p = ggplot2::ggplot(frm, ggplot2::aes_string(x=xvar)) +
p = ggplot2::ggplot(data = frm, mapping = ggplot2::aes(!!!simulate_aes_string(x=xvar))) +
ggplot2::geom_point(stat="count", color=color)
}
p + ggplot2::ggtitle(title)
Expand Down
12 changes: 8 additions & 4 deletions R/ConditionalSmoothedScatterPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,14 @@ ConditionalSmoothedScatterPlot = function(frame, xvar, yvar,
p = ggplot2::ggplot()
if(!is.null(point_color)) {
p = p + ggplot2::geom_point(data=frame,
ggplot2::aes_string(x=xvar, y=yvar),
mapping=ggplot2::aes(!!!simulate_aes_string(x=xvar, y=yvar)),
color=point_color,
alpha=point_alpha)
}
p = p + ggplot2::geom_line(data=fs, ggplot2::aes_string(x=xvar, y="smooth"), color=smooth_color)
p = p + ggplot2::geom_line(
data=fs,
mapping=ggplot2::aes(!!!simulate_aes_string(x=xvar, y="smooth")),
color=smooth_color)
} else{
gplist = unique(fs[[groupvar]])
for(gp in gplist) {
Expand All @@ -126,10 +129,11 @@ ConditionalSmoothedScatterPlot = function(frame, xvar, yvar,
p = ggplot2::ggplot()
if(!is.null(point_color)) {
p = p + ggplot2::geom_point(data=frame,
ggplot2::aes_string(x=xvar, y=yvar, color=groupvar),
mapping=ggplot2::aes(!!!simulate_aes_string(x=xvar, y=yvar, color=groupvar)),
alpha=point_alpha)
}
p = p + ggplot2::geom_line(data=fs, ggplot2::aes_string(x=xvar,y="smooth",color=groupvar))
p = p + ggplot2::geom_line(data=fs,
mapping=ggplot2::aes(!!!simulate_aes_string(x=xvar,y="smooth",color=groupvar)))
if(!is.null(palette)) {
p = p + ggplot2::scale_color_brewer(palette=palette)
}
Expand Down
6 changes: 3 additions & 3 deletions R/ThresholdPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,13 @@ ThresholdPlot <- function(frame, xvar, truthVar, title,
metric <- NULL # don't look like an unbound variable

if(monochrome) {
ggplot2::ggplot(data = stats, mapping = ggplot2::aes_string(x = 'threshold', y = 'value')) +
ggplot2::ggplot(data = stats, mapping = ggplot2::aes(!!!simulate_aes_string(x = 'threshold', y = 'value'))) +
ggplot2::geom_line(color=linecolor) +
ggplot2::facet_wrap(~metric, ncol = 1) +
ggplot2::ylim(c(0, 1)) +
ggplot2::ggtitle(title)
} else {
p = ggplot2::ggplot(data = stats, mapping = ggplot2::aes_string(x = 'threshold', y = 'value')) +
p = ggplot2::ggplot(data = stats, mapping = ggplot2::aes(!!!simulate_aes_string(x = 'threshold', y = 'value'))) +
ggplot2::geom_line(aes(color=metric)) +
ggplot2::facet_wrap(~metric, ncol = 1) +
ggplot2::ylim(c(0, 1)) +
Expand Down Expand Up @@ -382,7 +382,7 @@ MetricPairPlot <- function(frame, xvar, truthVar, title,
stats <- stats[ , c(x_metric, y_metric), drop = FALSE]
# re-order for plotting
stats <- stats[order(stats[[x_metric]], stats[[y_metric]]), , drop = FALSE]
ggplot2::ggplot(data = stats, mapping = ggplot2::aes_string(x = x_metric, y = y_metric)) +
ggplot2::ggplot(data = stats, mapping = ggplot2::aes(!!!simulate_aes_string(x = x_metric, y = y_metric))) +
ggplot2::geom_line(color=linecolor) +
ggplot2::ggtitle(title)
}
Expand Down

0 comments on commit 3e8aad1

Please sign in to comment.