Skip to content

Commit

Permalink
Style code (GHA)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpquast committed May 17, 2024
1 parent 6b43b21 commit 14d8c48
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions R/calculate_go_enrichment.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ go_enrichment <- function(...) {
#' determines if the enrichment analysis should be performed in order to check for both enrichemnt and
#' deenrichemnt or only one of the two. This affects the statistics performed and therefore also the displayed
#' plot.
#' @param replace_long_name a logical argument that specifies if GO term names above 50 characters should
#' be replaced by the GO ID instead for the plot. This ensures that the plotting area doesn't become
#' @param replace_long_name a logical argument that specifies if GO term names above 50 characters should
#' be replaced by the GO ID instead for the plot. This ensures that the plotting area doesn't become
#' too small due to the long name. The default is `TRUE`.
#' @param label_move_frac a numeric argument between 0 and 1 that specifies which labels should be
#' @param label_move_frac a numeric argument between 0 and 1 that specifies which labels should be
#' moved outside of the bar. The default is 0.2, which means that the labels of all bars that have a size
#' of 20% or less of the largest bar are moved to the right of the bar. This prevents labels from
#' of 20% or less of the largest bar are moved to the right of the bar. This prevents labels from
#' overlapping with the bar boundaries.
#' @param min_n_detected_proteins_in_process is a numeric argument that specifies the minimum number of
#' detected proteins required for a GO term to be displayed in the plot. The default is 1, meaning
Expand Down Expand Up @@ -364,7 +364,7 @@ if you used the right organism ID.", prefix = "\n", initial = ""))
}
} %>%
tidyr::complete(.data$go_id, tidyr::nesting(!!rlang::ensym(is_significant), n_sig), fill = list(n_has_process = 0)) %>%
dplyr::ungroup() %>%
dplyr::ungroup() %>%
tidyr::drop_na(.data$go_id)


Expand Down Expand Up @@ -447,9 +447,9 @@ if you used the right organism ID.", prefix = "\n", initial = ""))
filtered_result_table <- result_table %>%
dplyr::ungroup() %>%
dplyr::filter(.data$n_detected_proteins_in_process >= min_n_detected_proteins_in_process)
if(replace_long_name){
filtered_result_table <- filtered_result_table %>%

if (replace_long_name) {
filtered_result_table <- filtered_result_table %>%
mutate(term = ifelse(nchar(.data$term) > 50, .data$go_id, .data$term))
}

Expand All @@ -468,10 +468,10 @@ if you used the right organism ID.", prefix = "\n", initial = ""))
plot_input <- filtered_result_table %>%
dplyr::ungroup() %>%
dplyr::mutate(neg_log_sig = -log10(!!rlang::ensym(type))) %>%
dplyr::group_by({{ group }}) %>%
dplyr::mutate(n = 1:dplyr::n()) %>%
dplyr::group_by({{ group }}) %>%
dplyr::mutate(n = 1:dplyr::n()) %>%
dplyr::filter(n <= top)
# dplyr::slice(1:top)
# dplyr::slice(1:top)
} else {
split_cutoff <- stringr::str_split(plot_cutoff, pattern = " ", simplify = TRUE)
type <- split_cutoff[1]
Expand All @@ -481,9 +481,9 @@ if you used the right organism ID.", prefix = "\n", initial = ""))
dplyr::mutate(neg_log_sig = -log10(!!rlang::ensym(type))) %>%
dplyr::filter(!!rlang::ensym(type) <= threshold)
}

# move label if bar is less than 20% (default) of largest bar
plot_input <- plot_input %>%
plot_input <- plot_input %>%
mutate(hjust = ifelse((.data$neg_log_sig / max(.data$neg_log_sig)) < label_move_frac, -0.15, 1.05))

if (plot_style == "barplot") {
Expand Down

0 comments on commit 14d8c48

Please sign in to comment.