Hi Chris,
to follow with this, I have two more questions. The goal for me is to extract the mean of both graph and vertex metrics to use in within-subject analyses, ML classifiers, etc.
1.- I found that the metrics' mean from dt.G (from g) are not the same from dt.G.group (from g.group). This mismatch happened using density and consensus-based thresholds indistinctly.
I understand dt.G stores the graph from all my subjects (n = 891) across thresholds, while dt.G.group have the groups' average by threshold (n = 2), but shouldn't the means still match?
dt.G[, .(mean = mean(Cp)), by = .(Group, threshold)]
dt.G.group[, Group := Study.ID] # I have to do this first because Group appears as '1' while the Study.ID column behaves as 'Group'
dt.G.group[, .(mean = mean(Cp)), by = .(Group, threshold)]
2.- Another question I have is, say I'm interested in using binarized networks (weighted = NULL), should I use 'A.bin' and 'A.inds' instead of 'A.norm.sub' and 'A.norm.mean' when generating g and g.group objects? If so, doing that result in different means between weighted and unweighted networks.
The code to generate g and g.group was this from your user guide (p. 46-47) is below.
Thank you very much in advance!
Jonatan
###################################################################################################
# mayflies and my.mats file already generated #
inds <- lapply(grps, function(x) covars[Group == x, which = T])
thresholds <- rev(seq(0.05, 0.3, 0.05))
sub.thresh <- 0.5
modality <- 'fmri'
atlas <- 'dk'
my.mats <- create_mats(matfiles$A,
modality = modality,
mat.thresh = thresholds,
sub.thresh = sub.thresh,
inds = inds)
g <- g.group <- vector('list', length(thresholds))
for (j in seq_along(thresholds)) {
g[[j]] <- make_brainGraphList(my.mats$A.norm.sub[[j]], atlas, modality = modality, # A.bin[[j]], or A.norm.sub[[j]] if weighted = T?
weighting = 'pearson', threshold = thresholds[j],
weighted = T, gnames = covars$Study.ID, # weighted T or NULL
grpNames = covars$Group)
g.group[[j]] <- make_brainGraphList(my.mats$A.norm.mean[[j]], atlas, modality = modality, # A.inds[[j]], or A.norm.mean[[j]] if weighted = T?
weighting = 'pearson', threshold = thresholds[j],
weighted = T, gnames = grps) # weighted T or NULL
}
dt.G <- rbindlist(lapply(g, graph_attr_dt))
dt.G.group <- rbindlist(lapply(g.group, graph_attr_dt))
dt.G.group$sub.thresh <- dt.G$sub.thresh <- sub.thresh
setorderv(dt.G, 'threshold', -1)
idvars <- c('modality', 'atlas', 'weighting', 'sub.thresh', 'threshold', 'Group')
dt.G.long <- melt(dt.G, id.vars = c(idvars, 'Study.ID', 'density'))
dt.G.group[, Group := Study.ID] # Required to not return error when melt in dt.G.group.long
dt.G.group.long <- melt(dt.G.group, id.vars = c(idvars, 'Study.ID', 'density'))
# Calculate means #
###################################################################################################