aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2021-10-25 15:13:05 +0300
committerFrederick Muriuki Muriithi2021-10-25 15:13:05 +0300
commit5a472ebab04c68cd5228f253cc98d0ae22a520d7 (patch)
tree3d6b1a5a8933896a6e7fdc98f473ef069accd348 /scripts
parent0814eea6b57e45d4337424e63c164d204d03b64d (diff)
parent5440bfcd6940db08c4479a39ba66dbc802b2c426 (diff)
downloadgenenetwork3-5a472ebab04c68cd5228f253cc98d0ae22a520d7.tar.gz
Merge branch 'main' of github.com:genenetwork/genenetwork3 into partial-correlations
Diffstat (limited to 'scripts')
-rw-r--r--scripts/wgcna_analysis.R17
1 files changed, 15 insertions, 2 deletions
diff --git a/scripts/wgcna_analysis.R b/scripts/wgcna_analysis.R
index 17b3537..b0d25a9 100644
--- a/scripts/wgcna_analysis.R
+++ b/scripts/wgcna_analysis.R
@@ -6,11 +6,13 @@ library(rjson)
options(stringsAsFactors = FALSE);
-imgDir = Sys.getenv("GENERATED_IMAGE_DIR")
+cat("Running the wgcna analysis script\n")
+
# load expression data **assumes from json files row(traits)(columns info+samples)
# pass the file_path as arg
# pass the file path to read json data
+
args = commandArgs(trailingOnly=TRUE)
if (length(args)==0) {
@@ -21,6 +23,7 @@ if (length(args)==0) {
}
inputData <- fromJSON(file = json_file_path)
+imgDir = inputData$TMPDIR
trait_sample_data <- do.call(rbind, inputData$trait_sample_data)
@@ -83,6 +86,11 @@ network <- blockwiseModules(dataExpr,
+cat("Generated network \n")
+
+network
+
+
genImageRandStr <- function(prefix){
randStr <- paste(prefix,stri_rand_strings(1, 9, pattern = "[A-Za-z0-9]"),sep="_")
@@ -90,14 +98,19 @@ genImageRandStr <- function(prefix){
return(paste(randStr,".png",sep=""))
}
+
mergedColors <- labels2colors(network$colors)
imageLoc <- file.path(imgDir,genImageRandStr("WGCNAoutput"))
png(imageLoc,width=1000,height=600,type='cairo-png')
+
+cat("Generating the CLuster dendrogram\n")
+
+
plotDendroAndColors(network$dendrograms[[1]],mergedColors[network$blockGenes[[1]]],
"Module colors",
-dendroLabels = FALSE, hang = 0.03,
+dendroLabels = NULL, hang = 0.03,
addGuide = TRUE, guideHang = 0.05)