brainGraph v3.0 custom parcellation pipeline

57 views
Skip to first unread message

Gershon Spitz

unread,
Sep 30, 2020, 7:43:12 AM9/30/20
to brainGr...@googlegroups.com
Dear Chris,

Thank you for your hard work on completing brainGraph v3.0

I have transitioned over from v2.7 and have found encountered some new error messages, but also some fixes which is great!

To help diagnose the problem, just some quick details:

— Looking at created and analysing structural covariance networks between two groups
—Using a custom parcellation atlas, the Schaefer 400 parcels,7 network version


My parcellation data.table looks like this:



I use the as_atlas to coerce the custom atlas:

Schaefer2018_400Parcels_7Networks <- as_atlas(parcellation)
I am testing running the pipeline over two densities: 

densities <- seq(0.10, 0.20, 0.10)

All runs smoothly until I get to creating the undirected graphs for each group using the following:

# Create simple, undirected graphs for each group
g <- lapply(seq_along(densities),  function(x)
make_brainGraphList(corrs[x], atlas = 'Schaefer2018_400Parcels_7Networks', modality='thickness', .progress=F))

I receive the following error:



I can get around this error by changing the ’name’ column in the parcellation by adding ‘l’ or ‘r’ to each region. Ie.,

Schaefer2018_400Parcels_7Networks_left <- Schaefer2018_400Parcels_7Networks %>%
  dplyr::filter(hemi == 'L') %>%
  mutate(name = paste0('l', name))

Schaefer2018_400Parcels_7Networks_right <- Schaefer2018_400Parcels_7Networks %>%
  dplyr::filter(hemi == 'R') %>%
  mutate(name = paste0('r', name))

Schaefer2018_400Parcels_7Networks <- setDT(rbind(Schaefer2018_400Parcels_7Networks_left,Schaefer2018_400Parcels_7Networks_right))

Creating the graphs then successfully runs using:

# Create simple, undirected graphs for each group
g <- lapply(seq_along(densities),  function(x)
make_brainGraphList(corrs[x], atlas = 'Schaefer2018_400Parcels_7Networks', modality='thickness', .progress=F))

I also find the I must specify atlas  Schaefer2018_400Parcels_7Networks’ 
Otherwise, if I use the following code:

g <- lapply(seq_along(densities), function(x)
make_brainGraphList(corrs[x], modality='thickness', .progress=F))

I receive the following error:

Similarly, if I want to create a subgraph, I must specify the atlas name, otherwise I receive the same “object ’NA not found” error. Thus, I have to specify like so:

g.lh <- lapply(seq_along(densities), function(x)
make_brainGraphList(corrs[x], atlas = 'Schaefer2018_400Parcels_7Networks', modality='thickness',
subnet=lobe.lh))
By the way, I believe the manual specifies to place the ’subnet’ command outside the brackets, which I think is incorrect.

Doing so, I am able to extract vertex level measure using, 

dt.V.limbic <- rbindlist(lapply(g.limbic, vertex_attr_dt))

But receive an error if I try to extract graph level measures using 

dt.G.limbic <- rbindlist(lapply(g.limbic, graph_attr_dt))

Receiving the following error:



The good news is that now both individuals contribution functions work, both aop and loo!


However, I now receive an error during random graph generation using:

#Generate N number of for each group and density
kNumRand <- 1e2
clustering <- F
outdir <- file.path(getwd(), 'rand')
rand_vars <- analysis_random_graphs(g, N=kNumRand, savedir=outdir,
clustering=clustering)
save(rand_vars, file = "data/rand_vars.RData")

I receive the following error:



Once again, thank you for developing the package and hopefully we can solve these niggling issues!

Best wishes,







Chris Watson

unread,
Sep 30, 2020, 11:28:21 AM9/30/20
to brainGr...@googlegroups.com
Hi Gershon, I am glad the new version fixes some bugs.

1. RE vertex names: the "l" and "r" prefixes being required suggests to me that the names in your input data table also include those. Is that the case?
It is slightly simpler to use "data.table" to update the names; I won't write out your full atlas name but just use "schaefer" below:
schaefer[hemi == 'L', name := paste0('l', name)]
schaefer[hemi == 'R', name := paste0('r', name)]

2. Yes, "atlas" is a required argument for "make_brainGraphList". I will update the User Guide but remember you can always check the function help pages.
And you are correct, "subnet" should be in the same function call and not outside the first set of parentheses.

3. I am not sure what is causing that error. You would need to send me both "g.limbic" and your atlas data.table so I can look into it

4. It would seem to me that "density" is not a graph attribute, but I would need the "g" object and the atlas data.table to look into this

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/46CB35CC-36A8-46D4-A50A-536133C0D6BE%40monash.edu.

Gershon Spitz

unread,
Sep 30, 2020, 11:02:12 PM9/30/20
to brainGr...@googlegroups.com
Hi Chris,

1. Ah, of course. My data table indeed had difference parcels labels—a silly oversight. I used you much more elegant code to fix this.

2. All good.

3. I attach the g.limbic and atlas data.table

4. I attach the g object and atlas data.table. The g object is for two groups and densities 0.1 and 0.2

Best,
Gershon.

g.limbic.RData
g.RData
Schaefer2018_400Parcels_7Networks.RData

Chris Watson

unread,
Oct 1, 2020, 2:04:21 AM10/1/20
to brainGr...@googlegroups.com
The "g.limbic" you sent is a factor vector, not any graphs.
For "analysis_random_graphs", I discovered the bug. It might take some time before I push the changes.
Fortunately the random graphs were saved to disk, so you can load them and run whatever commands you want.
What do you ultimately want to do w/ them?

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

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

--
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.
On 1 Oct 2020, at 1:28 am, Chris Watson <cwa...@alum.mit.edu> wrote:

Hi Gershon, I am glad the new version fixes some bugs.

1. RE vertex names: the "l" and "r" prefixes being required suggests to me that the names in your input data table also include those. Is that the case?
It is slightly simpler to use "data.table" to update the names; I won't write out your full atlas name but just use "schaefer" below:
schaefer[hemi == 'L', name := paste0('l', name)]
schaefer[hemi == 'R', name := paste0('r', name)]

2. Yes, "atlas" is a required argument for "make_brainGraphList". I will update the User Guide but remember you can always check the function help pages.
And you are correct, "subnet" should be in the same function call and not outside the first set of parentheses.

3. I am not sure what is causing that error. You would need to send me both "g.limbic" and your atlas data.table so I can look into it

4. It would seem to me that "density" is not a graph attribute, but I would need the "g" object and the atlas data.table to look into this

Chris


On Wed, Sep 30, 2020 at 6:43 AM 'Gershon Spitz' via brainGraph-help <brainGr...@googlegroups.com> wrote:
Dear Chris,

Thank you for your hard work on completing brainGraph v3.0

I have transitioned over from v2.7 and have found encountered some new error messages, but also some fixes which is great!

To help diagnose the problem, just some quick details:

— Looking at created and analysing structural covariance networks between two groups
—Using a custom parcellation atlas, the Schaefer 400 parcels,7 network version


My parcellation data.table looks like this:


<Screen Shot 2020-09-30 at 8.44.08 pm.png>

I use the as_atlas to coerce the custom atlas:

Schaefer2018_400Parcels_7Networks <- as_atlas(parcellation)
I am testing running the pipeline over two densities: 

densities <- seq(0.10, 0.20, 0.10)

All runs smoothly until I get to creating the undirected graphs for each group using the following:

# Create simple, undirected graphs for each group
g <- lapply(seq_along(densities),  function(x)
make_brainGraphList(corrs[x], atlas = 'Schaefer2018_400Parcels_7Networks', modality='thickness', .progress=F))

I receive the following error:

<Screen Shot 2020-09-30 at 8.52.28 pm.png>


I can get around this error by changing the ’name’ column in the parcellation by adding ‘l’ or ‘r’ to each region. Ie.,

Schaefer2018_400Parcels_7Networks_left <- Schaefer2018_400Parcels_7Networks %>%
  dplyr::filter(hemi == 'L') %>%
  mutate(name = paste0('l', name))

Schaefer2018_400Parcels_7Networks_right <- Schaefer2018_400Parcels_7Networks %>%
  dplyr::filter(hemi == 'R') %>%
  mutate(name = paste0('r', name))

Schaefer2018_400Parcels_7Networks <- setDT(rbind(Schaefer2018_400Parcels_7Networks_left,Schaefer2018_400Parcels_7Networks_right))

Creating the graphs then successfully runs using:

# Create simple, undirected graphs for each group
g <- lapply(seq_along(densities),  function(x)
make_brainGraphList(corrs[x], atlas = 'Schaefer2018_400Parcels_7Networks', modality='thickness', .progress=F))

I also find the I must specify atlas  Schaefer2018_400Parcels_7Networks’ 
Otherwise, if I use the following code:

g <- lapply(seq_along(densities), function(x)
make_brainGraphList(corrs[x], modality='thickness', .progress=F))

I receive the following error:

<Screen Shot 2020-09-30 at 9.05.39 pm.png>
Similarly, if I want to create a subgraph, I must specify the atlas name, otherwise I receive the same “object ’NA not found” error. Thus, I have to specify like so:

g.lh <- lapply(seq_along(densities), function(x)
make_brainGraphList(corrs[x], atlas = 'Schaefer2018_400Parcels_7Networks', modality='thickness',
subnet=lobe.lh))
By the way, I believe the manual specifies to place the ’subnet’ command outside the brackets, which I think is incorrect.

Doing so, I am able to extract vertex level measure using, 

dt.V.limbic <- rbindlist(lapply(g.limbic, vertex_attr_dt))

But receive an error if I try to extract graph level measures using 

dt.G.limbic <- rbindlist(lapply(g.limbic, graph_attr_dt))

Receiving the following error:

<Screen Shot 2020-09-30 at 9.09.43 pm.png>


The good news is that now both individuals contribution functions work, both aop and loo!


However, I now receive an error during random graph generation using:

#Generate N number of for each group and density
kNumRand <- 1e2
clustering <- F
outdir <- file.path(getwd(), 'rand')
rand_vars <- analysis_random_graphs(g, N=kNumRand, savedir=outdir,
clustering=clustering)
save(rand_vars, file = "data/rand_vars.RData")

I receive the following error:

<Screen Shot 2020-09-30 at 9.21.16 pm.png>


Once again, thank you for developing the package and hopefully we can solve these niggling issues!

Best wishes,








--
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/46CB35CC-36A8-46D4-A50A-536133C0D6BE%40monash.edu.

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

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

Gershon Spitz

unread,
Oct 1, 2020, 2:13:37 AM10/1/20
to brainGr...@googlegroups.com
Hi Chris,

Sorry to confuse, what I am trying to do is only use the vertices in the ‘limbic’ network to obtain graph vertex-level measures.

Ie., using the following code. 
regions.limbic <- get(atlas)[lobe == 'Limbic', name]

g.limbic <- lapply(seq_along(densities), function(x)
make_brainGraphList(corrs[x], atlas = 'Schaefer2018_400Parcels_7Networks', modality='thickness',
subnet=regions.limbic))
The error is that I cannot create the graphs.

I receive the error:


I want to use the analysis_random_graphs  to obtain the normalised measures for my graphs.

Ie., to obtain the small.dt and rich.dt data frames



Best,
Gershon.

Chris Watson

unread,
Oct 1, 2020, 2:17:42 AM10/1/20
to brainGr...@googlegroups.com
I will need the "corrs" data, then.

If you want to get the normalized measures from random graphs right away, you can edit the function and comment out the line calling "get_rand_attrs", since that is causing the error.
Otherwise, it will have to wait until I post a bugfix update.

Chris

Gershon Spitz

unread,
Oct 1, 2020, 2:27:10 AM10/1/20
to brainGr...@googlegroups.com
Thanks Chris,

I can confirm commenting out the get_rand_attrs solves the problem.

Attached is the corrs r object. Could it have something to do with atlas = ’NA’ ?

Best,

corrs.RData

Chris Watson

unread,
Oct 1, 2020, 11:59:01 AM10/1/20
to brainGr...@googlegroups.com
RE the other error: if you remove the "subnet" graph-level attribute it should run without error.

for (i in 1:2) {
  for (j in 1:2) {
    g[[i]]$graph[[j]]$subnet <- NULL
  }
}

I will fix this with the next bugfix release as well.

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.
On 1 Oct 2020, at 4:17 pm, Chris Watson <cwa...@alum.mit.edu> wrote:

I will need the "corrs" data, then.

If you want to get the normalized measures from random graphs right away, you can edit the function and comment out the line calling "get_rand_attrs", since that is causing the error.
Otherwise, it will have to wait until I post a bugfix update.

Chris

On Thu, Oct 1, 2020 at 1:13 AM 'Gershon Spitz' via brainGraph-help <brainGr...@googlegroups.com> wrote:
Hi Chris,

Sorry to confuse, what I am trying to do is only use the vertices in the ‘limbic’ network to obtain graph vertex-level measures.

Ie., using the following code. 
regions.limbic <- get(atlas)[lobe == 'Limbic', name]

g.limbic <- lapply(seq_along(densities), function(x)
make_brainGraphList(corrs[x], atlas = 'Schaefer2018_400Parcels_7Networks', modality='thickness',
subnet=regions.limbic))
The error is that I cannot create the graphs.

I receive the error:

<Screen Shot 2020-10-01 at 4.10.14 pm.png>

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

Gershon Spitz

unread,
Oct 1, 2020, 6:54:03 PM10/1/20
to brainGr...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages