forked from edo98811/WGCNA_official_documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimulated-02-dataLoading.R
66 lines (50 loc) · 2.11 KB
/
Simulated-02-dataLoading.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
#=====================================================================================
#
# 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)
# The following setting is important, do not omit.
options(stringsAsFactors = FALSE);
#=====================================================================================
#
# Code chunk 2
#
#=====================================================================================
datGeneSummary=read.csv("GeneSummaryTutorial.csv")
datTraits=read.csv("TraitsTutorial.csv")
datMicroarrays=read.csv("MicroarrayDataTutorial.csv")
#=====================================================================================
#
# Code chunk 3
#
#=====================================================================================
# This vector contains the microarray sample names
ArrayName= names(data.frame(datMicroarrays[,-1]))
# This vector contains the gene names
GeneName= datMicroarrays$GeneName
# We transpose the data so that the rows correspond to samples and the columns correspond to genes
# Since the first column contains the gene names, we exclude it.
datExpr=data.frame(t(datMicroarrays[,-1]))
names(datExpr)=datMicroarrays[,1]
dimnames(datExpr)[[1]]=names(data.frame(datMicroarrays[,-1]))
#Also, since we simulated the data, we know the true module color:
truemodule= datGeneSummary$truemodule
rm(datMicroarrays)
collectGarbage()
#=====================================================================================
#
# Code chunk 4
#
#=====================================================================================
# First, make sure that the array names in the file datTraits line up with those in the microarray data
table( dimnames(datExpr)[[1]]==datTraits$ArrayName)
# Next, define the microarray sample trait
y=datTraits$y