g.group <- g <- fnames <- vector('list', length = length(groups))for (i in seq_along(groups)) { for (j in seq_along(thresholds)) { print(paste0('Threshold ', j, '/', length(thresholds), '; group ', i, '; ', format(Sys.time(), '%H:%M:%S'))) foreach(k = seq_along(inds[[i]])) %dopar% { g.tmp <- graph_from_adjacency_matrix(A.norm.sub[[j]][, , inds[[i]][k]], mode = 'undirected', diag = F, weighted = T) g.tmp <- set_brainGraph_attr(g.tmp, atlas, modality = 'dti', weighting = 'sld', threshold = thresholds[j], subject = covars_dti[groups[i], Study.ID[k]], group = groups[i], use.parallel = FALSE, A = A.norm.sub[[j]][, , inds[[i]][k]]) saveRDS(g.tmp, file = paste0(savedir, '/', sprintf('g%i_thr%02i_subj%03i%s', i, j, k, '.rds'))) } } # Group mean weighted graphs print(paste0('Group', i, '; ', format(Sys.time(), '%H:%M:%S'))) g.group[[i]] <- lapply(seq_along(thresholds), function(x) graph_from_adjacency_matrix(A.norm.mean[[x]][[i]], mode = 'undirected', diag = F, weighted = T)) g.group[[i]] <- llply(seq_along(thresholds), function(x) brainGraph::set_brainGraph_attr(g.group[[i]][[x]], atlas, modality = 'dti', weighting = 'sld', threshold = thresholds[x], group = groups[i], A = A.norm.mean[[x]][[i]], use.parallel = FALSE), .parallel = TRUE)}
## check datafor (i in seq_along(groups)) { g[[i]] <- fnames[[i]] <- vector('list', length = length(thresholds)) for (j in seq_along(thresholds)) {
fnames[[i]][[j]] <- list.files(savedir, sprintf('g%i_thr%02i.*', i, j), full.names=T) g[[i]][[j]] <- lapply(fnames[[i]][[j]], readRDS) } x <- all.equal(sapply(g[[i]][[1]], graph_attr, 'name'), covars_dti[groups[i], Study.ID]) if (isTRUE(x)) lapply(fnames[[i]], file.remove)}saveRDS(g, file = paste0(savedir, '/', 'g.rds'))saveRDS(g.group, file = paste0(savedir, '/', 'g.group.rds'))
## Graph and Vertex measurements# GROUP-LEVEL#===============================================================================dt.V.group <- rbindlist(lapply(g.group, function(x) rbindlist(lapply(x, vertex_attr_dt))))dt.G.group <- rbindlist(Map(graph_attr_dt, g.group, as.list(groups)))# SUBJECT-LEVEL#===============================================================================dt.V <- vector('list', length = length(groups))for (i in seq_along(groups)) { dt.V[[i]] <- lapply(g[[i]], llply, vertex_attr_dt, groups[i]) dt.V[[i]] <- rbindlist(lapply(dt.V[[i]], rbindlist))}dt.V <- rbindlist(dt.V)dt.G <- rbindlist(Map(function(x, y) rbindlist(lapply(x, graph_attr_dt, y)), g, as.list(groups)))dt.V.group$sub.thresh <- dt.G.group$sub.thresh <- dt.G$sub.thresh <- dt.V$sub.thresh <- sub.threshsetorderv(dt.V, 'threshold', -1)setorderv(dt.G, 'threshold', -1)setcolorder(dt.V.group, c('modality', 'atlas', 'weighting', 'sub.thresh', 'threshold', 'Group', names(dt.V.group)[1:33]))setcolorder(dt.G.group, c('modality', 'atlas', 'weighting', 'sub.thresh','threshold', 'Group', names(dt.G.group)[c(1:4, 6:23)]))setcolorder(dt.G, c('modality', 'atlas', 'weighting', 'sub.thresh', 'threshold', 'Group', 'Study.ID', names(dt.G)[c(1:4, 6:23)]))setcolorder(dt.V, c('modality', 'atlas', 'weighting', 'sub.thresh', 'threshold', 'Group', 'Study.ID', names(dt.V)[1:33]))dt.G.group.tidy <- melt(dt.G.group, names(dt.G)[1:6])dt.G.tidy <- melt(dt.G, c(names(dt.G)[1:7], 'density'))
Error in colnamesInt(x, neworder, check_dups = TRUE) :
argument specifying columns specify duplicated column(s)
Warning message: In melt.data.table(dt.G.group, names(dt.G)[1:6]) : 'measure.vars' [num.tri, diameter, transitivity, assortativity, ...] are not all of the same type. By order of hierarchy, the molten data value column will be of type 'character'. All measure variables not of type 'character' will be coerced too. Check DETAILS in ?melt.data.table for more on coercion.
"Cp" "Lp" "E.global" "mod" "density" "num.tri" "diameter" "threshold"
"transitivity" "assortativity" "assortativity.lobe" "assortativity.lobe.hemi"
"asymm" "spatial.dist" "num.hubs" "E.local" "vulnerability"
while other graph metrics seems normal, different for each subject in one group:
"strength" "mod.wt"
"E.local.wt" "E.global.wt" "diameter.wt" "Lp.wt"
"num.hubs.wt"
--
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/275fff89-9b7f-4cd1-a313-821524ebb119o%40googlegroups.com.
thresholds <- rev(seq(0.001, 0.01, 0.001))sub.thresh <- 0.5divisor <- 'waytotal'my.mats <- create_mats(matfiles$A, modality=modality, divisor=divisor, div.files=matfiles$way, threshold.by = "consensus", mat.thresh=thresholds, sub.thresh=sub.thresh, inds=inds)
--
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/f94e2072-7c2b-413d-9ff7-c68b7a8e3c0co%40googlegroups.com.
X <- brainGraph_GLM_design(covars_use, coding = "cell.means")conmat <- matrix(c(-1,1,0, -1,0,1, 0,-1,1), nrow = 3)
conmat <- t(conmat)rownames(conmat) <- c("B-A", "C-A", "C-B")
g.glm <- do.call(Map, c(c, g))[[6]]glm.res <- brainGraph_GLM(g.list = g.glm, covars = covars_use, measure = "strength", X = X, con.mat = conmat, level = "graph")summary(glm.res)
plot(glm.res)
brainGraph GLM results
---------------------------------------------------------------
Level: graph
Graph metric of interest: strength
Contrast type: T contrast
Alternative hypothesis: C != 0
Contrast matrix:
GroupA GroupB GroupC
B-A -1 1 0
C-A -1 0 1
C-B 0 -1 1
Statistics
-------------------------------
B-A
Region Estimate 95% CI low 95% CI high Std. error t value p-value p-value (FDR)
1: graph 0.11905 0.046618 0.19149 0.036224 3.2866 0.0016847 0.0016847
C-A
No signficant results!
C-B
No signficant results!
`geom_smooth()` using formula 'y ~ x'
`geom_smooth()` using formula 'y ~ x'
`geom_smooth()` using formula 'y ~ x'
TableGrob (4 x 2) "arrange": 6 grobs
z cells name grob
1 1 (2-2,1-1) arrange gtable[layout]
2 2 (2-2,2-2) arrange gtable[layout]
3 3 (3-3,1-1) arrange gtable[layout]
4 4 (3-3,2-2) arrange gtable[layout]
5 5 (1-1,1-2) arrange text[GRID.text.4511]
6 6 (4-4,1-2) arrange text[GRID.text.4512]
There were 12 warnings (use warnings() to see them)
> warnings()
1: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric, ... :
pseudoinverse used at 2.4124
2: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric, ... :
neighborhood radius 0.11965
3: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric, ... :
reciprocal condition number 3.5405e-16
4: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric, ... :
There are other near singularities as well. 0.014315
5: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric, ... :
pseudoinverse used at 2.4124
6: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric, ... :
neighborhood radius 0.11965
7: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric, ... :
reciprocal condition number 3.9505e-16
8: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric, ... :
There are other near singularities as well. 0.014315
9: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric, ... :
pseudoinverse used at 0.043446
10: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric, ... :
neighborhood radius 0.0065543
11: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric, ... :
reciprocal condition number 2.2595e-16
12: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric, ... :
There are other near singularities as well. 4.2959e-05
Hi, Chris.
Some infomation you may need:
> X GroupA GroupB GroupC [1,] 1 0 0 [2,] 1 0 0 [3,] 1 0 0
...
[22,] 0 1 0
[23,] 0 1 0
[24,] 0 1 0
...
[42,] 0 0 1
[50,] 0 0 1
[51,] 0 0 1
[52,] 0 0 1
and covars_use only has two columns: Study.ID and Group, for simplify purpose.
--
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/4ca7fa54-2bc3-4529-a6bc-48c061c75af2o%40googlegroups.com.
> plot(glm.res)[[1]]
`geom_smooth()` using formula 'y ~ x' `geom_smooth()` using formula 'y ~ x' `geom_smooth()` using formula 'y ~ x'
[[1]]
TableGrob (12 x 9) "layout": 18 grobs
z cells name grob
1 0 ( 1-12, 1- 9) background rect[plot.background..rect.1312]
2 5 ( 6- 6, 4- 4) spacer zeroGrob[NULL]
3 7 ( 7- 7, 4- 4) axis-l absoluteGrob[GRID.absoluteGrob.1298]
4 3 ( 8- 8, 4- 4) spacer zeroGrob[NULL]
5 6 ( 6- 6, 5- 5) axis-t zeroGrob[NULL]
6 1 ( 7- 7, 5- 5) panel gTree[panel-1.gTree.1290]
7 9 ( 8- 8, 5- 5) axis-b absoluteGrob[GRID.absoluteGrob.1294]
8 4 ( 6- 6, 6- 6) spacer zeroGrob[NULL]
9 8 ( 7- 7, 6- 6) axis-r zeroGrob[NULL]
10 2 ( 8- 8, 6- 6) spacer zeroGrob[NULL]
11 10 ( 5- 5, 5- 5) xlab-t zeroGrob[NULL]
12 11 ( 9- 9, 5- 5) xlab-b titleGrob[axis.title.x.bottom..titleGrob.1301]
13 12 ( 7- 7, 3- 3) ylab-l titleGrob[axis.title.y.left..titleGrob.1304]
14 13 ( 7- 7, 7- 7) ylab-r zeroGrob[NULL]
15 14 ( 4- 4, 5- 5) subtitle zeroGrob[plot.subtitle..zeroGrob.1308]
16 15 ( 3- 3, 5- 5) title titleGrob[plot.title..titleGrob.1307]
17 16 (10-10, 5- 5) caption zeroGrob[plot.caption..zeroGrob.1310]
18 17 ( 2- 2, 2- 2) tag zeroGrob[plot.tag..zeroGrob.1309]
[[2]]
TableGrob (12 x 9) "layout": 18 grobs
z cells name grob
1 0 ( 1-12, 1- 9) background rect[plot.background..rect.1354]
2 5 ( 6- 6, 4- 4) spacer zeroGrob[NULL]
3 7 ( 7- 7, 4- 4) axis-l absoluteGrob[GRID.absoluteGrob.1340]
4 3 ( 8- 8, 4- 4) spacer zeroGrob[NULL]
5 6 ( 6- 6, 5- 5) axis-t zeroGrob[NULL]
6 1 ( 7- 7, 5- 5) panel gTree[panel-1.gTree.1332]
7 9 ( 8- 8, 5- 5) axis-b absoluteGrob[GRID.absoluteGrob.1336]
8 4 ( 6- 6, 6- 6) spacer zeroGrob[NULL]
9 8 ( 7- 7, 6- 6) axis-r zeroGrob[NULL]
10 2 ( 8- 8, 6- 6) spacer zeroGrob[NULL]
11 10 ( 5- 5, 5- 5) xlab-t zeroGrob[NULL]
12 11 ( 9- 9, 5- 5) xlab-b titleGrob[axis.title.x.bottom..titleGrob.1343]
13 12 ( 7- 7, 3- 3) ylab-l titleGrob[axis.title.y.left..titleGrob.1346]
14 13 ( 7- 7, 7- 7) ylab-r zeroGrob[NULL]
15 14 ( 4- 4, 5- 5) subtitle zeroGrob[plot.subtitle..zeroGrob.1350]
16 15 ( 3- 3, 5- 5) title titleGrob[plot.title..titleGrob.1349]
17 16 (10-10, 5- 5) caption zeroGrob[plot.caption..zeroGrob.1352]
18 17 ( 2- 2, 2- 2) tag zeroGrob[plot.tag..zeroGrob.1351]
[[3]]
TableGrob (12 x 9) "layout": 18 grobs
z cells name grob
1 0 ( 1-12, 1- 9) background rect[plot.background..rect.1398]
2 5 ( 6- 6, 4- 4) spacer zeroGrob[NULL]
3 7 ( 7- 7, 4- 4) axis-l absoluteGrob[GRID.absoluteGrob.1384]
4 3 ( 8- 8, 4- 4) spacer zeroGrob[NULL]
5 6 ( 6- 6, 5- 5) axis-t zeroGrob[NULL]
6 1 ( 7- 7, 5- 5) panel gTree[panel-1.gTree.1376]
7 9 ( 8- 8, 5- 5) axis-b absoluteGrob[GRID.absoluteGrob.1380]
8 4 ( 6- 6, 6- 6) spacer zeroGrob[NULL]
9 8 ( 7- 7, 6- 6) axis-r zeroGrob[NULL]
10 2 ( 8- 8, 6- 6) spacer zeroGrob[NULL]
11 10 ( 5- 5, 5- 5) xlab-t zeroGrob[NULL]
12 11 ( 9- 9, 5- 5) xlab-b titleGrob[axis.title.x.bottom..titleGrob.1387]
13 12 ( 7- 7, 3- 3) ylab-l titleGrob[axis.title.y.left..titleGrob.1390]
14 13 ( 7- 7, 7- 7) ylab-r zeroGrob[NULL]
15 14 ( 4- 4, 5- 5) subtitle zeroGrob[plot.subtitle..zeroGrob.1394]
16 15 ( 3- 3, 5- 5) title titleGrob[plot.title..titleGrob.1393]
17 16 (10-10, 5- 5) caption zeroGrob[plot.caption..zeroGrob.1396]
18 17 ( 2- 2, 2- 2) tag zeroGrob[plot.tag..zeroGrob.1395]
[[4]]
TableGrob (12 x 9) "layout": 18 grobs
z cells name grob
1 0 ( 1-12, 1- 9) background rect[plot.background..rect.1444]
2 5 ( 6- 6, 4- 4) spacer zeroGrob[NULL]
3 7 ( 7- 7, 4- 4) axis-l absoluteGrob[GRID.absoluteGrob.1430]
4 3 ( 8- 8, 4- 4) spacer zeroGrob[NULL]
5 6 ( 6- 6, 5- 5) axis-t zeroGrob[NULL]
6 1 ( 7- 7, 5- 5) panel gTree[panel-1.gTree.1422]
7 9 ( 8- 8, 5- 5) axis-b absoluteGrob[GRID.absoluteGrob.1426]
8 4 ( 6- 6, 6- 6) spacer zeroGrob[NULL]
9 8 ( 7- 7, 6- 6) axis-r zeroGrob[NULL]
10 2 ( 8- 8, 6- 6) spacer zeroGrob[NULL]
11 10 ( 5- 5, 5- 5) xlab-t zeroGrob[NULL]
12 11 ( 9- 9, 5- 5) xlab-b titleGrob[axis.title.x.bottom..titleGrob.1433]
13 12 ( 7- 7, 3- 3) ylab-l titleGrob[axis.title.y.left..titleGrob.1436]
14 13 ( 7- 7, 7- 7) ylab-r zeroGrob[NULL]
15 14 ( 4- 4, 5- 5) subtitle zeroGrob[plot.subtitle..zeroGrob.1440]
16 15 ( 3- 3, 5- 5) title titleGrob[plot.title..titleGrob.1439]
17 16 (10-10, 5- 5) caption zeroGrob[plot.caption..zeroGrob.1442]
18 17 ( 2- 2, 2- 2) tag zeroGrob[plot.tag..zeroGrob.1441]
[[5]]
text[GRID.text.1445]
[[6]]
text[GRID.text.1446]
--
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/7a686cbc-962f-4ee5-8338-6a699e90e79do%40googlegroups.com.