-
Notifications
You must be signed in to change notification settings - Fork 0
/
The_nine_coexpression_association_assessment_methods.R
70 lines (63 loc) · 2.55 KB
/
The_nine_coexpression_association_assessment_methods.R
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
load("Ecoli_RNAseq_data.RData")
#Pearson Correlation
cor_c <- cor(t(Ecoli_RNASeq_top1000_randomized))
#Spearman Correlation
cor_c <- cor(t(Ecoli_RNASeq_top1000_randomized), method = "spearman")
#Kendall Correlation
cor_c <- cor(t(Ecoli_RNASeq_top1000_randomized), method = "kendall")
#Mutual Information
library(entropy)
cor_c <- matrix(0, nrow(Ecoli_RNASeq_top1000_randomized), nrow(Ecoli_RNASeq_top1000_randomized))
rownames(cor_c) <- rownames(Ecoli_RNASeq_top1000_randomized)
colnames(cor_c) <- rownames(Ecoli_RNASeq_top1000_randomized)
for (i in 1:nrow(Ecoli_RNASeq_top1000_randomized)) {
for (j in 1:nrow(Ecoli_RNASeq_top1000_randomized)) {
if (i < j) {
disc <- discretize2d(Ecoli_RNASeq_top1000_randomized[i,], Ecoli_RNASeq_top1000_randomized[j,], numBins1 = 5, numBins2 = 5)
cor_c[i, j] <- cor_c[j, i] <- mi.empirical(disc)
}
}
}
#Hoeffding's measure of dependence
library(Hmisc)
cor_c <- hoeffd(t(Ecoli_RNASeq_top1000_randomized))
library(MASS)
library(class
library(cluster)
library(impute)
library(Hmisc)
library(WGCNA)
#Polynomial-Regression based dependence
polyReg_dist <- adjacency.polyReg(t(Ecoli_RNASeq_top1000_randomized), degree = 3, symmetrizationMethod = "mean")
#Spline-Regression based dependence
splineReg_dist <- adjacency.splineReg(t(Ecoli_RNASeq_top1000_randomized), symmetrizationMethod = "mean")
#Distance Covariance
library(energy)
cor_c <- matrix(0, nrow(Ecoli_RNASeq_top1000_randomized), nrow(Ecoli_RNASeq_top1000_randomized))
rownames(cor_c) <- rownames(Ecoli_RNASeq_top1000_randomized)
colnames(cor_c) <- rownames(Ecoli_RNASeq_top1000_randomized)
for (i in 1:nrow(Ecoli_RNASeq_top1000_randomized)) {
for (j in 1:nrow(Ecoli_RNASeq_top1000_randomized)) {
if (i < j) {
cor_c[j, i] <- cor_c[i, j] <- dcov(Ecoli_RNASeq_top1000_randomized[i,], Ecoli_RNASeq_top1000_randomized[j,])
}
}
}
#Weighted Rank Correlation
WRC <- function(x, y) {
RR <- rank(x)
QQ <- rank(y)
N <- length(x)
cc <- 1 - 6 * sum((RR - QQ) ^ 2 * (N - RR + 1 + N - QQ + 1)) / (N ^ 4 + N ^ 3 - N ^ 2 - N)
return(cc)
}
cor_c <- matrix(0, nrow(Ecoli_RNASeq_top1000_randomized), nrow(Ecoli_RNASeq_top1000_randomized))
rownames(cor_c) <- rownames(Ecoli_RNASeq_top1000_randomized)
colnames(cor_c) <- rownames(Ecoli_RNASeq_top1000_randomized)
for (i in 1:nrow(Ecoli_RNASeq_top1000_randomized)) {
for (j in 1:nrow(Ecoli_RNASeq_top1000_randomized)) {
if (i < j) {
cor_c[j, i] <- cor_c[i, j] <- WRC(Ecoli_RNASeq_top1000_randomized[i,], Ecoli_RNASeq_top1000_randomized[j,])
}
}
}