Computing small.world coefficient

58 views
Skip to first unread message

Brian Kim

unread,
Dec 14, 2020, 3:57:34 PM12/14/20
to brainGraph-help
I am trying to compute the small world coefficient and am running into two issues.

When I try to run analysis_random_graphs, the function runs smoothly until the progress bar shows 100% at which point my RStudio Session aborts. It doesn't show any error message, so I am not sure how to proceed in debugging.

I'm only interested in computing the sigma coefficient, so as an alternative, I tried to compute the small world coefficient by using the small.world function as follows:

testGraph = g.all.sub[[1]]$graphs[[1]]
randomGraphs = sim.rand.graph.par(testGraph, N=100, clustering=FALSE)
dt.small = small.world(testGraph, randomGraphs)

The randomGraphs is generated correctly but I get the following error when running the small.world function: 
Error in FUN(X[[i]], ...) : Not a graph object
With the traceback showing the following line as the culprit
colMeans(vapply(rand, vapply, numeric(N[1L]), graph_attr, numeric(1L), "Lp"))

I am not too sure how to proceed from here. The documentation states to pass in the randomGraph from sim.rand.graph.par directly into small world, but the error is stating the random graph is not formatted correctly. 

Chris Watson

unread,
Dec 14, 2020, 4:02:28 PM12/14/20
to brainGr...@googlegroups.com
Try doing the following before calling "small.world":
randGraphs <- as_brainGraphList(randGraphs, type='random', level=level)

where "level" should be "subject" or "group".

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/brainGraph-help/5259b5b5-8981-4498-a56b-439b12ea986bn%40googlegroups.com.

Brian Kim

unread,
Dec 14, 2020, 4:08:28 PM12/14/20
to brainGr...@googlegroups.com
I get the following error:

Error in as_brainGraphList(randomGraphs, type = "random", level = "subject") : all(vapply(g.list, function(x) is_igraph(x[[1L]]), logical(1L))) is not TRUE

To check if the returned randomGraphs is returning a list of graphs, I ran 
class(randomGraphs[[1]])
Which shows "brainGraph" "igraph"



Chris Watson

unread,
Dec 14, 2020, 5:43:15 PM12/14/20
to brainGr...@googlegroups.com
If you save all the data and send it to me I can look into it.

Brian Kim

unread,
Dec 14, 2020, 10:44:53 PM12/14/20
to brainGraph-help
Thanks,
Is it possible to send it to you directly instead of on this public forum?

Chris Watson

unread,
Dec 14, 2020, 10:52:09 PM12/14/20
to brainGr...@googlegroups.com
Yes, you can email me directly or if the file is too large, you can use a file-sharing service.

Chris Watson

unread,
Dec 15, 2020, 11:37:37 AM12/15/20
to brainGr...@googlegroups.com
This is a bit of a convoluted solution but works for your single test graph:

rgl <- as_brainGraphList(list(randomGraphs), type='random')
dt.small <- small.world(as_brainGraphList(testGraph), rgl)

I don't know why your RStudio session initially aborted; I don't use it so I would suggest maybe trying outside of RStudio. Also make sure the random graph files were written to disk.

Brian Kim

unread,
Dec 15, 2020, 8:39:00 PM12/15/20
to brainGr...@googlegroups.com
Thanks Chris,

The code works great! Yes, I'll consider running the code directly from the terminal to address the RStudio issues.

Reply all
Reply to author
Forward
0 new messages