Skip to content

fix: improve error handling and fix minor bugs - #2

Open
mugpeng wants to merge 1 commit into
GangLiLab:masterfrom
mugpeng:fix-bugs-improve-error-handling
Open

fix: improve error handling and fix minor bugs#2
mugpeng wants to merge 1 commit into
GangLiLab:masterfrom
mugpeng:fix-bugs-improve-error-handling

Conversation

@mugpeng

@mugpeng mugpeng commented Aug 19, 2026

Copy link
Copy Markdown

Hi @liuyunze, thank you for maintaining this useful package!

This PR addresses a few bugs and improvements I noticed while reviewing the code. All changes are backward-compatible from the user's perspective.


1. Download failure now throws a clear error (utilities.R)

Before: When geneset_download() failed and no local cache existed, it returned FALSE silently. None of the callers (getGO, getKEGG, etc.) checked the return value, so the next line — fst::read.fst(destfile) — crashed with a cryptic file-not-found error from the fst package.

After: When download fails and no local cache is available, geneset_download() now calls stop() directly with the helpful message that was already being printed (including the download URL and manual instructions).

2. geneset_name returns an empty data.frame instead of logical NA (getEnrichrdb.R, getHgDisease.R, getMsigdb.R)

Before: For data sources that don't have a separate name table, the code set res[['geneset_name']] <- NA, returning a logical NA. This is inconsistent with other get* functions that always return a data.frame, and breaks downstream code that calls head(), colnames(), or nrow() on the result.

After: Now returns data.frame(term = character(0), name = character(0), stringsAsFactors = FALSE), which is type-compatible with the rest of the API.

3. Fixed typo in getKEGG.R

Corrected categoty to category and support to supports in the error message for non-human KEGG categories.


Please feel free to let me know if you'd like any adjustments!

- utilities.R: geneset_download now calls stop() when download fails
  and no local cache exists, instead of returning FALSE and letting
  callers crash with a cryptic fst::read.fst error
- getEnrichrdb.R, getHgDisease.R, getMsigdb.R: geneset_name now
  returns an empty data.frame instead of logical NA, keeping the
  return type consistent with other get*() functions
- getKEGG.R: fix typo 'categoty' -> 'category' and grammar
  'support' -> 'supports'
- getKEGG.R: include category in local cache filename to avoid
  collisions between pathway/module/enzyme caches for the same organism
@mugpeng
mugpeng force-pushed the fix-bugs-improve-error-handling branch from 8c6577c to 328ebfd Compare August 19, 2026 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant