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: 40,014 × 18
#>    source target source_genesymbol target_genesymbol is_directed is_stimulation
#>    <chr>  <chr>  <chr>             <chr>                   <dbl>          <dbl>
#>  1 P0DP25 P48995 CALM3             TRPC1                       1              0
#>  2 P0DP23 P48995 CALM1             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
#> # … with 40,004 more rows, and 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 <chr>,
#> #   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,202 × 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 Q16539 P49137 MAPK14            MAPKAPK2                    1              1
#>  3 O60674 P19235 JAK2              EPOR                        1              1
#>  4 Q9Y219 P46531 JAG2              NOTCH1                      1              1
#>  5 O00548 P46531 DLL1              NOTCH1                      1              1
#>  6 O15111 P19838 CHUK              NFKB1                       1              1
#>  7 P05019 P08069 IGF1              IGF1R                       1              1
#>  8 P78504 P46531 JAG1              NOTCH1                      1              1
#>  9 Q14164 Q92985 IKBKE             IRF7                        1              1
#> 10 Q13490 P42574 BIRC2             CASP3                       1              0
#> # … with 4,192 more rows, and 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 <chr>,
#> #   n_resources <int>, Cellinker_type <chr>, Macrophage_type <chr>