From 49b852baa46c0f06caa2f0621b18d521cf334483 Mon Sep 17 00:00:00 2001 From: Alexander Kabui Date: Tue, 14 Sep 2021 23:40:17 +0300 Subject: function to generate rand str for image --- scripts/wgcna_analysis.R | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/wgcna_analysis.R b/scripts/wgcna_analysis.R index 65ff36e..efe0336 100644 --- a/scripts/wgcna_analysis.R +++ b/scripts/wgcna_analysis.R @@ -1,7 +1,9 @@ # initial workspace setup library(WGCNA); -stringsAsFactors = FALSE +library(stringi); + +options(stringsAsFactors = FALSE); # load expression data **assumes csv format row(traits)(columns info+samples) @@ -64,8 +66,18 @@ mergedColors = labels2colors(net$colors) # generate random name for png && save the image location +genImageRandStr <- function(prefix){ + + randStr <- paste(prefix,stri_rand_strings(1, 9, pattern = "[A-Za-z0-9]"),sep="_") + + return(paste(randStr,".png",sep="")) +} + + + +png(genImageRandStr,width=1000,height=600,type='cairo-png') + -png("WGCNAoutput.png",width=1000,height=600,type='cairo-png') plotDendroAndColors(network$dendrograms[[1]],mergedColors[net$blockGenes[[1]]], "Module colors", -- cgit v1.2.3