contrast matrix in mtpc

28 views
Skip to first unread message

maria

unread,
Jan 27, 2020, 2:07:28 PM1/27/20
to brainGraph-help
Hi Chris,

I would like to ensure, that I'm using the correct contrast matrix to test my hypotheses in mtpc. 

I would like to compare graph theory measurements of patients and controls, while controlling for non-interest covariates. 

My design matrix looks like this (showing head and tail of brainGraph_GLM_design() with coding='effects') : 

Screen Shot 2020-01-23 at 1.32.43 PM.png















Following your examples in the manual I constructed the following contrast matrix, testing the group difference (using t statistics and alternative='greater'): 

Screen Shot 2020-01-23 at 1.29.49 PM.png

I'm wondering whether this is correct, even if I have no "reference group" as such? Or should it rather be -1 and 1? Does the choice of the alternative affect the results or this this merely for my own records? 

Furthermore, how would I have to construct the contrast to test the specific differences between more than 2 groups such as in the factor variable 'subgroups' (4 levels: 0,1,2,3)? 

Design matrix with effects coding: 
Screen Shot 2020-01-27 at 1.10.02 PM.png









I assume this would require a post test? Is this kind of analysis possible at all in mptc? 

Thank you, Maria










Chris Watson

unread,
Jan 27, 2020, 5:38:30 PM1/27/20
to brainGr...@googlegroups.com
For the first example, yes those contrasts should be correct, assuming "stgrPatient" is the variable you want to test for.
B0 is still the grand mean, and B4 = mu_2 - B0. So then mu_1 = B0 - B3, and mu_2 = B0 + B3. To test for "group 1 > group 2", equivalently "group 1 - group 2 > 0", you would have
mu_1 - mu_2 > 0
(B0 - B3) - (B0 + B3) > 0
-2B3 > 0
C = [0 0 0 -2 0]

And flip the sign for the opposite group comparison. Changing it to +/- 1 should only change the scale and not the P-values but I have not looked into this. Yes, the choice of alternative affects the results; if you do not know the direction of the effect, then it would be better to have a single two-tailed contrast; in that case, the sign of the contrast shouldn't matter (again, I haven't looked into this really). Looking at both one-sided tests will result in the P-value being 1/2 of that from a two-sided test, so if you didn't adjust the P-values for the multiple comparisons it would not be appropriate, technically. If your first contrast was "greater" and the second was "less", then these should produce identical results and therefore would be redundant.

For more than 2 groups, see the text in the User Guide (Chapter 8, Tutorial: design matrix coding). In your example with k=4 groups, if you are interested in a comparison that does *not* involve the reference group, then the contrast for "mu_i != mu_j" would simply be a +1 for the "ith" group and -1 for the "jth" group. For example, if you think "group 1 > group 2", C = [0 0 0 0 0 1 -1 0].
A comparison with the reference group is a bit different but I give an example in the User Guide. If you think "group 0 < group 3", you would have
mu_0 < mu_3
mu_0 - mu_3 < 0
(B0 - B5 - B6 - B7) - (B0 + B7) < 0
-B5 - B6 - 2B7 < 0
C = [0 0 0 0 0 -1 -1 -2]

mu_0 > mu_2
mu_0 - mu_2 > 0
(B0 - B5 - B6 - B7) - (B0 + B6) > 0
-B5 - 2B6 - B7 > 0
C = [0 0 0 0 0 -1 -2 -1]

So for any contrast involving the reference group, there should be a "-1" for all group columns except the one involving another group, in which case that column has "-2".

If you found any of this confusing, please let me know. Just remember that "B0" is the *1st* column of the design matrix, and for your 2nd example, B5 B6 B7 are the columns for the 3 other subgroups.
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/ae03bfaf-70dc-4a1e-8265-283904297a12%40googlegroups.com.

Chris Watson

unread,
Jan 27, 2020, 5:45:11 PM1/27/20
to brainGr...@googlegroups.com
And regarding your final question, there is no way (with brainGraph) to do post-hoc tests, if you mean things like Tukey's, FIsher's Least Significant Difference, and so forth. However, these are usually done after running the "omnibus test", or the F-test comparing for *any* significant difference among *all* groups. These post-hoc tests are intended to discover which pairs of groups are significantly different from one another.

If you are thinking of multiple comparison correction, for MTPC there are no P-values to adjust in the final outputs. If you wanted, you could reduce "alpha" when collecting all the GLM results. But I don't know if anyone has looked into this yet. I think it is better to test a smaller number of a priori comparisons instead of looking for all pairwise differences. Alternatively, it may be better to test a set of orthogonal contrasts, but I am not well-versed in this area. A statistician should be able to help.

Chris

maria

unread,
Jan 28, 2020, 9:08:39 AM1/28/20
to brainGraph-help
Thank you so much for elaborating! That is very helpful! 
On Mon, Jan 27, 2020 at 1:07 PM maria <frau.mar...@gmail.com> wrote:
Hi Chris,

I would like to ensure, that I'm using the correct contrast matrix to test my hypotheses in mtpc. 

I would like to compare graph theory measurements of patients and controls, while controlling for non-interest covariates. 

My design matrix looks like this (showing head and tail of brainGraph_GLM_design() with coding='effects') : 

Screen Shot 2020-01-23 at 1.32.43 PM.png















Following your examples in the manual I constructed the following contrast matrix, testing the group difference (using t statistics and alternative='greater'): 

Screen Shot 2020-01-23 at 1.29.49 PM.png

I'm wondering whether this is correct, even if I have no "reference group" as such? Or should it rather be -1 and 1? Does the choice of the alternative affect the results or this this merely for my own records? 

Furthermore, how would I have to construct the contrast to test the specific differences between more than 2 groups such as in the factor variable 'subgroups' (4 levels: 0,1,2,3)? 

Design matrix with effects coding: 
Screen Shot 2020-01-27 at 1.10.02 PM.png









I assume this would require a post test? Is this kind of analysis possible at all in mptc? 

Thank you, Maria










--
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.

maria

unread,
Jan 31, 2020, 2:33:27 PM1/31/20
to brainGraph-help
Hi Chris, 

I'm really sorry, that I have to ask for your support again. 

I followed you'r explanations on how to construct the contrast matrices for the mtpc, but the results are absolutely contrary to what simple plotting of the parameters by group suggests and what the GLM on single thresholds shows. 
I am aware that the single threshold effects do not necessarily have to be reflected in the mtpc results, but to find the effect being present but in the opposite direction is very odd. 

I thoroughly checked my code a thousand times, recreated the graph object and specifically checked the ordering of Study.ID's and group allocation in the graph object as well as in the covariate table. Everything seems to match as it's supposed to... 

This is what my code for a GLM to test the group difference (Patients vs. Controls in Variable "stgrPatient", reference level is "Controls") for one of the global parameters looks like: 
The design matrix: 

Screen Shot 2020-01-31 at 1.32.21 PM.png



g.glm_post <- c(g_post[[1]][[1]], g_post[[2]][[1]])  # concatenate all control graphs and patient graphs at threshold 20

con.mat = matrix(c(0, 0, 0, -2, 0, 0, 0, 0, 2, 0), nrow=2, ncol = 5, byrow = T)
rownames(con.mat) <- c('Control > Patient', 'Patient > Control')

summary(brainGraph_GLM(g.glm_post, measure = 'transitivity', covars = covars_glm_post[, c("Study.ID", "sex", "pma_mri1", "stgr", "Kohorte")], coding='effects', mean.center=TRUE,
                       con.mat = con.mat, con.type = "t", alpha=0.025, alt='greater', level = 'graph'))

This gives me the results, that I would expect when looking at the graph (here for example transitivity)

Screen Shot 2020-01-31 at 1.37.20 PM.png

Screen Shot 2020-01-31 at 1.40.03 PM.png




Now, when I repeat the analyses with the mtpc: 

mtpcVars <- data.table(level= c(rep('graph', each=6)),
                       outcome=c('E.global.wt', 'transitivity', 'E.local.wt', 'strength', 'Cp', 'mod.wt'),
                       alt='greater')

setkey(mtpcVars, level, outcome)

mtpcVars['graph', N := 10000]
mtpcPerms <- list(graph=shuffleSet(n=nrow(covars_glm_post), nset=mtpcVars['graph', unique(N)]))

mtpcContrast = matrix(c(0, 0, 0, -2, 0, 0, 0, 0, 2, 0), nrow=2, ncol = 5, byrow = T)
rownames(mtpcContrast) <- c('Control > Patient', 'Patient > Control')

mtpc.diffs.list <- sapply(mtpcVars[, unique(level)], function(x) NULL)
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 some timing info in the terminal; optional
    print(paste('Level:', x, '; Outcome:', y, ';', format(Sys.time(), '%H:%M:%S')))
    mtpc.diffs.list[[x]][[y]] <-
      mtpc(g_post, thresholds, covars=covars_glm_post[, c("Study.ID", "sex", "pma_mri1", "stgr", "Kohorte")], coding='effects', measure=y, con.mat=mtpcContrast,
           con.type='t', alpha=0.025, level=x, N=mtpcVars[.(x, y), N], perms=mtpcPerms[[x]],
           alt=mtpcVars[.(x, y), alt])
  }
}

Screen Shot 2020-01-31 at 2.17.39 PM.png




Do you have any idea, what could cause this? What else could I try? 


Apologies, for this long post! 


Thank you, Maria

Chris Watson

unread,
Feb 2, 2020, 2:11:48 AM2/2/20
to brainGr...@googlegroups.com
This looks to be the same problem another user posted about 2 months ago. In that case, the order of the covariates data.table (specifically, the Study.ID and/or Group columns) differed from the order in the graph list objects. Please make sure that the orders match. The function should already check for these issues, but it seems it is a bug that I did not catch previously.

Let me know if it works.
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/9ddac06d-2e91-4176-940d-9ad248d184ed%40googlegroups.com.

maria

unread,
Feb 3, 2020, 10:02:25 AM2/3/20
to brainGraph-help
Hi Chris, 

thank you. Yes, I already followed the trouble shooting steps from that post and ensured that the order of subjects in the graph object and in the covariates table is the same and that the group variable is correct too. Furthermore, the covariates table does contain the "Study.ID" variable, which is of class character just as the name attribute in the graph object. 

Also I‘m using the same covariates and the same graph object for the GLM, so I‘m not sure what could result in these differences in effects... 

Is there anything else that I could test? 

Thanks, Maria


On Sunday, February 2, 2020 at 2:11:48 AM UTC-5, Chris Watson wrote:
This looks to be the same problem another user posted about 2 months ago. In that case, the order of the covariates data.table (specifically, the Study.ID and/or Group columns) differed from the order in the graph list objects. Please make sure that the orders match. The function should already check for these issues, but it seems it is a bug that I did not catch previously.

Let me know if it works.
Chris

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

Chris Watson

unread,
Feb 3, 2020, 11:02:30 AM2/3/20
to brainGr...@googlegroups.com
Ok. Please send me a ".rda"/".RData" file with all of the data/variables I need
to perform these analyses and debug. Please also provide a ".R" script with the
code that you have been running. And finally (you can paste the text output in
email) please provide the R, igraph, and brainGraph versions you are using. It
might be helpful if you also provide operating system info, too. If you have
"devtools" you can do

devtools::session_info(c('igraph', 'brainGraph'))

Or you can use "sessionInfo" with the same arguments.

Chris

On Mon, Feb 03, 2020 at 09:02 AM, maria <frau.mari...@gmail.com> wrote:

> from: maria <frau.mari...@gmail.com>
> date: Mon, Feb 03 07:02 AM -08:00 2020
> to: brainGraph-help <brainGr...@googlegroups.com>
> reply-to: brainGr...@googlegroups.com
> subject: Re: [brainGraph-help] contrast matrix in mtpc
>
> Hi Chris,
>
> thank you. Yes, I already followed the trouble shooting steps from that
> post and ensured that the order of subjects in the graph object and in the
> covariates table is the same and that the group variable is correct too.
> Furthermore, the covariates table does contain the "Study.ID" variable,
> which is of class character just as the name attribute in the graph object.
>
> Also I‘m using the same covariates and the same graph object for the GLM,
> so I‘m not sure what could result in these differences in effects...
>
> Is there anything else that I could test?
>
> Thanks, Maria
>
>
> On Sunday, February 2, 2020 at 2:11:48 AM UTC-5, Chris Watson wrote:
>>
>> This looks to be the same problem another user posted about 2 months ago.
>> In that case, the order of the covariates data.table (specifically, the
>> Study.ID and/or Group columns) differed from the order in the graph list
>> objects. Please make sure that the orders match. The function should
>> already check for these issues, but it seems it is a bug that I did not
>> catch previously.
>>
>> Let me know if it works.
>> Chris
>>
>> On Fri, Jan 31, 2020 at 1:33 PM maria <frau.mar...@gmail.com <javascript:>>
>>> email to brainGr...@googlegroups.com <javascript:>.
>>> <https://groups.google.com/d/msgid/brainGraph-help/9ddac06d-2e91-4176-940d-9ad248d184ed%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/417e6c10-8239-4deb-8e4a-59aa18b21cfa%40googlegroups.com.

maria

unread,
Feb 3, 2020, 5:00:56 PM2/3/20
to brainGraph-help
Hi Chris, 

I sent you the file, please let me know if you need anything else. 

Thank you, Maria


On Monday, February 3, 2020 at 11:02:30 AM UTC-5, Chris Watson wrote:
Ok. Please send me a ".rda"/".RData" file with all of the data/variables I need
to perform these analyses and debug. Please also provide a ".R" script with the
code that you have been running. And finally (you can paste the text output in
email) please provide the R, igraph, and brainGraph versions you are using. It
might be helpful if you also provide operating system info, too. If you have
"devtools" you can do

devtools::session_info(c('igraph', 'brainGraph'))

Or you can use "sessionInfo" with the same arguments.

Chris

On Mon, Feb 03, 2020 at 09:02 AM, maria <frau.mar...@gmail.com> wrote:

> from: maria <frau.mar...@gmail.com>
> To unsubscribe from this group and stop receiving emails from it, send an email to brainGr...@googlegroups.com.

Chris Watson

unread,
Feb 4, 2020, 7:12:07 PM2/4/20
to brainGr...@googlegroups.com
Yes, please send me a .R file with the code you have run.
Chris

On Mon, Feb 03, 2020 at 04:00 PM, maria <frau.mari...@gmail.com> wrote:

> from: maria <frau.mari...@gmail.com>
> date: Mon, Feb 03 02:00 PM -08:00 2020
> to: brainGraph-help <brainGr...@googlegroups.com>
> reply-to: brainGr...@googlegroups.com
> subject: Re: [brainGraph-help] contrast matrix in mtpc
>
> Hi Chris,
>
> I sent you the file, please let me know if you need anything else.
>
> Thank you, Maria
>
> On Monday, February 3, 2020 at 11:02:30 AM UTC-5, Chris Watson wrote:
>>
>> Ok. Please send me a ".rda"/".RData" file with all of the data/variables I
>> need
>> to perform these analyses and debug. Please also provide a ".R" script
>> with the
>> code that you have been running. And finally (you can paste the text
>> output in
>> email) please provide the R, igraph, and brainGraph versions you are
>> using. It
>> might be helpful if you also provide operating system info, too. If you
>> have
>> "devtools" you can do
>>
>> devtools::session_info(c('igraph', 'brainGraph'))
>>
>> Or you can use "sessionInfo" with the same arguments.
>>
>> Chris
>>
>> On Mon, Feb 03, 2020 at 09:02 AM, maria <frau.mar...@gmail.com
>> <javascript:>> wrote:
>>
>> > from: maria <frau.mar...@gmail.com <javascript:>>
>> > date: Mon, Feb 03 07:02 AM -08:00 2020
>> > to: brainGraph-help <brainGr...@googlegroups.com <javascript:>>
>> > reply-to: brainGr...@googlegroups.com <javascript:>
>> https://groups.google.com/d/msgid/brainGraph-help/417e6c10-8239-4deb-8e4a-59aa18b21cfa%40googlegroups.com.
>>
>>
>>
>
> --
> 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/0f41c64b-1aab-4643-81c1-461073eb0983%40googlegroups.com.

maria

unread,
Feb 5, 2020, 8:34:26 AM2/5/20
to brainGraph-help
Hi Chris, 


My session info: 
version    R version 3.6.1 (2019-07-05)
os            macOS High Sierra 10.13.6   
system    x86_64, darwin15.6.0    

Thank you, Maria    

On Tuesday, February 4, 2020 at 7:12:07 PM UTC-5, Chris Watson wrote:
Yes, please send me a .R file with the code you have run.
Chris

On Mon, Feb 03, 2020 at 04:00 PM, maria <frau.mar...@gmail.com> wrote:

> from: maria <frau.mar...@gmail.com>
> To unsubscribe from this group and stop receiving emails from it, send an email to brainGr...@googlegroups.com.
03_mtpc_postvscontrols_20200204.R

Chris Watson

unread,
Feb 5, 2020, 10:09:37 PM2/5/20
to brainGr...@googlegroups.com
Hi Maria,

It seems the real problem is with my code. One issue is that the "y" value
is extracted from a data table *before* it is ordered by "Study.ID". This means
that the order of subjects in "y" is not the same as that of "covars", and
therefore the design matrix "X".

*However*, this still shouldn't have been a problem because the "y" variable
only gets assigned to the output list. This of course is not good but is not the
source of the problem. It looks like the "covars" data table's ordering gets
changed in the first call to "brainGraph_GLM" (from within "mtpc"). This ends up
changing the design matrix. You can see this by comparing the "X" element:

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

I am not entirely sure why the order of "pma_mri1" doesn't change, but
"stgrPatient" (the variable of interest) and "sex1" change.

The quick fix is to edit the "setup_glm" function and add (before the first line
of the code)
covars <- copy(covars)

If that causes problems, then instead you could create a new graph object and
reorder the graphs, and then make sure to set a new key for covars *before*
running analyses. Something like the following (not tested):

IDs <- sapply(c(g_post[[1]][[1]], g_post[[2]][[1]]), graph_attr, 'name')
g.new <- vector('list', length(thresholds))
for (i in seq_along(g.new)) {
g.new[[i]] <- c(g_post[[1]][[i]], g_post[[2]][[i]])[order(IDs)]
}
setkey(covars, Study.ID)

You would then (probably) have to comment out the following line in "mtpc":
g.list <- do.call(Map, c(c, g.list))


I am sorry about this bug, and this has been fixed for v3.0.0 but I am still
working on getting it finished. Please try the above fix and let me know if it
works.

Chris

On Wed, Feb 05, 2020 at 07:34 AM, maria <frau.mari...@gmail.com> wrote:

> from: maria <frau.mari...@gmail.com>
> date: Wed, Feb 05 05:34 AM -08:00 2020
> to: brainGraph-help <brainGr...@googlegroups.com>
> reply-to: brainGr...@googlegroups.com
> subject: Re: [brainGraph-help] contrast matrix in mtpc
>
> Hi Chris,
>
> this is the script. And the
> workspace: https://drive.google.com/file/d/1hpUflhSO-Cgh9kvfjGPd4elmHQ4Jb5kJ/view?usp=sharing
>
> My session info:
> version R version 3.6.1 (2019-07-05)
> os macOS High Sierra 10.13.6
> system x86_64, darwin15.6.0
>
> Thank you, Maria
>
> On Tuesday, February 4, 2020 at 7:12:07 PM UTC-5, Chris Watson wrote:
>>
>> Yes, please send me a .R file with the code you have run.
>> Chris
>>
>> On Mon, Feb 03, 2020 at 04:00 PM, maria <frau.mar...@gmail.com
>> <javascript:>> wrote:
>>
>> > from: maria <frau.mar...@gmail.com <javascript:>>
>> > date: Mon, Feb 03 02:00 PM -08:00 2020
>> https://groups.google.com/d/msgid/brainGraph-help/0f41c64b-1aab-4643-81c1-461073eb0983%40googlegroups.com.
>>
>>
>>
>
> --
> 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/c65d60c0-af50-4ed4-bb47-638a92ddccc4%40googlegroups.com.

maria

unread,
Feb 7, 2020, 10:44:48 AM2/7/20
to brainGraph-help
Hi Chris, 

thank you so much! 

I chose the first option and added the line "covars <- copy(covars)" to the brainGraph_GLM function which will then be called in mtpc. I think it fixed the issue, and the results of the mtpc are as expected. So that‘s great! 

However, I would like to better understand what was causing the issue, to be sure it‘s correct now. It looks like that before the fix, the X element got changed from one threshold to another. Is that correct? 
With the fix, this does not occur anymore. But the ordering of X in only by Study.ID and not stgr and then Study.ID. Is that the desired ordering?

If so, everything is fine. 

Thank you! Maria

If that is what you mean and what you think is causing the issue, then 
On Wed, Feb 05, 2020 at 07:34 AM, maria <frau.mar...@gmail.com> wrote:

> from: maria <frau.mar...@gmail.com>
> To unsubscribe from this group and stop receiving emails from it, send an email to brainGr...@googlegroups.com.

Chris Watson

unread,
Feb 7, 2020, 4:49:39 PM2/7/20
to brainGr...@googlegroups.com
1. Yes, the ordering in "X" should be by Study ID only. In v3, I will ensure
this is the case for any tables/matrices including Study IDs. Things became too
complicated when trying to account for sorting by both Group name and ID.

2. In "data.table", most operations are performed "by reference". This is
different from all (or, the vast majority) of other functions/operations in R.
Usually, when you pass a data object/variable to a function, a *copy* of that
object is passed to the function environment. The "original" object in the
Global Environment (i.e., the workspace, the environment the user is working in)
does not get affected; if the object is changed within the function, it is
really the copy of the object. With data.table, the operations are done on the
*original* object. So, from within "mtpc", it loops across all
thresholds/densities and calls "brainGraph_GLM". For the first
threshold/density, it is operating on the original "covars" table. But through
that, it makes some changes, so that the "covars" in the "mtpc" environment gets
changed instead of being left unaffected. So for the 2nd through final
thresholds, in the calls to "brainGraph_GLM", the ordering of "covars" is
different from that of the graphs, and the model (design matrix "X") becomes
incorrect.

I hope this explanation makes sense. When I finally release v3.0.0 this should
not be an issue.

Chris

On Fri, Feb 07, 2020 at 09:44 AM, maria <frau.mari...@gmail.com> wrote:

> from: maria <frau.mari...@gmail.com>
> date: Fri, Feb 07 07:44 AM -08:00 2020
> to: brainGraph-help <brainGr...@googlegroups.com>
> reply-to: brainGr...@googlegroups.com
> subject: Re: [brainGraph-help] contrast matrix in mtpc
>
> Hi Chris,
>
>> <javascript:>> wrote:
>>
>> > from: maria <frau.mar...@gmail.com <javascript:>>
>> > date: Wed, Feb 05 05:34 AM -08:00 2020
>> https://groups.google.com/d/msgid/brainGraph-help/c65d60c0-af50-4ed4-bb47-638a92ddccc4%40googlegroups.com.
>>
>>
>>
>
> --
> 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/75d8a0fd-cfd9-4f2f-b116-ae7a98461f6a%40googlegroups.com.

maria

unread,
Feb 7, 2020, 5:19:27 PM2/7/20
to brainGraph-help
Perfect, thank you! 


On Friday, February 7, 2020 at 4:49:39 PM UTC-5, Chris Watson wrote:
1. Yes, the ordering in "X" should be by Study ID only. In v3, I will ensure
this is the case for any tables/matrices including Study IDs. Things became too
complicated when trying to account for sorting by both Group name and ID.

2. In "data.table", most operations are performed "by reference". This is
different from all (or, the vast majority) of other functions/operations in R.
Usually, when you pass a data object/variable to a function, a *copy* of that
object is passed to the function environment. The "original" object in the
Global Environment (i.e., the workspace, the environment the user is working in)
does not get affected; if the object is changed within the function, it is
really the copy of the object. With data.table, the operations are done on the
*original* object. So, from within "mtpc", it loops across all
thresholds/densities and calls "brainGraph_GLM". For the first
threshold/density, it is operating on the original "covars" table. But through
that, it makes some changes, so that the "covars" in the "mtpc" environment gets
changed instead of being left unaffected. So for the 2nd through final
thresholds, in the calls to "brainGraph_GLM", the ordering of "covars" is
different from that of the graphs, and the model (design matrix "X") becomes
incorrect.

I hope this explanation makes sense. When I finally release v3.0.0 this should
not be an issue.

Chris

On Fri, Feb 07, 2020 at 09:44 AM, maria <frau.mar...@gmail.com> wrote:

> from: maria <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