Figure 22 in BrainGraph help guide...

5 views
Skip to first unread message

Daniel J. King

unread,
Feb 17, 2017, 7:51:11 AM2/17/17
to brainGraph-help
Hi Chris,

Your help guide has some great figures in it, but the ones I am interested in at the moment is the adjacency matrices (figure 22). I have checked through the PDF and the cran package manual but can't seem to find a function to produce these, was it a separate plotting function?

Thanks again,
Best wishes
Dan

Chris Watson

unread,
Feb 17, 2017, 9:47:04 AM2/17/17
to brainGr...@googlegroups.com
Thank you, I am glad they are helpful. That specific plot is from the function "plot_corr_mat". The code can be found in the block on page 44 in Chapter 5.10.1. It is the 4th command in the block, specifically:
plot_corr_mat(corrs[[2]][[10]]$r.thresh, type='lobe', g=g[[2]][[10]], group=groups[2])

1. The first arguments is the thresholded (binarized) adjacency matrix for group 2, threshold/density 10
2. The second argument is the "type" of vertex attribute to color the cells by. In this case I chose "lobe". Other options are "comm" and "comm.wt" (for unweighted and weighted community membership) and "network" (which only works for the "dosenbach160" atlas that has a "network" attribute, e.g. default mode, sensorimotor, etc.).
3. The third argument is the associated graph, here for group 2 & threshold/density 10. It is required to get those vertex attributes.
4. The fourth argument is optional and is what places "Patient" in the title; i.e., it is the group name. You could also leave this blank and then add your own title if you wish, e.g.,
plot_corr_mat(corrs[[2]][[10]]$r.thresh, type='lobe', g=g[[2]][[10]]) + labs(title='My Group')

Chris

--
You received this message because you are subscribed to the Google Groups "brainGraph-help" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brainGraph-help+unsubscribe@googlegroups.com.
To post to this group, send email to brainGraph-help@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brainGraph-help/3d27ae13-0319-4d04-b667-a64a5e46936c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel J. King

unread,
Feb 17, 2017, 10:16:31 AM2/17/17
to brainGraph-help, cwa...@alum.mit.edu
What if you wanted to generate a weighted adjacency matrix based on the strength of correlations between residuals?


On Friday, February 17, 2017 at 2:47:04 PM UTC, Chris Watson wrote:
Thank you, I am glad they are helpful. That specific plot is from the function "plot_corr_mat". The code can be found in the block on page 44 in Chapter 5.10.1. It is the 4th command in the block, specifically:
plot_corr_mat(corrs[[2]][[10]]$r.thresh, type='lobe', g=g[[2]][[10]], group=groups[2])

1. The first arguments is the thresholded (binarized) adjacency matrix for group 2, threshold/density 10
2. The second argument is the "type" of vertex attribute to color the cells by. In this case I chose "lobe". Other options are "comm" and "comm.wt" (for unweighted and weighted community membership) and "network" (which only works for the "dosenbach160" atlas that has a "network" attribute, e.g. default mode, sensorimotor, etc.).
3. The third argument is the associated graph, here for group 2 & threshold/density 10. It is required to get those vertex attributes.
4. The fourth argument is optional and is what places "Patient" in the title; i.e., it is the group name. You could also leave this blank and then add your own title if you wish, e.g.,
plot_corr_mat(corrs[[2]][[10]]$r.thresh, type='lobe', g=g[[2]][[10]]) + labs(title='My Group')

Chris
On Fri, Feb 17, 2017 at 6:51 AM, Daniel J. King <daniel...@gmail.com> wrote:
Hi Chris,

Your help guide has some great figures in it, but the ones I am interested in at the moment is the adjacency matrices (figure 22). I have checked through the PDF and the cran package manual but can't seem to find a function to produce these, was it a separate plotting function?

Thanks again,
Best wishes
Dan

--
You received this message because you are subscribed to the Google Groups "brainGraph-help" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brainGraph-he...@googlegroups.com.
To post to this group, send email to brainGr...@googlegroups.com.

Chris Watson

unread,
Feb 17, 2017, 12:34:59 PM2/17/17
to brainGr...@googlegroups.com
Do you mean you would like to produce a similar figure, but with the color scale of the cells reflecting the correlation coefficient? It is possible but not with that function (unless I update it).

I can send you some code later today that would do it. However, I remember that in the past I was unhappy with the color scale in such a plot, but I will come up with a solution and you can determine if it is close to what you're looking for.

Chris

To unsubscribe from this group and stop receiving emails from it, send an email to brainGraph-help+unsubscribe@googlegroups.com.
To post to this group, send email to brainGraph-help@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brainGraph-help/a5df5204-841d-4fa4-90ae-be0e222a9bfd%40googlegroups.com.

Chris Watson

unread,
Feb 17, 2017, 1:50:09 PM2/17/17
to brainGr...@googlegroups.com
Try the following code and see the attached figures. Figs 1-2 are from the first ggplot command, and Figs 3-4 are the second.

corrs.m <- setDT(melt(corrs[[1]][[1]]$R))
corrs.m[Var1 == Var2, value := 0]

ggplot(corrs.m, aes(x=Var1, y=Var2, fill=value)) + geom_tile() + scale_fill_gradient2(low='blue', high='red', midpoint=0, limits=c(-1, 1), name='Correlation\ncoefficient')
Or:
ggplot(corrs.m, aes(x=Var1, y=Var2, fill=value)) + geom_tile() + scale_fill_gradient(low='yellow', high='red', limits=c(-1, 1), name='Correlation\ncoefficient')


You may also try each of the above after removing "limits=c(-1, 1)". These are in Figures 2 and 4. Let me know if this was what you were looking for.
Chris
corrmat1.png
corrmat2.png
corrmat3.png
corrmat4.png

Daniel J. King

unread,
Feb 20, 2017, 5:42:17 AM2/20/17
to brainGraph-help, cwa...@alum.mit.edu
Hi Chris,

That was exactly what I was looking for thanks! I see what you mean re. the colours, a little difficult to interpret! I will have a go with these and see how it goes.

Thanks again!

Dan

Chris Watson

unread,
Feb 23, 2017, 2:47:59 PM2/23/17
to brainGr...@googlegroups.com
There are other color scales (called "palettes" in R) that you can investigate yourself. Or you can play around with different "high" and "low" values.
You can do a search for e.g.
* R color palette ggplot2
* R ggplot2 heatmap rainbow    # "rainbow" is the name of one of the color palettes
* R ggplot2 geom_tile palette    # "geom_tile" is the "geometry" function of ggplot2 that plots a matrix in the way you want it

and so on.

Chris

To unsubscribe from this group and stop receiving emails from it, send an email to brainGraph-help+unsubscribe@googlegroups.com.
To post to this group, send email to brainGraph-help@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brainGraph-help/e816bcc0-5b36-4710-89c0-8fdf355d2266%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages