Skip to contents

New columns from extra attributes

Usage

extra_attrs_to_cols(data, ..., flatten = FALSE, keep_empty = TRUE)

Arguments

data

An interaction data frame.

...

The names of the extra attributes; NSE is supported. Custom column names can be provided as argument names.

flatten

Logical: unnest the list column even if some records have multiple values for the attributes; these will yield multiple records in the resulted data frame.

keep_empty

Logical: if `flatten` is `TRUE`, shall we keep the records which do not have the attribute?

Value

Data frame with the new column created; the new column is list type if one interaction might have multiple values of the attribute, or character type if

Examples

i <- import_omnipath_interactions(fields = 'extra_attrs')
extra_attrs_to_cols(i, Cellinker_type, Macrophage_type)
#> # A tibble: 81,529 × 18
#>    source target source_genesymbol target_genesymbol is_directed is_stimulation
#>    <chr>  <chr>  <chr>             <chr>                   <dbl>          <dbl>
#>  1 P0DP23 P48995 CALM1             TRPC1                       1              0
#>  2 P0DP25 P48995 CALM3             TRPC1                       1              0
#>  3 P0DP24 P48995 CALM2             TRPC1                       1              0
#>  4 Q03135 P48995 CAV1              TRPC1                       1              1
#>  5 P14416 P48995 DRD2              TRPC1                       1              1
#>  6 Q99750 P48995 MDFI              TRPC1                       1              0
#>  7 Q14571 P48995 ITPR2             TRPC1                       1              1
#>  8 P29966 P48995 MARCKS            TRPC1                       1              0
#>  9 Q13255 P48995 GRM1              TRPC1                       1              1
#> 10 Q13586 P48995 STIM1             TRPC1                       1              1
#> # ℹ 81,519 more rows
#> # ℹ 12 more variables: is_inhibition <dbl>, consensus_direction <dbl>,
#> #   consensus_stimulation <dbl>, consensus_inhibition <dbl>,
#> #   extra_attrs <list>, sources <chr>, references <chr>, curation_effort <dbl>,
#> #   n_references <int>, n_resources <int>, Cellinker_type <chr>,
#> #   Macrophage_type <list>
extra_attrs_to_cols(
    i,
    Cellinker_type,
    Macrophage_type,
    flatten = TRUE,
    keep_empty = FALSE
)
#> # A tibble: 4,196 × 18
#>    source target source_genesymbol target_genesymbol is_directed is_stimulation
#>    <chr>  <chr>  <chr>             <chr>                   <dbl>          <dbl>
#>  1 Q16539 P49137 MAPK14            MAPKAPK2                    1              1
#>  2 O60674 P19235 JAK2              EPOR                        1              1
#>  3 Q9Y219 P46531 JAG2              NOTCH1                      1              1
#>  4 O00548 P46531 DLL1              NOTCH1                      1              1
#>  5 O15111 P19838 CHUK              NFKB1                       1              1
#>  6 P05019 P08069 IGF1              IGF1R                       1              1
#>  7 P78504 P46531 JAG1              NOTCH1                      1              1
#>  8 Q14164 Q92985 IKBKE             IRF7                        1              1
#>  9 Q13490 P42574 BIRC2             CASP3                       1              0
#> 10 Q13490 P42574 BIRC2             CASP3                       1              0
#> # ℹ 4,186 more rows
#> # ℹ 12 more variables: is_inhibition <dbl>, consensus_direction <dbl>,
#> #   consensus_stimulation <dbl>, consensus_inhibition <dbl>,
#> #   extra_attrs <list>, sources <chr>, references <chr>, curation_effort <dbl>,
#> #   n_references <int>, n_resources <int>, Cellinker_type <chr>,
#> #   Macrophage_type <list>