brainconn icon indicating copy to clipboard operation
brainconn copied to clipboard

brainconn(): edge.color cannot be changed with edge.color.weighted = T

Open jzhangc opened this issue 3 years ago • 6 comments

When edge.color.weighted set to TRUE, the edge color would always be the default "blue" no matter what other colours are set.

jzhangc avatar May 23 '21 22:05 jzhangc

Hi - thanks for pointing this out! I will add an option to allow for color scales to be entered when using edge.color.weighted. In the meantime, here is a workaround to include colour scales using ggraph's "scale_edge_colour*":

library(brainconn) conmat <- brainconn::example_weighted_undirected brain <- brainconn(atlas = 'schaefer300_n7', conmat = conmat, edge.color.weighted = T) brain + scale_edge_colour_gradient2(low='yellow', mid='orange', high='red')

image

brain + scale_edge_colour_distiller(palette = 2) image

brain + scale_edge_colour_viridis() image

brain + scale_edge_colour_gradientn(colours = pals::parula()) image

See here for more options and detials.

Thanks and let me know if there is anything else you need.

sidchop avatar May 24 '21 00:05 sidchop

Hello, I tried using this fix for the weighted scale today but it doesn't seem to override the default blue scale for me. This is the code I'm using:

c_serum_brain <- brainconn(atlas = custom_atlas, conmat = c_serum, node.size = 1.5, view = "ortho", edge.width = 1, edge.color.weighted = T)

c_serum_brain + scale_edge_colour_gradient2(low='yellow', mid='orange', high='red')

I tried restarting R, using a different conmat, and trying all the scales above but still had the same blue scale output. Just wanted to check in and see if anything had been updated since this initial post! Thanks!

hgrotzin avatar Feb 18 '22 18:02 hgrotzin

I haven't incorporated this feature into brainconn yet, but the fix above should still work. If you want to attach your custom_atlas and conmat - ill take a look.

sidchop avatar Feb 18 '22 19:02 sidchop

Great, thanks so much! This is the custom atlas: node_coords.csv

and this is one of the connectivity matrices I'm analyzing: 28andHe_CSerum.csv

hgrotzin avatar Feb 18 '22 21:02 hgrotzin

Hi - this was indeed a bug with the "ortho" view.

I have now fixed this and changed the code to allow for any "scale_edge_colour*" function from ggraph to be directly passed to edge_color, if edge.color.weighted = T. Try reinstalling the package, and trying the below:

brainconn(atlas = custom_atlas, conmat = c_serum, node.size = 1.5, view = "ortho", edge.width = 0.8, edge.color.weighted = T, edge.color = scale_edge_colour_gradient2(low='yellow', mid='orange', high='red'))

sidchop avatar Feb 18 '22 22:02 sidchop

yes that worked! thank you so much for your help

hgrotzin avatar Feb 18 '22 23:02 hgrotzin