A convenience function that uses gene_eval
and a custom function to apply new upper and lower bounds.
gene_associate( reaction_table, gene_table, expression_flux_function = function(x) { (1 + log(x)/stats::sd(x)^2)^sign(x - 1) } )
reaction_table | A data frame describing the metabolic model. |
---|---|
gene_table | A data frame showing gene presence |
expression_flux_function | a function to convert from gene set expression to flux |
the reaction_table, with a new column, present, and altered upper and lower bounds
This function relies on gene_eval
, which uses eval
to evaluate gene expression sets.
This gives flexibility, but means that malicious code in the gene_sets
argument could get evaluated.
gene_sets
is evaluated in a restricted environment, but there might be a way around this, so you might want to check for anything suspicious in this argument manually.
For more information, read the code.
gene_eval
#> #>#>#> #>#>#> #>gene_table = tibble(name = iJO1366$geneAssociation %>% stringr::str_split('and|or|\\s|\\(|\\)') %>% purrr::flatten_chr() %>% unique, presence = 1) %>% filter(name != '', !is.na(name)) gene_associate(reaction_table = iJO1366 %>% mutate(geneAssociation = geneAssociation %>% stringr::str_replace_all('and', '&') %>% stringr::str_replace_all('or', '|') ), gene_table = gene_table )#> # A tibble: 2,583 x 9 #> abbreviation lowbnd uppbnd obj_coef equation officialName geneAssociation #> <chr> <dbl> <dbl> <dbl> <chr> <chr> <chr> #> 1 12DGR120tipp 0 1000 0 12dgr12… 1,2 diacylg… "" #> 2 12DGR140tipp 0 1000 0 12dgr14… 1,2 diacylg… "" #> 3 12DGR141tipp 0 1000 0 12dgr14… 1,2 diacylg… "" #> 4 12DGR160tipp 0 1000 0 12dgr16… 1,2 diacylg… "" #> 5 12DGR161tipp 0 1000 0 12dgr16… 1,2 diacylg… "" #> 6 12DGR180tipp 0 1000 0 12dgr18… 1,2 diacylg… "" #> 7 12DGR181tipp 0 1000 0 12dgr18… 1,2 diacylg… "" #> 8 12PPDRtex -1000 1000 0 12ppd__… (R)-Propane… "b0241 | b0929… #> 9 12PPDRtpp -1000 1000 0 12ppd__… (R)-Propane… "" #> 10 12PPDStex -1000 1000 0 12ppd__… (S)-Propane… "b0241 | b0929… #> # … with 2,573 more rows, and 2 more variables: subsystem <chr>, present <dbl>