forked from edo98811/WGCNA_official_documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimulated-08-Visualization.R
121 lines (93 loc) · 3.68 KB
/
Simulated-08-Visualization.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
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
#=====================================================================================
#
# Code chunk 1
#
#=====================================================================================
# Display the current working directory
getwd();
# If necessary, change the path below to the directory where the data files are stored.
# "." means current directory. On Windows use a forward slash / instead of the usual \.
workingDir = ".";
setwd(workingDir);
# Load WGCNA package
library(WGCNA)
library(cluster)
# The following setting is important, do not omit.
options(stringsAsFactors = FALSE);
# Load the previously saved data
load("Simulated-RelatingToExt.RData");
load("Simulated-Screening.RData")
#=====================================================================================
#
# Code chunk 2
#
#=====================================================================================
cmd1=cmdscale(as.dist(dissTOM),2)
sizeGrWindow(7, 6)
par(mfrow=c(1,1))
plot(cmd1, col=as.character(colorh1), main="MDS plot",
xlab="Scaling Dimension 1", ylab="Scaling Dimension 2")
#=====================================================================================
#
# Code chunk 3
#
#=====================================================================================
power=6
color1=colorDynamicTOM
restGenes= (color1 != "grey")
diss1=1-TOMsimilarityFromExpr( datExpr[, restGenes], power = 6 )
hier1=hclust(as.dist(diss1), method="average" )
diag(diss1) = NA;
sizeGrWindow(7,7)
TOMplot(diss1^4, hier1, as.character(color1[restGenes]),
main = "TOM heatmap plot, module genes" )
#=====================================================================================
#
# Code chunk 4
#
#=====================================================================================
power=6
color1=colorDynamicTOM
restGenes= (color1 != "grey")
diss1=1-adjacency( datExpr[, restGenes], power = 6 )
hier1=hclust(as.dist(diss1), method="average" )
diag(diss1) = NA;
sizeGrWindow(7,7)
TOMplot(diss1^4, hier1, as.character(color1[restGenes]),
main = "Adjacency heatmap plot, module genes" )
#=====================================================================================
#
# Code chunk 5
#
#=====================================================================================
sizeGrWindow(7,7)
topList=rank(NS1$p.Weighted,ties.method="first")<=30
gene.names= names(datExpr)[topList]
# The following shows the correlations between the top genes
plotNetworkHeatmap(datExpr, plotGenes = gene.names,
networkType="signed", useTOM=FALSE,
power=1, main="signed correlations")
#=====================================================================================
#
# Code chunk 6
#
#=====================================================================================
sizeGrWindow(7,7)
# The following shows the correlations between the top genes
plotNetworkHeatmap(datExpr, plotGenes = gene.names,
networkType="unsigned", useTOM=FALSE,
power=1, main="signed correlations")
#=====================================================================================
#
# Code chunk 7
#
#=====================================================================================
sizeGrWindow(7,7)
# The following shows the TOM heatmap in a signed network
plotNetworkHeatmap(datExpr, plotGenes = gene.names,
networkType="signed", useTOM=TRUE,
power=12, main="C. TOM in a signed network")
# The following shows the TOM heatmap in a unsigned network
plotNetworkHeatmap(datExpr, plotGenes = gene.names,
networkType="unsigned", useTOM=TRUE,
power=6, main="D. TOM in an unsigned network")