fg_add_feature: Adds a feature.

View source: R/01_flowgraph_modifiers.R

fg_add_featureR Documentation

Adds a feature.

Description

Adds a feature created using feat_fun from fg OR m into a given flowGraph object. Only use this function if you cannot generate the desired features using the existing flowGraph functions starting with fg_feat_<feature name>.

Usage

fg_add_feature(
  fg,
  type = "node",
  feature,
  m = NULL,
  feat_fun = NULL,
  overwrite = FALSE,
  ...
)

Arguments

fg

flowGraph object.

type

A string specifying the type of the feature being added i.e. 'node' or 'edge'.

feature

A string indicating the unique name of the feature added.

m

A numeric matrix with feature values; it should contain the same sample id's on row names as in fg_get_meta(fg)$id and node or edge names as column names (i.e. if m is a node feature, it would have the same column names as those in fg_get_graph(fg)$v$phenotype; if it is an edge feature, its column names should be the same as paste0(fg_get_graph(fg)$e$from, '_', fg_get_graph(fg)$e$to)).

feat_fun

A function that ouputs a feature matrix as in m given fg and other optional parameters.

overwrite

A logical variable indicating whether or not the function should replace the existing feature with the same name if one is already in fg.

...

Other parameters that would be used as input into feat_fun.

Details

fg_add_feature adds the given new feature matrix to the given flowGraph object fg updating slots feat and feat_desc. See flowGraph-class slot feat and feat_desc for what should be in these slots. We do not recommend users to directly use this method unless there is a clear understanding on how the row and column names should be specified. Instead, we recommend users to use the functions listed in the "See also" sections prefixed with "fg_feat_".

Value

flowGraph object.

See Also

flowGraph-class fg_feat_node_prop fg_feat_node_specenr fg_get_feature fg_rm_feature fg_get_feature_desc

Examples


 no_cores <- 1
 data(fg_data_pos30)
 fg <- flowGraph(fg_data_pos30$count, class=fg_data_pos30$meta$class,
                 prop=FALSE, specenr=FALSE,
                 no_cores=no_cores)
 fg_get_feature_desc(fg)

 fg <- fg_add_feature(fg, type="node", feature="count_copy",
                      m=fg_data_pos30$count)
 fg_get_feature_desc(fg)


aya49/flowGraph documentation built on Feb. 4, 2024, 6:40 p.m.