Skip to contents

Wrapper function around tidyr's pivot_longer() function to facilitate the easy transformation into the correct data format for MiCo construction.

Usage

pivotMiCo(tb, species, from, to, flux)

Arguments

tb

Tibble with data on a microbial community in long or short format to be

species

Column name of the species column

from

the name of the column specifying the met consumed

to

the name of the column specifying the met excreted

flux

Column name of the flux column

Examples

tb <- tibble::tribble(
  ~uptake, ~secretion, ~flux, ~species,
  "m1", "m2", 1, "s1",
  "m2", "m3", 1, "s2",
  "m3", "m4", 1, "s3",
  "m4", "m1", 1, "s4")

pivotMiCo(
    tb = tb,
    species = "species",
    from = "uptake",
    to = "secretion",
    flux = "flux")
#> # A tibble: 8 × 3
#>   species metabolite  flux
#>   <chr>   <chr>      <dbl>
#> 1 s1      m1            -1
#> 2 s1      m2             1
#> 3 s2      m2            -1
#> 4 s2      m3             1
#> 5 s3      m3            -1
#> 6 s3      m4             1
#> 7 s4      m4            -1
#> 8 s4      m1             1