forked from korkutlab/targetscore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ovcarChibe.Rmd
executable file
·127 lines (103 loc) · 4.72 KB
/
ovcarChibe.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
---
title: "Generate Causality SIF"
output:
html_document:
toc: yes
pdf_document:
toc: yes
---
```{r setup, echo=FALSE, warning=FALSE, message=FALSE}
require("knitr")
opts_knit$set(root.dir="..")
opts_chunk$set(fig.align="center", fig.width=6, fig.height=6, dpi=300)
```
## Purpose
* Plot SIFs generated by the Causality analysis
## Setup
```{r loadLibraries, message=FALSE, warning=FALSE}
library(zeptosensPkg)
library(paxtoolsr)
library(igraph)
```
## Generate SIF File
```{r}
graphType <- "compatible"
signedPcDir <- tempdir()
siteMatchStrict <- TRUE
resultPrefix <- "inst/ovcarProject/ovcar3_dif_drug_sig_"
platformFile <- "inst/chibeExample/abdata-chibe.txt"
valuesFile <- file.path(.googleDrive, "ovcar_project/ozgun_data/ozgun_data/dif_drug_sig/ovcar3_dif_drug_sig.txt")
geneCentric <- TRUE
compatibleResults <- generateRPPAGraphs(platformFile = platformFile,
idColumn = "ID1",
symbolsColumn = "Symbols",
sitesColumn = "Sites",
effectColumn = "Effect",
valuesFile = valuesFile,
valueColumn = "change",
valueThreshold = 0.001,
graphType = graphType,
siteMatchStrict=siteMatchStrict,
geneCentric=geneCentric,
outputFilePrefix = paste0(resultPrefix, "compatible"),
customNetworkDirectory=signedPcDir)
compatibleSif <- compatibleResults$sif
compatibleSif[, "graphType"] <- rep(graphType, nrow(compatibleResults$sif))
graphType <- "conflicting"
conflictingResults <- generateRPPAGraphs(platformFile = platformFile,
idColumn = "ID1",
symbolsColumn = "Symbols",
sitesColumn = "Sites",
effectColumn = "Effect",
valuesFile = valuesFile,
valueColumn = "change",
valueThreshold = 0.001,
graphType = graphType,
siteMatchStrict=siteMatchStrict,
geneCentric=geneCentric,
outputFilePrefix = paste0(resultPrefix, "conflicting"),
customNetworkDirectory=signedPcDir)
conflictingSif <- conflictingResults$sif
conflictingSif[, "graphType"] <- rep(graphType, nrow(conflictingResults$sif))
overallSif <- rbind(conflictingSif, compatibleSif)
overallSif <- unique(overallSif)
write.table(overallSif, file=paste0(resultPrefix, "overall.sif"), sep="\t", row.names=FALSE, quote=FALSE, na="")
```
## Combine SIF
```{r}
#cat ovcar3_dif_drug_sig_compatible.sif ovcar3_dif_drug_sig_conflicting.sif > ovcar3_dif_drug_sig_overall.sif
#cat ovcar3_dif_drug_sig_compatible.format ovcar3_dif_drug_sig_conflicting.format > ovcar3_dif_drug_sig_overall.format
conflictingSif <- read.table(paste0(resultPrefix, "conflicting.sif"), sep="\t", fill=TRUE, row.names=NULL, header=FALSE, stringsAsFactors=FALSE)
compatibleSif <- read.table(paste0(resultPrefix, "compatible.sif"), sep="\t", fill=TRUE, row.names=NULL, header=FALSE, stringsAsFactors=FALSE)
if(ncol(compatibleSif) == 4) {
compatibleSif <- cbind(compatibleSif, "V5"=rep(NA, nrow(compatibleSif)))
}
if(ncol(conflictingSif) == 4) {
conflictingSif <- cbind(conflictingSif, "V5"=rep(NA, nrow(conflictingSif)))
}
overallSif <- rbind(as.matrix(compatibleSif), as.matrix(conflictingSif))
overallSif <- unique(overallSif)
write.table(overallSif, file=paste0(resultPrefix, "overall.sif"),
sep="\t", quote=FALSE, col.names=FALSE, row.names=FALSE, na="")
conflictingFormat <- read.table(paste0(resultPrefix, "conflicting.format"), sep="\t")
compatibleFormat <- read.table(paste0(resultPrefix, "compatible.format"), sep="\t")
conflictingFormat$V4 <- sub("0 100 0", "0 255 255", conflictingFormat$V4)
conflictingFormat$V4 <- sub("100 0 0", "255 0 255", conflictingFormat$V4)
# Only merge edge data
overallFormat <- rbind(compatibleFormat, conflictingFormat[conflictingFormat$V1 == "edge", ])
write.table(overallFormat, file=paste0(resultPrefix, "overall.format"),
sep="\t", quote=FALSE, col.names=FALSE, row.names=FALSE, na="")
```
## Parse Causality SIF
```{r}
# Get results to plot
causalityResults <- conflictingResults
g <- generateCausalityIgraph(causalityResults)
plot(g, layout=layout.fruchterman.reingold,
edge.arrow.width=0.5, edge.arrow.size=0.5, edge.color=E(g)$color, edge.lty=E(g)$lty,
vertex.color=V(g)$color, vertex.label.cex=0.5)
```
## Session Info
```{r, eval=FALSE}
sessionInfo()
```