/
UseCase3.Rmd
78 lines (67 loc) · 2.29 KB
/
UseCase3.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
---
title: 'CyTargetLinker use case 3: Author - Publication - Journal Network'
author: "mkutmon"
date: "July 7, 2019"
version: 2.0
---
################################
# Tested with
# Cytoscape version 3.7.1
# CyTargetLinker version 4.1.0
# R version 3.5.3
# RCy3 version 2.0.88
################################
# Step 0: Set up environment
```{r setup, include=FALSE}
if(!"RCy3" %in% installed.packages()){
install.packages("RCy3")
}
library(RCy3)
```
## Set working directory
```{r set working directory}
if(!"knitr" %in% installed.packages()){
install.packages("knitr")
}
library(knitr)
knitr:::input_dir()
```
## check cytoscape connection
```{r test connection}
cytoscapePing()
if("cytargetlinker" %in% commandsHelp("")) print("Success: the CyTargetLinker app is installed") else print("Warning: CyTargetLinker app is not installed. Please install the CyTargetLinker app before proceeding.")
```
# Step 1: Load author information (list of wikidata identifiers)
```{r}
authors <- read.csv("authors.txt", sep="")
createNetworkFromDataFrames(as.data.frame(authors),NULL, title="Network", collection="Publication Network")
```
# Step 2: Extend network with known publications of authors
```{r}
publications <- file.path(getwd(), "linksets", "publications.xgmml")
CTLextend.cmd = paste('cytargetlinker extend idAttribute="shared name" linkSetFiles="', publications, '" network=current direction=BOTH', sep="")
commandsRun(CTLextend.cmd)
layoutNetwork()
```
# Step 3: Extend the network with journal names of the publications
```{r}
journals <- file.path(getwd(), "linksets", "journals.xgmml")
CTLextend.cmd = paste('cytargetlinker extend idAttribute="shared name" linkSetFiles="', journals, '" network=current direction=BOTH', sep="")
commandsRun(CTLextend.cmd)
layoutNetwork()
```
# Step 4: Adapt viusal style
```{r}
lockNodeDimensions(TRUE)
setNodeShapeDefault('ellipse')
setNodeColorMapping('CTL.Type', c('initial', 'article', 'journal'), colors=c('#D3D3D3', '#F5CA2E', '#5D90C7'), mapping.type="d")
setNodeLabelMapping('CTL.label')
setNodeFontSizeBypass(authors[,1], 30)
```
# Step 5: Save images and session
```{r}
png.file <- file.path(getwd(), "Author-Publication-Journal-Network.png")
exportImage(png.file,'PNG')
session.file <- file.path(getwd(), "Author-Publication-Journal-Network.cys")
saveSession(session.file)
```