aboutsummaryrefslogtreecommitdiff
path: root/scripts/wgcna_analysis.R
diff options
context:
space:
mode:
authorAlexander Kabui2021-09-15 04:34:26 +0300
committerAlexander Kabui2021-09-15 04:34:26 +0300
commitcee10bacd4316eb807c36b8a11e84f9be5945f44 (patch)
treef9095238491fb850722864bed94ce21a1e2bc119 /scripts/wgcna_analysis.R
parent94e2e79141cbddb48456fb5707eb0e4e36e97d3b (diff)
downloadgenenetwork3-cee10bacd4316eb807c36b8a11e84f9be5945f44.tar.gz
minor fixes
Diffstat (limited to 'scripts/wgcna_analysis.R')
-rw-r--r--scripts/wgcna_analysis.R18
1 files changed, 12 insertions, 6 deletions
diff --git a/scripts/wgcna_analysis.R b/scripts/wgcna_analysis.R
index 390bee4..267cd86 100644
--- a/scripts/wgcna_analysis.R
+++ b/scripts/wgcna_analysis.R
@@ -1,3 +1,5 @@
+
+
library(WGCNA);
library(stringi);
@@ -6,6 +8,7 @@ options(stringsAsFactors = FALSE);
imgDir = Sys.getenv("GENERATED_IMAGE_DIR")
# load expression data **assumes csv format row(traits)(columns info+samples)
+# pass the file_path as arg
inputData <- read.csv(file = "wgcna_data.csv")
@@ -13,26 +16,29 @@ inputData <- read.csv(file = "wgcna_data.csv")
dataExpr <- as.data.frame(t(inputData));
-# data cleaning
+## data cleaning
gsg = goodSamplesGenes(dataExpr, verbose = 3);
-
+# https://horvath.genetics.ucla.edu/html/CoexpressionNetwork/Rpackages/
if (!gsg$allOK)
{
-# Optionally, print the gene and sample names that were removed:
if (sum(!gsg$goodGenes)>0)
-printFlush(paste("Removing genes:", paste(names(datExpr0)[!gsg$goodGenes], collapse = ", ")));
+printFlush(paste("Removing genes:", paste(names(dataExpr)[!gsg$goodGenes], collapse = ", ")));
if (sum(!gsg$goodSamples)>0)
-printFlush(paste("Removing samples:", paste(rownames(datExpr0)[!gsg$goodSamples], collapse = ", ")));
+printFlush(paste("Removing samples:", paste(rownames(dataExpr)[!gsg$goodSamples], collapse = ", ")));
# Remove the offending genes and samples from the data:
dataExpr <- dataExpr[gsg$goodSamples, gsg$goodGenes]
}
-# network constructions and modules
+## network constructions and modules
+
+# Allow multi-threading within WGCNA
+enableWGCNAThreads()
# choose softthreshhold (Calculate soft threshold)
+# xtodo allow users to pass args
powers <- c(c(1:10), seq(from = 12, to=20, by=2))
sft <- pickSoftThreshold(dataExpr, powerVector = powers, verbose = 5)