Skip to content

Commit

Permalink
chalmers-gem: for non-human organisms Gene Symbols are used instead…
Browse files Browse the repository at this point in the history
… of ENSG IDs; updated regex to match those; fixes #116
  • Loading branch information
deeenes committed Feb 13, 2025
1 parent f2437fc commit 03cdd2d
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions R/chalmers_gem.R
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ chalmers_gem_network <- function(
#' @importFrom magrittr %>% inset2
#' @importFrom dplyr filter select bind_rows mutate rename
#' @importFrom tidyr unnest_longer separate_wider_regex
#' @importFrom stringr str_replace str_c
#' @importFrom stringr str_replace_all str_c
#' @noRd
binary_from_reaction <- function(
reactions,
Expand Down Expand Up @@ -349,16 +349,14 @@ binary_from_reaction <- function(
{select(.$r, ri, ci, source = !!sym(.$t), target = !!sym(.$s))} %>%
mutate(reverse = TRUE, met_to_gene = !met_to_gene)
)} %>%
mutate(
across(
c(source, target),
~str_replace(.x, '^\\(?(ENS[A-Z]+\\d+)\\)?$', '\\1')
)
) %>%
mutate(across(c(source, target), ~str_replace_all(.x, '[\\(\\)]', ''))) %>%
filter(!is.na(source), !is.na(target)) %>%
separate_wider_regex(
c(source, target),
patterns = c(id = '(?:MAM|ENSG)\\d+', comp = '[cmxrelgni]?'),
patterns = c(
id = '(?:MAM\\d+|[-\\w\\.:\'\\[\\]]+)',
comp = '[cmxrelgni]??'
),
names_sep = '_'
) %>%
mutate(comp = as.factor(str_c(source_comp, target_comp))) %>%
Expand Down

0 comments on commit 03cdd2d

Please sign in to comment.