Apply Cnet border color by directionality
Source:R/jamenrich-apply-cnet-direction.R
apply_cnet_direction.RdApply Cnet border color by directionality
Usage
apply_cnet_direction(
cnet,
hitim = NULL,
col = circlize::colorRamp2(breaks = c(-1, 0, 1), colors = c("blue", "grey80",
"firebrick3")),
col_l_max = 80,
hide_solo_pie = TRUE,
frame_blank = default_igraph_values()$vertex$frame.color,
frame_lwd_blank = 0.2,
border_lwd = 2,
do_reorder = FALSE,
verbose = FALSE,
...
)Arguments
- cnet
igraphobject with node attribute"pie.color"populated as alistofcharactervectors, named by enrichment. The enrichment names should matchcolnames(hitim).- hitim
numericmatrix with values centered at zero for no change, positive values+1for up-regulation, and negative values-1for down-regulation. The values are converted to color using color functioncol.- col
functionthat takesnumericinput and assigns a color. The default assigns red for positive values, blue for negative values, and white for zero, usingcolorjam::col_div_xf(1.2).- col_l_max
numericmaximum HCL Lightness, default 80, for output colors. For example, the middle color in"RdBu_r"is nearly white, thecol_l_maxcan be used to apply a darker grey.- hide_solo_pie
logicaldefault TRUE, whether a single-color border for a multi-part pie node should only apply the color to the overall node with 'frame.color', and not apply the color to each pie wedge using 'pie.border'.Default
hide_solo_pie=TRUE: when all wedges (one or more) have the samepie.bordercolor, the 'pie.border' is defined asNA, and 'frame.color' is assigned to this color. The effect is to display the outline color and not each wedge. Both 'pie.lwd' and 'frame.lwd' will be assignedborder_lwd, and since 'pie.border' isNAit will not be rendered. Only the 'frame.color' will be rendered.When
hide_solo_pie=FALSEeach pie wedge border color is assigned to 'pie.border',frame.colorwill be assigned 'frame_blank', and 'frame.lwd' will be assigned 'frame_lwd_blank' which is useful for displaying a small outer frame for each node.
- frame_blank
characterstring to define the color used for 'frame.color' when colors are defined in 'pie.border'. The default uses the igraph defaults, currently 'black'. In this case, the frame is drawn around the innerpie.bordercolors, and only serves to add visual clarity. The frame border can be blankframe_blank="transparent"or can be a thinner line, controlled withframe_lwd_blank=0.2.- frame_lwd_blank
numericline width, default 0.2, for nodes that have "blank" frame, which also means the 'pie.border' colors must also defined. In this case the frame border can be invisible (frame_lwd_blank=0) or a very thin line (defaultframe_lwd_blank=0.2) to surround the inner borders drawn with 'pie.border'.- border_lwd
numericline width, default 2, used when a node matchesrownames(hitim). When the colors are applied to 'pie.color', the border is defined with 'pie.lwd'. When colors are applied to 'frame.color', the border is defined with 'frame.lwd'.- do_reorder
logicaldefault FALSE, whether to reorder nodes by node attributes such as color and border, by callingreorder_igraph_nodes(). Whendo_reorder=TRUE, other relevant arguments are passed through...toreorder_igraph_nodes()in particular:colorV: to control the expected order of colors. It should be supplied if known upfront.sortAttributes: to customize the default attribute sort order.nodeSortBy: to customize the x-/y- axis arrangement.orderByAspect: to enable x-/y- sorting by the aspect ratio of nodes in the group. For example, tall-skinny node groups should sort by y-axis first, short-wide node groups should sort by x-axis first.
- ...
additional arguments are passed to
reorder_igraph_nodes()whendo_reorder=TRUE.
Details
This function specifically requires the "pie.color"
node attribute of the cnet object igraph is populated
with a list of colors whose name is the enrichment,
and matches colnames(hitim) of the supplied hit
incidence matrix.
The node names V(cnet)$name also must match rownames(hitim),
otherwise the "pie.border" and "coloredrect.border" is assigned
its previous value.
In that case "frame.color" retains its original value.
This function may be run multiple times with different hitim,
for example using geneIMdirection and enrichIMdirection in two steps.
When there are multiple colors for a given node, they are populated in
node attributes "pie.border" in list form. For these nodes,
the attribute "frame.color" is set to NULL so it is not displayed
on top of the pie wedge colors.
When there are no matching rownames(hitim), or all colors
are identical, the "pie.border" is populated with NULL,
so the pie wedges do not each show a color. Also for single-wedge
pie nodes, this process avoids drawing a small line at the top
of each node.
Instead the attribute "frame.color" is populated with the
one unique border color, so that only the outer border is colorized.
See also
Other jam cnet igraph functions:
rotate_igraph_layout()