Skip to content

Commit

Permalink
remove distr dependency, fix aes_string and other issues
Browse files Browse the repository at this point in the history
  • Loading branch information
matdoering committed Jan 13, 2024
1 parent b1c9ff7 commit 16a2348
Show file tree
Hide file tree
Showing 16 changed files with 88 additions and 190 deletions.
5 changes: 1 addition & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Depends:
R (>= 4.0.0)
License: GPL-2
Encoding: UTF-8
RoxygenNote: 7.1.1
RoxygenNote: 7.3.0
Imports:
Biostrings (>= 2.38.4),
XML (>= 3.98-1.4),
Expand All @@ -45,9 +45,6 @@ Imports:
S4Vectors (>= 0.8.11),
foreach (>= 1.4.3),
magrittr (>= 1.5),
distr (>= 2.6),
distrEx (>= 2.6),
fitdistrplus (>= 1.0-7),
uniqtag (>= 1.0),
openxlsx (>= 4.0.17),
grid (>= 3.1.0),
Expand Down
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ S3method(assign_binding_regions,character)
S3method(assign_binding_regions,numeric)
S3method(cbind,Primers)
S3method(cbind,Templates)
S3method(cbind,fill)
S3method(rbind,Primers)
S3method(rbind,Templates)
export(ConstraintOptions)
export(ConstraintSettings)
export(CoverageConstraints)
export(PCR_Conditions)
export(Primers)
export(Templates)
export(adjust_binding_regions)
Expand Down
6 changes: 0 additions & 6 deletions R/PrimerDesign.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@
#' The algorithm tries to ensure that the designed set of primers
#' achieves a coverage ratio not lower than \code{required.cvg}.
#' To this end, the constraints for designing primers may be relaxed.}
#' \item{\code{classify_design_problem}}{Uses reference beta distributions
#' of primer coverage ratios to classify a primer design task into
#' groups ranging from \emph{easy} to \emph{hard}. For \emph{easy} tasks,
#' it should not be a problem to design a small primer set. For
#' \emph{hard} tasks, however, a small set of primers may not be
#' achievable.}
#' \item{\code{get_initial_primers}}{Creates a set of primer candidates
#' based on the input template sequences. This set of primers can
#' be used to create custom primer design algorithms.}
Expand Down
4 changes: 2 additions & 2 deletions R/con_template_secondary_structures.R
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ plot.Delta.DeltaG <- function(constrained.foldings, stratify = FALSE) {
g = groups)[-1]

if (!stratify) {
p <- ggplot(plot.df, aes_string(x = "Binding_Region", y = "Delta_Delta_G")) + geom_bar(stat = "summary")
p <- ggplot(plot.df, aes(x = .data[["Binding_Region"]], y = .data[["Delta_Delta_G"]])) + geom_bar(stat = "summary")
} else {
p <- ggplot(plot.df, aes_string(x = "Binding_Region", y = "Delta_Delta_G")) + geom_boxplot() +
p <- ggplot(plot.df, aes(x = .data[["Binding_Region"]], y = .data[["Delta_Delta_G"]])) + geom_boxplot() +
facet_wrap(~Group)
}
x.names <- unique(paste(plot.df$Constraint_Region_Start, "-", plot.df$Constraint_Region_End,
Expand Down
8 changes: 4 additions & 4 deletions R/plots_comparison.R
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,11 @@ plot_primer.comparison.box <- function(primer.data,
}
plot.df$Run <- abbreviate(plot.df$Run, getOption("openPrimeR.plot_abbrev"))
plot.df$Run <- factor(plot.df$Run, levels = unique(plot.df$Run)[order(as.character(unique(plot.df$Run)))])
p <- ggplot(plot.df, aes_string(x = "Run", y = "Value", colour = "Run")) +
p <- ggplot(plot.df, aes(x = .data[["Run"]], y = .data[["Value"]], colour = .data[["Run"]])) +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
ggtitle(title) + ylab("Value") +
geom_boxplot(outlier.shape = NA) +
guides(colour = FALSE) # remove legend: is redundant here
guides(colour = "none") # remove legend: is redundant here
if (length(con.identifier) > 1) {
# multiple constraints are plotted
p <- p + facet_wrap(as.formula("~Constraint"),
Expand All @@ -313,8 +313,8 @@ plot_primer.comparison.box <- function(primer.data,
colors <- colorRampPalette(brewer.pal(8, pal))(length(unique(plot.df$Run)))
p <- p + scale_colour_manual(values = colors)
if (length(boundary.data) != 0) {
p <- p + geom_hline(data = boundary.data, aes_string(yintercept = "Z"),
size = 0.25,
p <- p + geom_hline(data = boundary.data, aes(yintercept = .data[["Z"]]),
linewidth = 0.25,
colour = "red", linetype = 2)
}
if (length(y.limits) != 0) {
Expand Down
32 changes: 16 additions & 16 deletions R/plots_constraints.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ plot_template_structure <- function(fold.df) {
fold.df$Region <- intervals
ylab <- expression(paste(Delta, " G (no structure) - ", Delta, " G (structure) [kcal/mol]", sep = ""))
p <- ggplot(fold.df) +
geom_boxplot(aes_string(x = "Region", y = "Delta_Delta_G", fill = "Group")) +
geom_boxplot(aes(x = .data[["Region"]], y = .data[["Delta_Delta_G"]], fill = .data[["Group"]])) +
facet_wrap(~Direction, scales = "free_x") +
ggtitle("Template secondary structures") +
ylab(ylab)
Expand Down Expand Up @@ -209,7 +209,7 @@ plot_constraint.histogram <- function(primer.df, con.cols, con.identifier, bound
Z = bound)
boundary.data <- rbind(boundary.data, cur.bound)
}
p <- ggplot(plot.df, aes_string(x = "Value", fill = "Direction")) +
p <- ggplot(plot.df, aes(x = .data[["Value"]], fill = .data[["Direction"]])) +
xlab("Value") +
ylab("Count") + ggtitle("Constraints") +
scale_fill_manual(values = plot.colors) +
Expand All @@ -225,7 +225,7 @@ plot_constraint.histogram <- function(primer.df, con.cols, con.identifier, bound
}
if (length(boundary.data) != 0) {
p <- p + geom_vline(data = boundary.data,
aes_string(xintercept = "Z"),
aes(xintercept = .data[["Z"]]),
size = 0.25, colour = "red", linetype = 2)
}
if (length(x.limits) != 0) {
Expand Down Expand Up @@ -422,7 +422,7 @@ plot.dimer.dist <- function(dimer.data, deltaG.cutoff) {
} else if (all(dimer.df$Decision == "No Dimer")) {
colors <- colors[2]
}
p <- ggplot(dimer.df, aes_string(x = "DeltaG")) + geom_histogram(aes_string(fill = "Decision"),
p <- ggplot(dimer.df, aes(x = .data[["DeltaG"]])) + geom_histogram(aes(fill = .data[["Decision"]]),
colour = "grey") + geom_vline(xintercept = deltaG.cutoff, colour = "red") +
ggtitle(expression(paste("Dimerization ", Delta, " G values",
sep = ""))) + xlab(expression(paste(Delta, " G", sep = ""))) + scale_fill_manual(values = colors) +
Expand Down Expand Up @@ -680,13 +680,13 @@ setMethod("plot_constraint_fulfillment",
nbr.constraints <- length(unique(eval.m$Constraint))
eval.m$ID <- factor(unique(eval.m$ID))
levels(eval.m$ID) = abbreviate(levels(eval.m$ID), getOption("openPrimeR.plot_abbrev"))
p <- ggplot(eval.m, aes_string(x = "Constraint", y = "ID")) + geom_tile(aes_string(fill = "Outcome"),
colour = "black") + scale_fill_manual(values = colors) +
theme(axis.text.x = element_text(angle = 60,
p <- ggplot(eval.m, aes(x = .data[["Constraint"]], y = .data[["ID"]])) + geom_tile(aes(fill = .data[["Outcome"]]),
colour = "black") + scale_fill_manual(values = colors) +
theme(axis.text.x = element_text(angle = 60,
hjust = 1)) +
ggtitle(title) + xlab(xlab) + ylab(ylab) +
theme(legend.title = element_text(face = "bold")) +
scale_x_discrete(labels = constraint.names) +
theme(legend.title = element_text(face = "bold")) +
scale_x_discrete(labels = constraint.names) +
scale_y_discrete(limits = rev(levels(eval.m$ID))) # top primer should be the first entry in the plot
return(p)
})
Expand Down Expand Up @@ -733,14 +733,14 @@ setMethod("plot_constraint_fulfillment",
colors <- colorRampPalette(brewer.pal(8, pal))(length(unique(new.df[, "Constraint"])))
# plot
p <- ggplot(new.df) +
geom_bar(mapping = aes_string(x = "Constraint", y = "Ratio",
fill = "Constraint"), position = "dodge", stat = "identity") +
geom_bar(mapping = aes(x = .data[["Constraint"]], y = .data[["Ratio"]],
fill = .data[["Constraint"]]), position = "dodge", stat = "identity") +
scale_y_continuous(labels = scales::percent) + ylab("Fulfillment ratio") +
xlab("Constraint") + ggtitle("Evaluation of constraints") +
theme(
axis.text.x = element_text(angle = 90, hjust = 1)) +
facet_wrap(~Run, ncol = ncol) +
guides(fill = FALSE) + # remove legend: is redundant here
guides(fill = "none") + # remove legend: is redundant here
scale_x_discrete(labels = constraint.names) +
scale_fill_manual(labels = constraint.names, values = colors)

Expand Down Expand Up @@ -933,7 +933,7 @@ setMethod("plot_constraint_deviation",
# set up colors
pal <- getOption("openPrimeR.plot_colors")["Constraint"] # the RColorBrewer palette to use
colors <- colorRampPalette(brewer.pal(8, pal))(length(unique(df$Constraint)))
p <- ggplot(df, aes_string(x = "Constraint", y = "Deviation", colour = "Constraint")) +
p <- ggplot(df, aes(x = .data[["Constraint"]], y = .data[["Deviation"]], colour = .data[["Constraint"]])) +
theme(axis.text.x = element_text(angle = 60, hjust = 1)) +
ggtitle(title) +
ylab("Deviation from target") +
Expand All @@ -942,7 +942,7 @@ setMethod("plot_constraint_deviation",
height = 0)) +
scale_y_continuous(labels = scales::percent) +
scale_x_discrete(labels = constraint.names) +
guides(colour = FALSE) +
guides(colour = "none") +
scale_colour_manual(values = colors)
return(p)
})
Expand Down Expand Up @@ -1000,7 +1000,7 @@ setMethod("plot_constraint_deviation",
# set up colors
pal <- getOption("openPrimeR.plot_colors")[col.id] # the RColorBrewer palette to use
colors <- colorRampPalette(brewer.pal(8, pal))(length(unique(df[, col.id])))
p <- ggplot(plot.data, aes_string(x = "Run", y = "Mean_Deviation", colour = col.id)) +
p <- ggplot(plot.data, aes(x = .data[["Run"]], y = .data[["Mean_Deviation"]], colour = .data[[col.id]])) +
theme(axis.text.x = element_text(angle = 60, hjust = 1)) +
ggtitle(title) +
ylab(ylab) +
Expand All @@ -1011,7 +1011,7 @@ setMethod("plot_constraint_deviation",
if (deviation.per.primer) {
# show deviation per primer -> don't show legend for each primer
p <- p +
guides(colour = FALSE)
guides(colour = "none")
} else {
constraint.names <- constraints_to_unit(levels(plot.data$Constraint), FALSE)
# change names of constraints
Expand Down
Loading

0 comments on commit 16a2348

Please sign in to comment.