changeset 11:f2d2ec70b7d8 draft

Uploaded
author spficklin
date Fri, 06 Dec 2019 13:15:46 -0500
parents 96ba1a8fff06
children b6e5663f3be3
files aurora_wgcna_trait.Rmd
diffstat 1 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/aurora_wgcna_trait.Rmd	Fri Dec 06 13:15:35 2019 -0500
+++ b/aurora_wgcna_trait.Rmd	Fri Dec 06 13:15:46 2019 -0500
@@ -8,6 +8,9 @@
 ```{r setup, include=FALSE, warning=FALSE, message=FALSE}
 knitr::opts_chunk$set(error = FALSE, echo = FALSE)
 ```
+```{r, include=FALSE}
+options(tinytex.verbose = TRUE)
+```
 ```{r}
 # Load the data from the previous step.
 load(file=opt$r_data)
@@ -64,7 +67,7 @@
   hkeep = c()
   hignore = c()
   for (field in one_hot_cols[[i]]) {
-    
+
     # Make sure the field is categorical. If it came in as integer it must be switched.
     if (trait_types[[field]] == "integer") {
       trait_data[[field]] = as.factor(trait_data[[field]])
@@ -74,7 +77,7 @@
       print(field)
       next
     }
-    
+
     # Now make sure we have enough factors.
     if (nlevels(trait_data[[field]]) > 1) {
       hkeep[length(hkeep)+1] = field
@@ -82,17 +85,17 @@
       hignore[length(hignore)+1] = field
     }
   }
-  
+
   if (length(hignore) > 0) {
     print('These fields were ignored due to too few factors:')
     print(hignore)
   }
-  
+
   # Perform the 1-hot encoding for specified and valid fields.
   if (length(hkeep) > 0) {
     print('These fields were be 1-hot encoded:')
     print(hkeep)
-    
+
     swap_cols = colnames(trait_data)[(colnames(trait_data) %in% hkeep)]
     temp = as.data.frame(trait_data[, swap_cols])
     colnames(temp) = swap_cols
@@ -100,12 +103,12 @@
     dmy <- dummyVars(" ~ .", data = temp)
     encoded <- data.frame(predict(dmy, newdata = temp))
     encoded =  sapply(encoded, as.integer)
-  
+
     # Make a new trait_data table with these new 1-hot fields.
     keep_cols = colnames(trait_data)[!(colnames(trait_data) %in% one_hot_cols[[1]])]
     keep = as.data.frame(trait_data[, keep_cols])
     colnames(keep) = keep_cols
-  
+
     # Make a new trait_data object that has the columns to keep and the new 1-hot columns.
     trait_data = cbind(keep, encoded)
   }