-
Notifications
You must be signed in to change notification settings - Fork 0
/
.temp.Rmd
190 lines (148 loc) · 4.54 KB
/
.temp.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
---
title: "Comparative Network Analyses"
author: "Alex Bartnik"
date: "April 30, 2019"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r Load dependencies}
dependencies <- c(
"dplyr",
"tidyr",
"ggplot2"
)
for (package in dependencies) {
if (!package %in% (.packages())) {
library(package,
character.only = T)
}
}
if (!exists("fcDev")) {
source('../scripts/getData.R')
source('../scripts/preprocessing.R')
}
source('../scripts/getNetworkConnections.R')
```
```{r}
setwd('/home/anacadmin/R/projects/scatters')
gatherAllPairsPerNetwork <- function(network.name) {
internetworkpairs <- getInterNetworkPairs(getNetworkRegions(network.name))
intranetworkpairs <- getIntraNetworkPairs(getNetworkRegions(network.name))
subjects <- intersect(rownames(fcDev), rownames(dti))
`Disease Group` <- disease.groups[subjects,]
combinePairs <- function(inputData, source.name, inter.network, intra.network, disease.group) {
rbind(
cbind(inputData[subjects, inter.network], `Disease Group`) %>%
mutate(subject = subjects) %>%
gather(
key = "pair",
value = source.name,
-subject, -`Disease Group`
) %>%
mutate(location = "Internetwork"),
cbind(inputData[subjects, intra.network], `Disease Group`) %>%
mutate(subject = subjects) %>%
gather(
key = "pair",
value = source.name,
-subject, -`Disease Group`
) %>%
mutate(location = "Intranetwork")
) %>%
group_by(subject, location, `Disease Group`) %>%
{
if (source.name == "fcDev") {
summarise(., fcDev = mean(source.name))
} else if (source.name == "dti") {
summarise(., dti = mean(source.name))
}
}
}
network.fcDev <- combinePairs(
fcDev,
"fcDev",
getInterNetworkPairs(getNetworkRegions(network.name)),
getIntraNetworkPairs(getNetworkRegions(network.name)),
`Disease Group`
)
network.dti <- combinePairs(
dti,
"dti",
getInterNetworkPairs(getNetworkRegions(network.name)),
getIntraNetworkPairs(getNetworkRegions(network.name)),
`Disease Group`
)
network <- merge(network.fcDev, network.dti)
network.copy <- network
network.copy$location = "All"
network.all <- rbind(network, network.copy)
return (network.all)
}
```
```{r}
setwd('/home/anacadmin/R/projects/scatters')
dmn <- gatherAllPairsPerNetwork("DMN")
auditory <- gatherAllPairsPerNetwork("Auditory")
```
```{r}
setwd('/home/anacadmin/R/projects/scatters/')
for (network in smith.networks) {
if (network != "Cerbellum") {
print(network)
plotIntraNetworkSums(network, "Diffusion")
ggsave(paste("Intranetwork",network,".png",sep=""),
path = "figures/",
<<<<<<< HEAD
width = 6,
height = 5,
dpi = 20)
=======
width = 8,
height = 6,
dpi = 200)
>>>>>>> e9b41e2b074ab201b510e0c4b5358fc51b7af5d2
plotInterNetworkSums(network, "Diffusion")
ggsave(paste("Internetwork",network,".png",sep=""),
path = "figures/",
<<<<<<< HEAD
width = 6,
height = 5,
dpi = 20)
plotNetworkSums(network, "Diffusion")
ggsave(paste(network,".png",sep=""),
path = "figures/",
width = 6,
height = 5,
dpi = 20)
=======
width = 10,
height = 6,
dpi = 200)
plotNetworkSums(network, "Diffusion")
ggsave(paste("WithinNetworkFC_",network,".png",sep=""),
path = "figures/",
width = 10,
height = 6,
dpi = 200)
plotNetworkSums(network, "Diffusion", T)
ggsave(paste("TotalFC_",network,".png",sep=""),
path = "figures/",
width = 10,
height = 6,
dpi = 200)
>>>>>>> e9b41e2b074ab201b510e0c4b5358fc51b7af5d2
}
}
```
```{bash}
cd /home/anacadmin/R/projects/scatters/figures; ./montage.sh
```
```{r}
setwd('/home/anacadmin/R/projects/scatters/')
quickFacetPlot(dmn, "DMN", "Structural Disruption", "Change in Functional Connectivity")
```