Testing an empirical brain network for rich club characteristics

6 views
Skip to first unread message

B Drury

unread,
Mar 7, 2017, 5:37:23 PM3/7/17
to brainGraph-help

Hi Chris,


We’re trying to use brainGraph to determine if a brain network identified by our study has rich club characteristics. We're having a lot of problems. Answers to the following questions would help us a lot:


(1) What exactly is the format of the network object required as the first input to rich.club.norm() ?

      The relevant man page suggests any valid igraph object would do.  So we tested the behavior of rich.club.norm() using some valid demo igraph objects (see the R code at the very bottom of this note.) But we get the following error
             > my.results<-rich.club.norm(net, N = 100, rand = NULL, weighted=FALSE) # Where 'net' is a valid igraph graph object


             > Error in { : task 1 failed - "result would be too long a vector"


So it seems that not every igraph object would do. How should we re-format our network?


(2) How to pass the last argument ('Other parameters') to  rich.club.norm() ?

 The man page says:

                 ... Other parameters (passed to rich.club.coeff)


What exactly does that mean?  For instance, should we pass the arguments to rich.club.coeff(), and then include the output object of rich.club.coeff() as the last input to rich.club.norm()?


(3) Finally, a general question that subsumes the above two: Is there example code/tutorial that explains, in a step-by-step fashion, how one would go about testing whether a given brain network can be characterized as rich club or not?


Thank you very much,

Brianna


#############################################################################################################

#Sample R test code to test the behavior of rich.club.norm() :

               library("igraph")

               library("brainGraph")

 

               #Code copied from section 3.2 of the web page http://kateto.net/networks-r-igraph.htm (path added by me).

               nodes2 <- read.csv("C:/lab/network/igraph/netscix2016/Dataset2-Media-User-Example-NODES.csv", header=T, as.is=T)

               links2 <- read.csv("C:/lab/network/igraph/netscix2016/Dataset2-Media-User-Example-EDGES.csv", header=T, row.names=1)

               links2 <- as.matrix(links2)

 

               net <- graph_from_incidence_matrix(links2)

              

               my.results<-rich.club.norm(net, N = 100, rand = NULL, weighted=FALSE)

              

#############################################################################################################

Chris Watson

unread,
Mar 7, 2017, 6:32:14 PM3/7/17
to brainGr...@googlegroups.com
Hi Brianna,

1. Thanks for reporting the bug. This was a silly oversight. It looks like my code expects the vertices to have a "degree" attribute without checking beforehand. So (until I push the update to Github, which might be awhile), please use the following code:
V(net)$degree <- degree(net)

2. The ellipsis (triple dots) is just a "shorthand" for a list/set of multiple arguments. In this case, really the only useful argument to include would be "weighted". And since FALSE is the default, you only have to specify "weighted=TRUE" if you care about edge weights. Your function call in the sample test code is correct.

3. Have you seen the User Guide? You can get it from (you will be asked to download a PDF): https://dl.dropboxusercontent.com/s/wmupawb39bcdho3/brainGraph_UserGuide.pdf
See Chapters 5.5 and 5.7 specifically.

Let me know if the function runs (I tested it on my computer and it works for me). And feel free to ask any more questions.

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/5ee94853-cb52-4844-80a3-3ddb3e87994a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

B Drury

unread,
Mar 7, 2017, 9:44:48 PM3/7/17
to brainGraph-help
Hi Chris,

Thank you very much for the prompt reply.  We greatly appreciate it.  Yes, we do have the self-same version of the User's Guide, but we were flummoxed.

As to the additional/optional arguments, we were confused because we couldn't make rich.club.norm() work with our network to being with.  So we started wondering whether the ellipses somehow had an unconventional meaning.

The fix you suggested works great with the network in question,  But when I replace the previously mentioned demo network with our actual brain network (with your fix in place, of course), I get the following error:

   Error in { :
     task 1 failed - "At gengraph_graph_molloy_optimized.cpp:380 : Error in graph_molloy_opt::havelhakimi(): Couldn't bind vertex 3
     entirely (12 edges remaining), Internal error, likely a bug in igraph"


FYI, our network is constructed as follows:

    edges.df<-data.frame(source.ROIs, target.ROIs, edge.weights) #  'source.ROIs' and 'target.ROIs' are character vectors, and 'edge.weights' is a float vector
    roinames.df<-data.frame(ROI.names) # ROI.names is a character vector
    net <- graph_from_data_frame(d=edges.df, vertices=roinames.df, directed=T)
    V(net)$degree <- degree(net) #This is the fix you suggested

If you'd like to check this out yourself, we can upload our data here or email it to you, as you prefer. Please let us know if you'd like us to do that.

Thank you once again for your help,
Brianna

Chris Watson

unread,
Mar 8, 2017, 12:56:16 AM3/8/17
to brainGr...@googlegroups.com
Yes, please send me the data as I have not seen that error before. It is probably easiest to save the R objects as a ".rda" or ".RData" file, using the "save" function. You can attach it here, or if it's a very large file email me directly.

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.

Chris Watson

unread,
Mar 8, 2017, 12:56:38 PM3/8/17
to brainGr...@googlegroups.com
Also, I am curious why you set "directed" to "TRUE". In standard/typical (human brain MRI) analyses, you cannot infer directions. This might be part of the problem as I never developed any code with directed graphs in mind.

B Drury

unread,
Mar 8, 2017, 3:18:13 PM3/8/17
to brainGraph-help, cwa...@alum.mit.edu
Hi Chris,

I've attach the network as an RDS file.

I talked with a postdoc in the lab (I'm a student) why this should be a directed network. He said that's because this is a multivariate Granger Causality network, and the connections identified by Granger Causality are directional and weighted.  He said he thought it would be OK to treat this as an undirected, unweighted adjacency matrix if we must do so for analytical purposes, except that we'd lose some of the information.

Also, I tried running my script with "directed" to "FALSE", and I got the same error.

Best,
Brianna
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.
net.rds

Chris Watson

unread,
Mar 8, 2017, 4:18:05 PM3/8/17
to brainGr...@googlegroups.com
Thanks for sending. I have a subject coming in for MRI now so I can't respond more fully, but this should tide you over.

The issue was not (specifically) that the network was directed. it was in the method that was used to generate the random graphs (the "vl" method of the function "sample_degseq"; see the help page). I also didn't realize that your network is not "simple"; i.e., it has multi-edges. I never wrote any functions with that feature in mind but I think most of them should work still. If you want to simplify your graph then you can do:
net <- simplify(net)

To generate your own random graphs (try both directed and undirected), do something like this: (use "foreach" for speed if you have multiple cores, but this will be fast as your network is small)
my.rand <- vector('list', length=100)
for (i in 1:100) {
  my.rand[[i]] <- rewire(net, keeping_degseq(loops=F, niter=1e3*ecount(net)))
  my.rand[[i]] <- set.brainGraph.attributes(my.rand[[i]], rand=TRUE)
}

Then supply that to "rich.club.norm". However, I can't guarantee what will happen if the networks are directed; I am sure the algorithm should be different. Tore Opsahl's package "tnet" might have a function to do that, you can check out his personal website for more info.

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/7c49a29c-7be3-41b9-a161-1dc12eb76f75%40googlegroups.com.

B Drury

unread,
Mar 8, 2017, 10:10:25 PM3/8/17
to brainGr...@googlegroups.com
Hi Chris,

Thank you very much for your suggestions. Using simplify() as you suggested does eliminate the error, i.e., rich.club.norm() executes without error.  FYI, your code for creating the our own random graphs also works.  Thank you so much!  Also, please consider this issue resolved.

About your suggestion that we try the tnet package, I talked to my boss, and he said it would be a great idea to check it out.  So we greatly appreciate your suggestion.

Best regards,
Brianna

--
You received this message because you are subscribed to a topic in the Google Groups "brainGraph-help" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/brainGraph-help/j3-2tXxDhvE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to brainGraph-help+unsubscribe@googlegroups.com.

To post to this group, send email to brainGraph-help@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages