make_brainGraphList error message: "The `edges` argument of `as_adjacency_matrix()` was deprecated in igraph 2.0.0 and is now defunct."

125 views
Skip to first unread message

Sarah

unread,
Apr 17, 2024, 6:20:01 PM4/17/24
to brainGraph-help
Hi Chris, 

I am working through Chapter 6 of the user guide and following the complete example script provided in section 6.1.1. I am running into an issue at Step 4 with the make_brainGraphList command: I am wondering if you know of the work around for the edges argument being deprecated? 
> # 4. Create graph lists and calculate graph metrics > g <- lapply(seq_along(densities), function(x) + make_brainGraphList(corrs[x], atlas ='dk', modality='thickness')) [1] "Start time: 2024-04-17 15:00:47" | | 0%
Error in { : task 2 failed - "The `edges` argument of `as_adjacency_matrix()` was deprecated in igraph 2.0.0 and is now defunct."


The rest of my code is below: 
```{r}
# 1. Import data & set up variables
datadir <- "~//neuroimaging//Connectome_project"
covars <- fread(file.path(datadir, 'covars.csv'), stringsAsFactors=FALSE)
covars$meets_ptsd_criteria <- as.factor(covars$meets_ptsd_criteria)
grps <- covars[, levels(meets_ptsd_criteria)]
options(bg.group='meets_ptsd_criteria')
exclude.subs <- c('98', '99')
raw_data <- import_scn(datadir, atlas='dk', modality='thickness',
exclude.subs=exclude.subs)

# A hack to get the variables into the workspace
invisible(lapply(seq_along(raw_data), function(x)
assign(names(raw_data)[x], eval(raw_data[[x]]), envir=.GlobalEnv)))

# 2. Get and check residuals
myResids <- get.resid(lhrh, covars=covars, exclude.cov='meets_ptsd_critera')
residPlots <- plot(myResids)
ml <- gridExtra::marrangeGrob(residPlots, nrow=3, ncol=3)
ggsave('residuals.pdf', ml, path = datadir)
system('xdg-open residuals.pdf')

# 3. Correlation matrices
densities <- seq(0.05, 0.20, 0.01)
corrs <- corr.matrix(myResids, densities=densities)

# 4. Create graph lists and calculate graph metrics
g <- lapply(seq_along(densities), function(x)
make_brainGraphList(corrs[x], atlas ='dk', modality='thickness'))
# 5. data.tables of the metrics
dt.G <- rbindlist(lapply(g, graph_attr_dt))
dt.V <- rbindlist(lapply(g, vertex_attr_dt))

```

Thank you, 
Sarah

Hollie

unread,
May 5, 2024, 10:09:14 PM5/5/24
to brainGraph-help
Hi Sarah, 

I'm currently encountering the same issue - just wondering whether you managed to find a solution?

Many thanks, 

Hollie 

Lionel

unread,
May 15, 2024, 11:07:38 AM5/15/24
to brainGraph-help
Hey @all!

I just encountered the same error. I found a workaround by installing a former version of igraph where the edge argument is not deprecated (see here).

pak::pkg_install("igr...@1.6.0") 

@chris, do you plan on updating the braingraph package to work with the igraph >2.0.0?

Cheers,
Lionel

Hollie

unread,
May 23, 2024, 10:24:19 PM5/23/24
to brainGraph-help
This worked perfectly - thanks so much Lionel!!
Reply all
Reply to author
Forward
0 new messages