New columns from extra attributes
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 sourc…¹ targe…² is_di…³ is_st…⁴ is_in…⁵ conse…⁶ conse…⁷ conse…⁸
#> <chr> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 P0DP25 P48995 CALM3 TRPC1 1 0 1 1 0 1
#> 2 P0DP23 P48995 CALM1 TRPC1 1 0 1 1 0 1
#> 3 P0DP24 P48995 CALM2 TRPC1 1 0 1 1 0 1
#> 4 Q03135 P48995 CAV1 TRPC1 1 1 0 1 1 0
#> 5 P14416 P48995 DRD2 TRPC1 1 1 0 1 1 0
#> 6 Q99750 P48995 MDFI TRPC1 1 0 1 1 0 1
#> 7 Q14571 P48995 ITPR2 TRPC1 1 1 0 1 1 0
#> 8 P29966 P48995 MARCKS TRPC1 1 0 1 1 0 1
#> 9 Q13255 P48995 GRM1 TRPC1 1 1 0 1 1 0
#> 10 Q13586 P48995 STIM1 TRPC1 1 1 0 1 1 0
#> # … with 40,004 more rows, 8 more variables: extra_attrs <list>, sources <chr>,
#> # references <chr>, curation_effort <dbl>, n_references <dbl>,
#> # n_resources <int>, Cellinker_type <chr>, Macrophage_type <list>, and
#> # abbreviated variable names ¹source_genesymbol, ²target_genesymbol,
#> # ³is_directed, ⁴is_stimulation, ⁵is_inhibition, ⁶consensus_direction,
#> # ⁷consensus_stimulation, ⁸consensus_inhibition
extra_attrs_to_cols(
i,
Cellinker_type,
Macrophage_type,
flatten = TRUE,
keep_empty = FALSE
)
#> # A tibble: 4,202 × 18
#> source target sourc…¹ targe…² is_di…³ is_st…⁴ is_in…⁵ conse…⁶ conse…⁷ conse…⁸
#> <chr> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 Q16539 P49137 MAPK14 MAPKAP… 1 1 0 1 1 0
#> 2 Q16539 P49137 MAPK14 MAPKAP… 1 1 0 1 1 0
#> 3 O60674 P19235 JAK2 EPOR 1 1 0 1 1 0
#> 4 Q9Y219 P46531 JAG2 NOTCH1 1 1 1 1 1 0
#> 5 O00548 P46531 DLL1 NOTCH1 1 1 0 1 1 0
#> 6 O15111 P19838 CHUK NFKB1 1 1 1 1 0 1
#> 7 P05019 P08069 IGF1 IGF1R 1 1 0 1 1 0
#> 8 P78504 P46531 JAG1 NOTCH1 1 1 1 1 1 0
#> 9 Q14164 Q92985 IKBKE IRF7 1 1 0 1 1 0
#> 10 Q13490 P42574 BIRC2 CASP3 1 0 1 1 0 1
#> # … with 4,192 more rows, 8 more variables: extra_attrs <list>, sources <chr>,
#> # references <chr>, curation_effort <dbl>, n_references <dbl>,
#> # n_resources <int>, Cellinker_type <chr>, Macrophage_type <chr>, and
#> # abbreviated variable names ¹source_genesymbol, ²target_genesymbol,
#> # ³is_directed, ⁴is_stimulation, ⁵is_inhibition, ⁶consensus_direction,
#> # ⁷consensus_stimulation, ⁸consensus_inhibition