aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlexander Kabui2021-09-14 22:31:18 +0300
committerAlexander Kabui2021-09-14 22:31:18 +0300
commit49fdd614d4b18f7d28126e4ebbf3adca57f0416f (patch)
treec7b5e72fa522998305fe602df38026dd42f176fb /scripts
parentea0e92d3f63a9f403aacd5ab1590f61f2752158a (diff)
downloadgenenetwork3-49fdd614d4b18f7d28126e4ebbf3adca57f0416f.tar.gz
Checking data for excessive missing values
Diffstat (limited to 'scripts')
-rw-r--r--scripts/wgcna_analysis.R20
1 files changed, 19 insertions, 1 deletions
diff --git a/scripts/wgcna_analysis.R b/scripts/wgcna_analysis.R
index a8170b6..8e90d7d 100644
--- a/scripts/wgcna_analysis.R
+++ b/scripts/wgcna_analysis.R
@@ -10,10 +10,28 @@ wgcnaRawData <- read.csv(file = "wgcna_data.csv")
# transform expressionData
-datExpr <- as.data.frame(t(wgcnaRawData));
+dataExpr <- as.data.frame(t(wgcnaRawData));
+# data cleaning
+
+# adopted from docs
+gsg = goodSamplesGenes(dataExpr, verbose = 3);
+
+
+
+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 = ", ")));
+if (sum(!gsg$goodSamples)>0)
+printFlush(paste("Removing samples:", paste(rownames(datExpr0)[!gsg$goodSamples], collapse = ", ")));
+# Remove the offending genes and samples from the data:
+dataExpr <- dataExpr[gsg$goodSamples, gsg$goodGenes]
+}
+