-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathFunctionsBank.R
More file actions
55 lines (36 loc) · 1.67 KB
/
FunctionsBank.R
File metadata and controls
55 lines (36 loc) · 1.67 KB
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
# LIST OF FUNCTIONS
# Functions developed by Gendoo, Ghoraie, and El-Hachem for DNF publication (Cancer Research 2017)
##### constPert #####
constPerturbationLayer <- function(pertDat) {
# Correlation for Perturbation
pertCor <- cor(pertDat, method = "pearson", use = "pairwise.complete.obs")
## Calculate affinity matrix (from generic distance) as described in SNFtool package with default values
pertAff <- SNFtool::affinityMatrix(1-pertCor, 20, 0.5)
return(pertAff)
}
##### constSens #####
constSensitivityLayer <- function(sensDat) {
# Correlation for Sensivity
sensCor <- cor(sensDat, method = "pearson", use = "pairwise.complete.obs")
## if NA remaining in cor matrix, replace with 0s, not very clean but no other choices for now
sensCor <- apply(sensCor, 1, function(x) ifelse(is.na(x),0,x))
## Calculate affinity matrix (from generic distance) as described in SNFtool package with default values
sensAff <- SNFtool::affinityMatrix(1-sensCor, 20, 0.5)
return(sensAff)
}
##### Merger #####
integrateStrctSensPert <- function(sensAff, strcAff, pertAff) {
integration <- SNFtool::SNF(list(sensAff, strcAff, pertAff))
colnames(integration) <- rownames(integration) <- colnames(strcAff)
return(integration)
}
##### constStruct #####
constStructureLayer <- function(targFps) {
## Correlation for Structure (Tanimoto metric)
fpSim <- fingerprint::fp.sim.matrix(targFps, method = "tanimoto")
rownames(fpSim) <- names(targFps)
colnames(fpSim) <- names(targFps)
## Calculate affinity matrix (from generic distance) as described in SNFtool package with default values
fpAff <- SNFtool::affinityMatrix(1-fpSim, 20, 0.5)
return(fpAff)
}