-
Notifications
You must be signed in to change notification settings - Fork 0
/
03-relateModsToExt.R
44 lines (40 loc) · 1.47 KB
/
03-relateModsToExt.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
library(ggh4x)
library(reshape2)
library(ggplot2)
library(data.table)
library(tidyr)
library(rlist)
library(stringr)
library(readxl)
library(forcats)
library(tidyverse)
library(WGCNA)
setwd(dirname(rstudioapi::getActiveDocumentContext()$path))
dirname(rstudioapi::getActiveDocumentContext()$path)
# The following setting is important, do not omit.
options(stringsAsFactors = FALSE);
allowWGCNAThreads()
enableWGCNAThreads()
lnames = load(file = "mrna-01-dataInput.RData");
#The variable lnames contains the names of loaded variables.
lnames
# Load network data saved in the second part.
lnames = load(file = "mrna-02-networkConstruction-auto_signed_20220927.RData");
# Define numbers of genes and samples
nGenes = ncol(datExpr);
nSamples = nrow(datExpr);
# Recalculate MEs with color labels
MEs0 = moduleEigengenes(datExpr, moduleColors)$eigengenes
MEs = orderMEs(MEs0)
#moduleTraitCor = cor(MEs, datTraits[,c(1,2,18:35)], use = "p")
moduleTraitCor = cor(MEs, datTraits, use = "p")#student asymptotic p-value for given correlations.
#?cor
moduleTraitPvalue = corPvalueStudent(moduleTraitCor, nSamples);
#??corPvalueStudent
colnames <- colnames(moduleTraitPvalue)
rownames <- rownames(moduleTraitPvalue)
moduleTraitPvalue <- matrix(p.adjust(as.vector(as.matrix(moduleTraitPvalue)), method='fdr'),ncol=8)
colnames(moduleTraitPvalue) <- colnames
rownames(moduleTraitPvalue) <- rownames
moduleTraitPvalue <- -log10(moduleTraitPvalue)
####Submit to plotting####