results in MTPC

44 views
Skip to first unread message

yd li

unread,
Nov 3, 2019, 11:50:57 AM11/3/19
to brainGraph-help
Hi,Chris
I have 2 groups: Control (reference group)and MA. Most of my script were copied from the manual of brainGraph 2.7.0 and few modifications were done.
plot_global(dt.G.tidy,xvar='threshold',exclude=exclude.vars)  showed that Lp(control group,red) > Lp(MA group,green) at every threshold (0.001-0.01,interval=0.001).

Lp.png


brainGraph_GLM also presented results consistent with this plot with following contrast settings:
con.mat<-matrix(c(0,-2,0,2),nrow=2,byrow=T,dimnames=list(c('conrols>MA',"MA > Control')))

However, MTPC with the same effect coding contrast settings as those in brainGraph_GLM showed that Lp(MA) > Lp(control) . Question 1: Is that normal?
Then I reran the brainGraph_GLM script, the result changed to Lp(MA group) > Lp(control) at every threshold. Question 2: What changed the result?

Thanks,
Li

Chris Watson

unread,
Nov 4, 2019, 12:18:45 AM11/4/19
to brainGr...@googlegroups.com
Hi Li, could you post the full command-line? I am specifically curious what you specified for the "alternative" function argument. The default is "two.sided".

I do not know if it would be "normal". Remember that "mtpc" calculates results across *all* thresholds in the data, whereas "brainGraph_GLM" is for a single threshold.
Furthermore, since you have 2 contrasts, what are the results for both? Can you also plot the mtpc results (using the "plot" method) and see what it looks like?

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-he...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brainGraph-help/96701674-7639-42ce-aaf6-352c5afe5918%40googlegroups.com.

yd li

unread,
Nov 4, 2019, 9:15:04 PM11/4/19
to brainGraph-help
Hi, Chris,
the following is my command-line for brainGraph_GLM :
g.glm<-c(g[[1]][[1]],g[[2]][[1]]) 
con.mat <- matrix(c(0, -2,0,2), nrow=2,byrow = T, dimnames=list(c('Control > MA','MA > Control')))
cl <- makeCluster(detectCores())
registerDoSNOW(cl)
results_glm<-brainGraph_GLM(g.glm, measure='Lp',#'E.global.wt', 
                            covars=table_covars[, 1:2],
                            coding='effects', con.mat=con.mat,
                            level ='graph,
                            alt='greater',
                            permute=T,N=1000,long=F)
stopCluster(cl)
print(results_glm$DT[which(results_glm$DT$p.perm<0.05),])  

 my command-line for MTPC :

mtpcVars <- data.table(level='graph',
                       outcome='Lp',
                       alt='greater')
setkey(mtpcVars, level, outcome)
mtpcVars['graph', N := 5e3] 
library(permute)
mtpcPerms <- list(vertex=shuffleSet(n=nrow(table_covars), nset=mtpcVars['vertex', unique(N)]),
                  graph=shuffleSet(n=nrow(table_covars), nset=mtpcVars['graph', unique(N)]))
# Create the contrast matrix
mtpcContrast <- matrix(c(0, 0,-2,0,0,2), nrow=2,byrow = T, dimnames=list(c('Control > MA','MA > Control')))
mtpc.diffs.list <- sapply(mtpcVars[, unique(level)], function(x) NULL)
cl <- makeCluster(detectCores())
registerDoSNOW(cl)
for (x in names(mtpc.diffs.list)) { 
  mtpc.diffs.list[[x]] <- sapply(mtpcVars[x, unique(outcome)], function(x) NULL)
  for (y in mtpcVars[x, outcome]) {
    print(paste('Level:', x, '; Outcome:', y, ';', format(Sys.time(), '%H:%M:%S')))
    mtpc.diffs.list[[x]][[y]] <-
      mtpc(g, thresholds, covars=table_covars,#[,-3], # use -3 to exclude age
           measure=y, con.mat=mtpcContrast,
           con.type='t', level=x, N=mtpcVars[.(x, y), N], perms=mtpcPerms[[x]],
           alt=mtpcVars[.(x, y), alt])
  }
}
stopCluster(cl)

mtpc.diffs.sig.dt <-
  rbindlist(lapply(mtpc.diffs.list, function(x)
    rbindlist(lapply(x, function(y)
      y$DT[A.mtpc > A.crit, .SD[1], by=region]))))

Since plot_global and brainGraph_GLM showed that  Lp(control group) > Lp(MA group) at every threshold, I have expected MTPC would generate similar result. 
However, MTPC result was contradictory to my expection, which also happened to other global metrics.
Thanks
Li 



在 2019年11月4日星期一 UTC+8下午1:18:45,Chris Watson写道:
To unsubscribe from this group and stop receiving emails from it, send an email to brainGr...@googlegroups.com.

Chris Watson

unread,
Nov 5, 2019, 12:54:55 AM11/5/19
to brainGr...@googlegroups.com
The first thing I notice is that the contrast matrix is different for "brainGraph_GLM" and "mtpc". In the former case, you specify a 2x2 matrix while in the latter, you specify a 2x3. Unless this was a typo, then you cannot expect the results to be the same.

Please paste the output of "summary(mtpc.diffs.list)". It can still be instructive to look at the plots for these objects, as well.

Chris

P.S. Since you are only looking at one graph metric and one level (i.e., "graph") you do not need to create a data.table with parameters or use "for" loops; you can just keep the function call itself. However, it is up to you.

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/81c7d1b5-dc70-445d-9f54-a812fdb76b50%40googlegroups.com.
Message has been deleted

yd li

unread,
Nov 5, 2019, 1:32:10 AM11/5/19
to brainGraph-help
yes, the difference of 2 contrast is a typo.

The output of "summary(mtpc.diffs.list)" is:

Screenshot from 2019-11-05 14-02-46.png







plot(mtpc.diffs.list$graph$Lp,contrast=1):

Lp_plot.jpeg




plot(mtpc.diffs.list$graph$Lp,contrast=2):

Lp_plot_contrat2.jpeg

Thanks!





 

Chris Watson

unread,
Nov 5, 2019, 9:47:15 AM11/5/19
to brainGr...@googlegroups.com
Hi Li,

Sorry, I meant the summary of the MTPC results object; I think in your case it should be "summary(mtpc.diffs.list$graph$Lp)".
In any case, the plots are helpful. First, notice that the two plots are mirror images of one another (at least the observed statistic, the red lines, are). This is expected because the different in contrasts is only a sign change.

However, I just noticed what may be the source of the error. Your call to "mtpc" does not include a specification of effects coding. You must include "coding='effects'" in the function call. Please do this and let me know if the results then match those of "brainGraph_GLM".

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-he...@googlegroups.com.

yd li

unread,
Nov 6, 2019, 8:05:51 AM11/6/19
to brainGraph-help
Hi Chris,
I added 'coding=effects' in the 'mtpc' function. But this problem remains that ‘mtpc’ results were opposite to  those of 'brainGraph_GLM" for all global attributes.

Li

在 2019年11月5日星期二 UTC+8下午10:47:15,Chris Watson写道:
Hi Li,

Sorry, I meant the summary of the MTPC results object; I think in your case it should be "summary(mtpc.diffs.list$graph$Lp)".
In any case, the plots are helpful. First, notice that the two plots are mirror images of one another (at least the observed statistic, the red lines, are). This is expected because the different in contrasts is only a sign change.

However, I just noticed what may be the source of the error. Your call to "mtpc" does not include a specification of effects coding. You must include "coding='effects'" in the function call. Please do this and let me know if the results then match those of "brainGraph_GLM".

Chris


On Tue, Nov 5, 2019 at 12:32 AM yd li <flys...@126.com> wrote:
yes, the difference of 2 contrast is a typo.

The output of "summary(mtpc.diffs.list)" is:

Screenshot from 2019-11-05 14-02-46.png







plot(mtpc.diffs.list$graph$Lp,contrast=1):

Lp_plot.jpeg




plot(mtpc.diffs.list$graph$Lp,contrast=2):

Lp_plot_contrat2.jpeg

Thanks!





 

--
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,
Nov 6, 2019, 9:33:53 AM11/6/19
to brainGr...@googlegroups.com
Please send me an "rda" file containing all of the data needed to reproduce these problems.

Chris

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/7986e85e-1cbf-4c30-8b6f-3e11c2992f6f%40googlegroups.com.

yd li

unread,
Nov 7, 2019, 9:23:02 AM11/7/19
to brainGraph-help
Hi Chris,
I have sent you the g.rda and table_covars.rda. The thresholds are seq(0.001,0.01,0.001).
Thanks
Li

在 2019年11月6日星期三 UTC+8下午10:33:53,Chris Watson写道:

Chris Watson

unread,
Nov 24, 2019, 11:30:02 PM11/24/19
to brainGr...@googlegroups.com
Hi Li, it looks like the Study ID's are not in the same order in the "covars" table and in the graph lists. So when the graph metric (Lp) is getting pulled from the graph lists, they are not assigned to the correct group. Please make sure that both the Study ID's and group are correct.

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/590a030a-77cc-449d-ba94-89c04a41af8b%40googlegroups.com.

yd li

unread,
Nov 25, 2019, 9:18:42 PM11/25/19
to brainGraph-help
Hi  Chris,
I used following command lines to find the difference between subject-ID in graph lists and covars table. However, I cound not find any difference. Could you be more specific? Thanks!

捕获.JPG



在 2019年11月25日星期一 UTC+8下午12:30:02,Chris Watson写道:

Chris Watson

unread,
Nov 26, 2019, 12:40:46 AM11/26/19
to brainGr...@googlegroups.com
In the "table_covars.rds" file you provided for me, the "Group" and "Study.ID" variables don't seem to match. For example, subject "MA_002" is listed as being a Control, which I assume is incorrect. The information in this table *must* be correct for "mtpc" to run properly.

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/c2e5544c-bc37-4dc4-9321-4eb0662264dc%40googlegroups.com.

Chris Watson

unread,
Nov 26, 2019, 12:44:01 AM11/26/19
to brainGr...@googlegroups.com
Additionally, the order in the graph object (i.e., the "g" object) should match that in the table. For example, from the data you sent me, the order in "g" goes like:
lBS_06, lBS_07, lBS_10, ...

Whereas the rows of "covars" are in a different order.
Message has been deleted

yd li

unread,
Nov 26, 2019, 5:08:48 AM11/26/19
to brainGraph-help
Hi Chris,
I checked the  table_covars.rds file I have sent to you. I found that something weird happened to this file, because the order of subject.IDs in the file are different from the table_covars in my local computer in which the order of subject IDs matchs that in the graph lists.  Sorry for that. I will send you a correct version of my table_covars file and my mtpc script as well. 

Chris Watson

unread,
Nov 26, 2019, 10:59:00 AM11/26/19
to brainGr...@googlegroups.com
Hi, I run the code now and get the expected result; i.e., that Lp is greater in Controls than MA. I also rerun it a few times and get the same result. I do not see any instability; however, the reason you might be seeing that is because you are only running 500 permutations. The "A.mtpc" is not much greater than "A.crit" so it can possibly fluctuate due to different permutation sets, but if you use more permutations this should not fluctuate much.

Chris

On Tue, Nov 26, 2019 at 4:08 AM yd li <flys...@126.com> wrote:
Hi Chris,
I checked the  table_covars.rds file I have sent to you. I found that something weird happened to this file, because the order of subject.IDs in the file are different from the table_covars in my local computer in which the order of subject IDs matchs that in the graph lists.  Sorry for that. I will send you a correct version of my table_covars file and my mtpc script as well. 

--
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.
Reply all
Reply to author
Forward
0 new messages