-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrecreating_enrichment_map_vignette_part2.Rmd
173 lines (130 loc) · 5.59 KB
/
recreating_enrichment_map_vignette_part2.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
---
title: "Recreating EnrichmentMap tutorials with RCy3-part 2"
author: "Julia Gustavsen"
date: "May 24, 2016"
output:
html_document:
keep_md: true
number_sections: yes
theme: cerulean
toc: yes
toc_depth: 6
---
# Recreate tutorial from lab website and attempt to work with autoannotate and wordcloud: http://www.baderlab.org/Software/EnrichmentMap/Tutorial
- not currently fully functional because of problems with running autoannotate and wordcloud via cyREST.
## Load the appropriate libraries
```{r, message = FALSE}
library(RCy3)
library(httr)
library(RJSONIO)
```
## Important note:
* Make sure Cytoscape is open before running the code below!
## Load functions for creating Enrichment map
```{r, cache = TRUE}
source("./functions_to_add_to_RCy3/working_with_EM.R")
```
Create the connection to Cytoscape
```{r, cache = TRUE}
# first, delete existing windows to save memory:
deleteAllWindows(CytoscapeConnection())
cy <- CytoscapeConnection ()
```
```{r, cache = TRUE}
gsea_tut_path <- "/home/julia_g/windows_school/gsoc/gsoc_Rcy3_vignettes/GSEATutorial/"
gmt_file <- paste0(gsea_tut_path,
"Human_GO_AllPathways_no_GO_iea_April_15_2013_symbol.gmt")
data_1_ex_1 <- paste0(gsea_tut_path,
"MCF7_ExprMx_v2_names.gct")
gsea_tut_path <- "/home/julia_g/gsea_home/output/may23/estrogen_treatment_12hr_gsea_enrichment_results.Gsea.1464036337021/"
data_1_en_1_es <- paste0(gsea_tut_path,
"gsea_report_for_ES12_1464036337021.xls")
data_1_en_2_nt <- paste0(gsea_tut_path,
"gsea_report_for_NT12_1464036337021.xls")
rank_file <- paste0(gsea_tut_path,
"edb/MCF7_ExprMx_v2_names_ExprMx_v2_names.ES_NT.cls_ES12_versus_NT12.rnk")
```
```{r, cache = TRUE}
#Dataset 1 / Phenotypes 1: ES12 VS NT12
em_params <- list(analysisType = "GSEA",
gmtFile = gmt_file,
expressionDataset1 = data_1_ex_1,
enrichmentsDataset1 = data_1_en_1_es,
enrichments2Dataset1 = data_1_en_2_nt,
pvalue = "0.001",
qvalue = "0.05",
ranksDataset1 = rank_file,
phenotype1Dataset1 ="ES12",
phenotype2Dataset1 ="NT12",
similaritycutoff = "0.25",
coeffecients = "JACCARD")
EM_ex_6 <- setEnrichmentMapProperties(cy,
"build",
em_params,
copy.graph.to.R = TRUE)
```
Successfully built!
The experiment concerns ??? and we are examining estrogen treatment vs no treatment at 12hr.
```{r, cache = TRUE}
fitContent(EM_ex_6)
Sys.sleep(10)
saveImage(EM_ex_6,
"EM_ex_6",
"png",
h = 2000)
```
![](./EM_ex_6.png)
# Use the application auto annotate to add better labels to the groups in Enrichment Map
```{r, cache = TRUE}
source("./functions_to_add_to_RCy3/working_with_auto_annotate.R")
## autoannotate label-clusterBoosted
# Run label algorithm 'clusterBoosted'. Uses WordCloud to calculate the labels. Words in the label are the most frequent words and their adjacent words. The higher the "adjacent word bonus" is, the more likely adjacent words will be in the label.
# autoannotate label-sizeSorted Run label algorithm 'sizeSorted'. Uses WordCloud to calculate the labels. Words in the label are the most frequent words.
#autoannotate label-clusterBoosted arguments:
#adjacentWordBonus=: Size bonus given to words that are adjacent to the largest words. Default: 8
#labelColumn=: Name of node column to use to generate the labels
#maxWords=: Max words to include in label. Default: 4
#nodeList=[nodeColumn:value|node name,...]|all|selected|unselected: List of nodes in the cluster
```
```{r, cache = TRUE}
getAutoAnnotateCommandsNames(cy,
"label-clusterBoosted")
getAutoAnnotateCommandsNames(cy,
"label-sizeSorted")
```
** The app via cyrest does not add the annotations, but identifies the clusters, so not currently working to add in the labels.
```{r}
## problems here with the column label,
## need to generate it from the network to be queried.
## make sure to select the appropriate network.
autoa_params <- list(adjacentWordBonus = 8, # int
labelColumn = "EM3_GS_DESCR", # string
maxWords = 30, # int
nodeList = "all"
) # list nodes in the cluster
EM_ex_7 <- setAutoAnnotateProperties(EM_ex_6,
"label-clusterBoosted",
autoa_params)
```
**not working**
If it were working I would expect to see results something like this:
![](./em_autoannotate_manual_shot1.png)
# Test out word cloud
wordcloud create arguments:
cloudName=<String>: Cloud name ----
create=true|false: Actually create the cloud or just return the results without creating the cloud.
nodeList=[nodeColumn:value|node name,...]|all|selected|unselected: List of Nodes
wordColumnName=<String>: Column with words
```{r, cache = TRUE}
wordcloud_params <- list(cloudName = "Test_cloud_from_R",
create = TRUE,
nodeList = "all",
wordColumnName = "EM3_GS_DESCR")
request.uri <- "http://localhost:1234/v1/commands/wordcloud/create"
request.res <- GET(url = request.uri,
query = wordcloud_params)
request.res
## currently have to manually save. would like an export function like in the GUI.
```
If it worked it would look something like this:
![](./em_word_cloud_manual_shot.png)