Skip to content

Pull new main commits #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 25 additions & 21 deletions R/Boxplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,32 @@
#' @param groupvar_name A character containing the name for the group variable.
#' @param group_colours A character vector of hex codes for the group colors.
#' @param base_size A numeric containing the base size of the font.
#' @param lwd A numeric containing the line width of the boxplot.
#' @param outlier_size A numeric containing the size of the outliers.
#'
#' @return a tibble and a ggplot of the valid values
#' @export
#'
#' @examples
#' \dontrun{
#' prepared_data <- prepareData(...)
#'
#'
#' boxplot <- Boxplots(D_long = prepared_data[["D_long"]])
#' }
#'
#'

Boxplots <- function(D_long,
do_log_transformation = FALSE,
do_log_transformation = FALSE,
log_base = 2,
method = "boxplot",
use_groups = NULL,
groupvar_name = "Group",
groupvar_name = "Group",
group_colours = NULL,
base_size = 15){


base_size = 15,
lwd = 1,
outlier_size = 1){


mess <- ""

if(is.null(use_groups)){
Expand All @@ -43,45 +47,45 @@ Boxplots <- function(D_long,
use_groups <- FALSE
}
}

# log-transform data if necessary
if(do_log_transformation) {
D_long$value <- log(D_long$value, base = log_base)
}

x_axis <- sort(unique(D_long$name)) # save the different states for later
D_long <- D_long[!is.na(D_long$value),] # remove NA values

name <- value <- group <- NULL
if (use_groups) {
pl_boxplot <- ggplot2::ggplot(D_long, ggplot2::aes(x = name, y = value, fill = group)) +
ggplot2::labs(fill = groupvar_name)
ggplot2::labs(fill = groupvar_name)
if (!is.null(group_colours)) pl_boxplot <- pl_boxplot + ggplot2::scale_fill_manual(values = group_colours)
mess <- paste0(mess, "with groups. \n")
} else {
pl_boxplot <- ggplot2::ggplot(D_long, ggplot2::aes(x = name, y = value))
mess <- paste0(mess, "without groups. \n")
}


pl_boxplot <- pl_boxplot +
ggplot2::theme_bw(base_size = base_size) +
ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 45, vjust = 1, hjust=1)) +
ggplot2::ylab("Log intensity") + ggplot2::xlab("Sample") +
ggplot2::ylab("Log intensity") + ggplot2::xlab("Sample") +
ggplot2::scale_x_discrete(limits = x_axis, drop = FALSE, na.translate = TRUE)


if (method == "violinplot"){
pl_boxplot <- pl_boxplot + ggplot2::geom_violin()
mess <- paste0("Violin Plot generated ", mess)
}

if (method == "boxplot") {
pl_boxplot <- pl_boxplot + ggplot2::geom_boxplot()
pl_boxplot <- pl_boxplot + ggplot2::geom_boxplot(linewidth = lwd, outlier.size = outlier_size)
mess <- paste0("Boxplot generated ", mess)
}

message(mess)

return(list("plot" = pl_boxplot, "message" = mess))
}
}
3 changes: 3 additions & 0 deletions R/workflow_QC.R
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ workflow_QC <- function(data_path,
write.csv(x = prepared_data$D, file = paste0(output_path, "/D_norm_wide", suffix, ".csv"), row.names = FALSE)
write.csv(x = prepared_data$D_long, file = paste0(output_path, "/D_norm_long", suffix, ".csv"), row.names = FALSE)

openxlsx::write.xlsx(x = cbind(prepared_data$ID, prepared_data$D), file = paste0(output_path, "/D_norm_ID", suffix, ".xlsx"),
rowNames = FALSE, overwrite = TRUE, keepNA = TRUE)


#### Calculate Valid Value Plot ####

Expand Down
8 changes: 7 additions & 1 deletion man/Boxplots.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 0 additions & 30 deletions man/calculate_onoff.Rd

This file was deleted.

92 changes: 46 additions & 46 deletions tests/testthat/_snaps/Boxplot/boxplot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading