Thank you for the speedy responses thus far with brainGraph.
I have been attempting to extract individuals contributions for SCN. The SCN analysis comprises two groups. I have used the Scheffer atlas and Freesurfer thickness modality. I am using brainGraph 2.7.3
2) I would like to calculate individual contributions of certain network properties. I saw there was a previous thread on this. If, for example, I wanted to extract individual contribution to global efficiency or nodal efficiency would the edited function look like the following:
function (resids, corr.mat, level = c("global", "regional"),
control.value = 1)
{
Group <- Study.ID <- i <- NULL
stopifnot(inherits(resids, "brainGraph_resids"))
groups <- resids$groups
kNumSubj <- resids$resids.all[, tabulate(Group)]
if (is.numeric(control.value)) {
}
else {
control.str <- control.value
}
control.inds <- resids$resids.all[, which(Group == control.str)]
level <- match.arg(level)
if (level == "global") {
pat.inds <- resids$resids.all[, which(Group == patient.str)]
IC[[groups[j]]] <- foreach(i = seq_len(kNumSubj[j]),
.combine = "c") %dopar% {
resids.aop <- resids[c(control.inds, pat.inds[i])]
resids.aop$resids.all[, `:=`(Group, control.str)]
resids.aop$resids.all <- droplevels(resids.aop$resids.all)
setkey(resids.aop$resids.all, Group)
new.corr <- corr.matrix(resids.aop, densities = 0.1)[[1]]$R
g <- graph_from_adjacency_matrix(corrs[[group.vec[i]]]$R, mode='undirected', diag=FALSE)
g.new <- graph_from_adjacency_matrix(new.corrs[[1]]$R, mode='undirected', diag=FALSE) g.eff <- efficiency(g, 'global', use.parallel=FALSE)
g.eff - g.eff.new }
IC[[groups[j]]] <- cbind(resids$resids.all[groups[j],
c("Study.ID", "Group")], IC[[groups[j]]])
}
DT <- rbindlist(IC)
setnames(DT, "V2", "IC")
}
else if (level == "regional") {
pat.inds <- resids$resids.all[, which(Group == patient.str)]
RC[[groups[j]]] <- foreach(i = seq_len(kNumSubj[j]),
.combine = "rbind") %dopar% {
resids.aop <- resids[c(control.inds, pat.inds[i])]
resids.aop$resids.all[, `:=`(Group, control.str)]
resids.aop$resids.all <- droplevels(resids.aop$resids.all)
setkey(resids.aop$resids.all, Group)
new.corr <- corr.matrix(resids.aop, densities = 0.1)[[1]]$R
g <- graph_from_adjacency_matrix(corrs[[group.vec[i]]]$R, mode='undirected', diag=FALSE) # Add "weighted=TRUE" if you want a weighted metric
g.new <- graph_from_adjacency_matrix(new.corrs[[1]]$R, mode='undirected', diag=FALSE) n.eff <- efficiency(g, 'nodal', use.parallel=FALSE)
n.eff.new <- efficiency(g.new, 'nodal', use.parallel=FALSE)
}
RC[[groups[j]]] <- cbind(resids$resids.all[groups[j],
c("Study.ID", "Group")], RC[[groups[j]]])
}
RC.dt <- rbindlist(RC)
DT <- melt(RC.dt, id.vars = c("Study.ID", "Group"),
variable.name = "region",
}
out <- list(method = "Add one patient", level = level, DT = DT)
class(out) <- c("IC", class(out))
return(out)
}
Let me know if you need any more information and thanks for the continued support!
Gershon.