Skip to content

Commit 8f8b9f5

Browse files
committed
#283 improve error handling
1 parent cec7e88 commit 8f8b9f5

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
* `assign_peptide_type` now takes the `start` argument, containing the start position of a peptide. If a protein does not have any peptide starting at position `1` and there is a peptide starting at position `2`, this peptide will be considered "tryptic" at the N-terminus. This is because the initial Methionine is likely missing due to processing for every copy of the protein and therefore position `2` is the true N-terminus.
2222
* `extract_metal_binders()` now uses keywords from UniProt as well. In addition, only "enables" GO terms are considered now.
2323
* `fetch_uniprot()` received another default column "keyword".
24+
* **Improved error handling:**
25+
`calculate_go_enrichment()` now checks if any significant proteins are present in the input `data`.
26+
If none are found (`is_significant == TRUE` for no rows), the function exits early.
2427

2528
# protti 0.9.1
2629

R/calculate_go_enrichment.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,12 @@ calculate_go_enrichment <- function(data,
247247

248248
if (!(plot_style %in% c("barplot", "heatmap"))) stop("Invalid plot_style. Available styles: barplot, heatmap")
249249

250+
# Check for presence of significant proteins
251+
if (sum(data[[rlang::as_name(rlang::enquo(is_significant))]], na.rm = TRUE) == 0) {
252+
message("No significant proteins found in the input data. Gene ontology enrichment analysis will not be performed.")
253+
return(invisible(NULL))
254+
}
255+
250256
if (length(barplot_fill_colour) < 2) stop('Please provide at least two colours to "barplot_fill_colour"!')
251257

252258
if (!stringr::str_detect(plot_cutoff, pattern = "^(pval|adj_pval) (top\\d+|\\d+(\\.\\d+)?)$")) {

0 commit comments

Comments
 (0)