Handle igraph attribute parameter list, internal function for jam_igraph()

handle_igraph_param_list(
  x,
  attr,
  factor_l,
  i_values = NULL,
  attr_type = c("node", "vertex", "edge"),
  verbose = FALSE,
  ...
)

Arguments

x

igraph object

attr

character name of the attribute to update in x.

factor_l

list or numeric vector or function:

  • list of numeric vectors where names(factor_l) correspond to attribute names, and the names of numeric vectors are attribute values The attribute names and attribute values are used to match relevant entities of type attr_type. For matching entities, attribute values are used as defined by attribute name attr, and are multiplied by the matching numeric value in factor_l.

  • numeric vector which is directly multiplied by i_values to produce an adjusted output vector i_values.

  • function which is used to modify i_values by calling factor_l(i_values) to produce adjusted output i_values.

i_values

vector of attribute values that represent the current attribute values in x for the attribute attr.

attr_type

character string indicating the type of entity being adjusted in x:

...

additional arguments are ignored.

Value

vector of attribute values representing attr.

Details

This mechanism is intended to help update igraph attributes in bulk operations by the attribute values associated with nodes or edges. Most commonly, the argument factor_l is multiplied by numeric attributes to scale attribute values, for example label font size, or node size.

For example:

handle_igraph_param_list(x,
   attr="size",
   factor_l=list(nodeType=c(Gene=1, Set=2)),
   i_values=rep(1, igraph::vcount(x)),
   attr_type="node")

This function call will match node attribute nodeType, the size of nodes with attribute value nodeType="Set" are multiplied size * 2, nodeType="Gene" are multiplied size * 1.