MTPC on small-worldness

36 views
Skip to first unread message

yd li

unread,
Jan 30, 2020, 11:42:03 AM1/30/20
to brainGraph-help
Hi Chris,
Can we use MTPC function to analyze the difference of small-world attributes between groups?

Thanks,
Yadi

Chris Watson

unread,
Jan 30, 2020, 11:52:11 AM1/30/20
to brainGr...@googlegroups.com
You could, but you would have to assign a graph attribute to every subject
containing the small-world coefficient, or whatever values you want to compare.

Chris

On Thu, Jan 30, 2020 at 10:42 AM, yd li <flys...@126.com> wrote:

> from: yd li <flys...@126.com>
> date: Thu, Jan 30 08:42 AM -08:00 2020
> to: brainGraph-help <brainGr...@googlegroups.com>
> reply-to: brainGr...@googlegroups.com
> subject: [brainGraph-help] MTPC on small-worldness
> --
> 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/4cc58dfb-7a5d-43e5-a9ed-233b2e7c7050%40googlegroups.com.

yd li

unread,
Jan 30, 2020, 7:54:34 PM1/30/20
to brainGraph-help
I have been able to apply MTPC on regular graph/vertex attributes according to the manual.  Could you show me the command line to add small-world coefficients, such as sigma and omega, into the g.list that will be fed into MTPC function?

Yadi

在 2020年1月31日星期五 UTC+8上午12:52:11,Chris Watson写道:
You could, but you would have to assign a graph attribute to every subject
containing the small-world coefficient, or whatever values you want to compare.

Chris

On Thu, Jan 30, 2020 at 10:42 AM, yd li <flys...@126.com> wrote:

> from: yd li <flys...@126.com>
> date: Thu, Jan 30 08:42 AM -08:00 2020
> to: brainGraph-help <brainGr...@googlegroups.com>
> reply-to: brainGr...@googlegroups.com
> subject: [brainGraph-help] MTPC on small-worldness
>
> Hi Chris,
> Can we use MTPC function to analyze the difference of small-world
> attributes between groups?
>
> Thanks,
> Yadi
>
> --
> 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 brainGr...@googlegroups.com.

Chris Watson

unread,
Feb 1, 2020, 9:10:30 PM2/1/20
to brainGr...@googlegroups.com
Assuming you have calculated small worldness either through the
"analysis_random_graphs" function (which returns, as one of the list elements, a
table containing small world coefficients) or separately with the "small.world"
function.

I assume that, following the User Guide, these values are in the variable
"small.dt". I also assume that you have subject-level graphs in a nested list
called "g", in which for example "g.list[[1]]" is for Group 1, "g.list[[1]][[1]]" is for
the first threshold, and "g.list[[1]][[1]][[1]]" is the first subject of Group 1 at
the first threshold. Furthermore, I assume the thresholds are in the vector
"thresholds", and the group names are in the vector "groups".

You could do it like the following.

subjects <- vector('list', length=length(groups))
for (i in seq_along(g.list)) {
subjects[[i]] <- covars[Group == groups[i], Study.ID]
for (j in seq_along(g.list[[i]])) {
for (k in seq_along(g.list[[i]][[j]])) {
g.list[[i]][[j]][[k]]$sigma <- small.dt[Study.ID == subjects[[i]][k] & threshold == thresholds[j], sigma]
}
}
}

I do not know if this will work without error, so you may have to adjust the
code to work with your dataset.

Please let me know if you have any questions/issues.
Chris

On Thu, Jan 30, 2020 at 06:54 PM, yd li <flys...@126.com> wrote:

> from: yd li <flys...@126.com>
> date: Thu, Jan 30 04:54 PM -08:00 2020
> to: brainGraph-help <brainGr...@googlegroups.com>
> reply-to: brainGr...@googlegroups.com
> subject: Re: [brainGraph-help] MTPC on small-worldness
>
> I have been able to apply MTPC on regular graph/vertex attributes according
> to the manual. Could you show me the command line to add small-world
> coefficients, such as sigma and omega, into the g.list that will be fed
> into MTPC function?
>
> Yadi
>
> 在 2020年1月31日星期五 UTC+8上午12:52:11,Chris Watson写道:
>>
>> You could, but you would have to assign a graph attribute to every subject
>> containing the small-world coefficient, or whatever values you want to
>> compare.
>>
>> Chris
>>
>> On Thu, Jan 30, 2020 at 10:42 AM, yd li <flys...@126.com <javascript:>>
>> wrote:
>>
>> > from: yd li <flys...@126.com <javascript:>>
>> > date: Thu, Jan 30 08:42 AM -08:00 2020
>> > to: brainGraph-help <brainGr...@googlegroups.com <javascript:>>
>> > reply-to: brainGr...@googlegroups.com <javascript:>
>> > subject: [brainGraph-help] MTPC on small-worldness
>> >
>> > Hi Chris,
>> > Can we use MTPC function to analyze the difference of small-world
>> > attributes between groups?
>> >
>> > Thanks,
>> > Yadi
>> >
>> > --
>> > 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 brainGr...@googlegroups.com <javascript:>.
> --
> 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/4befdbe8-8194-4a35-b383-be60ab378c43%40googlegroups.com.

yd li

unread,
Feb 9, 2020, 8:13:47 AM2/9/20
to brainGraph-help
Hi Chris,
Thanks a lot for your command lines.

Excuse me, I have 1 extra question and 1 feedback:
1. It is said that the betweenness centrality of the nodes can change dramatically from binary network to weighted network (Cheng et al., NeuroImage, 2012),
   Is there a way to calculate btwn.cent.wt in brainGraph?

2. Several months ago, I asked the similar question that maria asked in the post "contrast matrix in mtpc": the mtpc results are absolutely contrary to what simple plotting of the parameters by group suggests and what the GLM on single thresholds shows.. 
    According to your reply, I apply the command lines:

    head(mtpc.diffs.list[[1]]$transitivity$res.glm[[1]]$X) 
    head(mtpc.diffs.list[[1]]$transitivity$res.glm[[2]]$X) 

    However, I could not find any difference. And adding "covars <- copy(covars)" into  "setup_glm" function did not chang my mtpc results that are contrary to simple plotting of the parameters by group suggests

Thank you 
Yadi 

Chris Watson

unread,
Feb 9, 2020, 11:14:42 AM2/9/20
to brainGr...@googlegroups.com
1. Not in igraph/brainGraph. You could see the "tnet" package:
https://toreopsahl.com/tnet/weighted-networks/node-centrality/

2. The issue from when I worked with your data was that the ordering in the
graph objects and in the covariates table were both incorrect. Those must match
one another, and match what is correct for your study (i.e., subjects should not
be labelled with the wrong subject group). When this was fixed, from what I
recall, it fixed the issue.

Chris

On Sun, Feb 09, 2020 at 07:13 AM, yd li <flys...@126.com> wrote:

> from: yd li <flys...@126.com>
> date: Sun, Feb 09 05:13 AM -08:00 2020
> to: brainGraph-help <brainGr...@googlegroups.com>
> reply-to: brainGr...@googlegroups.com
> subject: Re: [brainGraph-help] MTPC on small-worldness
>
> --
> 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/2b74d546-fb69-411d-b532-229a86bb23ab%40googlegroups.com.

maria

unread,
Feb 14, 2020, 4:25:08 PM2/14/20
to brainGraph-help
Dear Chris, dear Yadi, 

following you discussion I tried to assign the sigma values as graph attributes. With a few adaptations it worked perfectly with your command line, Chris. 

This is my final code: 
subjects <- vector('list', length=length(groups)) 
for (i in seq_along(g.list)) { 
  subjects[[i]] <- covars[Group == groups[i], Study.ID] 
  for (j in seq_along(g.list[[i]])) { 
    for (k in seq_along(g.list[[i]][[j]])) { 
      g.list[[i]][[j]][[k]]$sigma <- small.dt[Study.ID == subjects[[i]][k] & round(density, 2) == thresholds[j], sigma] 
    } 
  } 

I can analyze the threshold specific differences with brainGraph_GLM(), however, when I try to test group differences with mtpc() I get the following error: 
 
Error in vapply(g.list, graph_attr, numeric(1), measure) : 
 values must be length 1,
 but FUN(X[[1]]) result is length 0 

Although this seems to be an error from within brainGraph_GLM(), it seem to only occur when calling it via mtpc. 

@ Yadi, were you able to run the mtpc on "sigma" successfully? Could you share your solution? 

Thanks, maria
> To unsubscribe from this group and stop receiving emails from it, send an email to brainGr...@googlegroups.com.

yd li

unread,
Feb 15, 2020, 3:51:49 AM2/15/20
to brainGraph-help
Hi, Maria,
You have to calculate sigma for every subject. Is that what you have done to small.dt? 

Yadi

在 2020年2月15日星期六 UTC+8上午5:25:08,maria写道:

Maria Feldmann

unread,
Feb 15, 2020, 8:33:50 AM2/15/20
to brainGr...@googlegroups.com
Yes, exactly. 

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/2bccd193-86f6-40e6-ae86-a5ec961f952d%40googlegroups.com.

Chris Watson

unread,
Feb 15, 2020, 12:13:32 PM2/15/20
to brainGr...@googlegroups.com
Hi Maria, this might mean that "sigma" is not a graph attribute for some
subject(s) and/or threshold(s). You should check that they all have the
attribute, something like

anyNA(sapply(g.list, sapply, sapply, graph_attr, 'sigma'))

or

any(is.null(sapply(g.list, sapply, sapply, graph_attr, 'sigma')))

Otherwise, send me the full command you use, and the output of "traceback()".
Chris

On Sat, Feb 15, 2020 at 07:33 AM, Maria Feldmann <frau.mari...@gmail.com> wrote:

> from: Maria Feldmann <frau.mari...@gmail.com>
> date: Sat, Feb 15 08:33 AM -05:00 2020
> to: brainGr...@googlegroups.com
>> <https://groups.google.com/d/msgid/brainGraph-help/2bccd193-86f6-40e6-ae86-a5ec961f952d%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
> --
> 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/CAHJO6FU9%3Dqw74C5Fc6kRVXz5p24jE-ca-pCk_PJVtDvj7fJcSg%40mail.gmail.com.

maria

unread,
Feb 18, 2020, 12:24:09 PM2/18/20
to brainGraph-help
Hi Chris, 

thank you so much. You were right. I was able to fix it by reassigning sigma to the graph attribute with this code: 

subjects <- vector('list', length=length(groups)) 
for (i in seq_along(g.list)) { 
  subjects[[i]] <- covars[stgr == groups[i], Study.ID] 
  for (j in seq_along(g.list[[i]])) { 
    for (k in seq_along(g.list[[i]][[j]])) { 
      g.list[[i]][[j]][[k]]$sigma <- small.dt[Study.ID == subjects[[i]][k] & threshold == j, sigma] 
    } 
  } 

After that mtpc worked perfectly. 

Thanks, maria


On Saturday, February 15, 2020 at 12:13:32 PM UTC-5, Chris Watson wrote:
Hi Maria, this might mean that "sigma" is not a graph attribute for some
subject(s) and/or threshold(s). You should check that they all have the
attribute, something like

anyNA(sapply(g.list, sapply, sapply, graph_attr, 'sigma'))

or

any(is.null(sapply(g.list, sapply, sapply, graph_attr, 'sigma')))

Otherwise, send me the full command you use, and the output of "traceback()".
Chris

On Sat, Feb 15, 2020 at 07:33 AM, Maria Feldmann <frau.mar...@gmail.com> wrote:

> from: Maria Feldmann <frau.mar...@gmail.com>
> To unsubscribe from this group and stop receiving emails from it, send an email to brainGr...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages