= matrix(c(1, 0,
grp_matrix 0, 1), nrow = 2, ncol = 2)
<- nrow(grp_matrix)
n_grp <- rainbow_hcl(ncol(grp_matrix), c = 100)
use_color <- length(use_color)
n_color = color
use_color # defines how many pie segments are needed, common to all the pie-charts
<- rep(1 / n_color, n_color)
pie_area names(pie_area) <- rep("", n_color)
<- desaturate(use_color)
desat_color names(desat_color) <- names(use_color)
<- purrr::map_dfr(rownames(grp_matrix), function(i_grp){
piechart_strings <- grp_matrix[i_grp, ]
tmp_logical <- use_color
tmp_color
# add the proper desaturated versions of the colors
!tmp_logical] <- desat_color[!tmp_logical]
tmp_color[
= paste0('piechart: attributelist="',
out_str paste(colnames(grp_matrix), collapse = ','),
'" ',
'colorlist="',
paste(tmp_color, collapse = ','),
'" ',
'arcstart=-90 showlabels=false')
data.frame(colorlist = out_str)
})
= as.data.frame(matrix(1, nrow = nrow(piechart_strings),
tmp_matrix ncol = ncol(grp_matrix)))
names(tmp_matrix) = colnames(grp_matrix)
= cbind(tmp_matrix, piechart_strings)
piechart_df
# after merging this with the node information to
# put the right things with the right node
# this gives **node_vis_df** below
::setNodeShapeDefault("ELLIPSE")
RCy3::setNodeSizeDefault(35)
RCy3::loadTableData(node_vis_df, data.key.column = "name", table = "node", table.key.column = "name")
RCy3::updateStyleMapping("default",
RCy3::mapVisualProperty("NODE_CUSTOMGRAPHICS_1", "colorlist", "p")) RCy3
I have a package, {categoryCompare2}
(Flight 2022) that I’ve been working on for a while, and recently wanted to make available on our labs r-universe (“The ’Moseleybioinformaticslab’ Universe,” n.d.).
For some of the current visualization, we use Cytoscape to examine annotation similarity graphs, coupling the R together with Cytoscape via {RCy3}
(Gustavsen et al. 2019). In the previous iteration, we had used actual piechart images generated by R, and then used setNodeImageDirect
to point the node images to local image files.
However, the latest iteration of {RCy3}
has essentially lost that functionality. However, there is a new visualization plugin that can do similar things, enhancedGraphics (Morris JH 2014).
Alexander Pico, one of the primary {RCy3}
developers, provided me with the guidance for a code solution (Pico 2022), which I’ve adapted below.
References
Reuse
Citation
@online{mflight2022,
author = {Robert M Flight},
title = {Pie {Charts} in {RCy3}},
date = {2022-01-06},
url = {https://rmflight.github.io/posts/2022-01-06-pie-charts-in-rcy3},
langid = {en}
}