egeulgen / pathfindR

pathfindR: Enrichment Analysis Utilizing Active Subnetworks
https://egeulgen.github.io/pathfindR/
Other
177 stars 25 forks source link

term_gene_graph() function: V(g)$color doing work that aes() and scale_color_manual() should do #184

Closed rafalcode closed 7 months ago

rafalcode commented 7 months ago

Not so much a bug but a lack of efficient best practice perhaps, (found because I was trying to change colours in term_gene_graph() function) but this idea of creating a new attribute in V(g) called color based on V(g)$term and using it in the aes() for geom_node_point() is not too great an idea simply because that is the job of aes() and then scale_color_manual() in the first place. The creation of this color attribute is unnecessary because by defining the aes() on term like so

i.e. p <- p + ggraph::geom_node_point(ggplot2::aes(color=.data$type, size=.data$size)

then

scale_color_manual(value=

can be assigned to the three colours. As I say, it's not a bug, but it obscures a major part of ggplot2's philosophy, the whole aes() concept, "Grammar of Graphics" etc.