Hi Chris and everybody,
I was trying to 'adapt' the following code to compute centrality closeness to test instead other graph metrics stored in 'dt.G' (after creating graphs and tidying things up).
The original code from p. 108 says the following:
clocent.diffs.perm <- function(g, densities) {
meas <- lapply(g, function(x) t(sapply(x, function(y) centr_clo(y)$res)))
meas.diff <- sapply(seq_along(V(g[[1]][[1]])), function(x)
brainGraph:::auc_diff(densities, cbind(meas[[1]][, x], meas[[2]][, x])))
tmp <- as.data.table(t(meas.diff))
setnames(tmp, 1:ncol(tmp), V(g[[1]][[1]])$name)
return(tmp)
}
perms.clocent <- brainGraph_permute(densities,
all.dat.resids,
perms = myPerms[1:1e2, ],
level = 'other',
.function = clocent.diffs.perm,
auc = T)
summary(perms.clocent, alt = 'two.sided')
Now, I'd like to compute other graph metrics not included in brainGraph_permute by default (for instance, E.local). I was trying to run:
clocent.diffs.perm <- function(g, densities) {
meas <- lapply(g, function(x) t(sapply(x, function(y) NA)))
meas[[1]] <- dt.G$E.global[dt.G$Group == 'Patient']
meas[[2]] <- dt.G$E.global[dt.G$Group == 'Control']
meas.diff <- meas[[1]] - meas[[2]]
tmp <- as.data.table(t(meas.diff))
return(tmp)
}
perms.clocent <- brainGraph_permute(densities,
all.dat.resids,
perms = myPerms,
level = 'other',
.function = clocent.diffs.perm,
auc = T)
When trying to get the summary statistics, I get the following error:
summary(perms.clocent, alt = 'two.sided')
Error in `[.data.table`(result.dt, , `:=`(p, (sum(abs(get(measure)) >= :
by=c(...), key(...) or names(...) must evaluate to 'character'
When turning the 'auc' option to FALSE, I get instead:
Error in setkeyv(x, cols, verbose = verbose, physical = physical) :
some columns are not in the data.table: densities
I think I messed up with the densities part. In the original function, 'densities' is well-defined as its purpose is to be further used in auc_diff.
I've searched throughout the forum for previous messages asking something similar with very little luck. Is this the right way to pass to brainGraph_permute other metrics though?
By the way, I'm using:
R version 3.6.1 (2019-07-05)
brainGraph version 2.7.3.
Best,
Jonatan