Browse code

fix function to allow proper mapping of selected columns to add

Shana White authored on 05/09/2017 17:42:05
Showing 1 changed files

1 1
old mode 100644
2 2
new mode 100755
... ...
@@ -35,9 +35,9 @@ add_edge_data <- function(expanded_edges, KEGG_mappings,
35 35
     
36 36
     expanded_edges <- expanded_edges[expanded_edges$type != "maplink", ]
37 37
     
38
-    if ("pre_mapped" %in% names(user_data)) {
39
-        user_data <- user_data[, -c(which(colnames(user_data) == "pre_mapped"))]
40
-    }
38
+    # if ("pre_mapped" %in% names(user_data)) {
39
+    #     user_data <- user_data[, -c(which(colnames(user_data) == "pre_mapped"))]
40
+    # }
41 41
     
42 42
     if (nrow(expanded_edges) > 0) {
43 43
         
... ...
@@ -84,17 +84,12 @@ add_edge_data <- function(expanded_edges, KEGG_mappings,
84 84
             } else {
85 85
                 edge_set <- expanded_edges_1
86 86
             }
87
-            
87
+
88 88
             edge_set <- edge_set[order(edge_set$unique_ID), ]
89 89
             
90
-            data_to_add <- cbind(as.character(pre_mapped[, "unique_ID"]), 
91
-                                pre_mapped[, data_column_no])
92
-            data_to_add <- data.frame(data_to_add, stringsAsFactors = FALSE)
93
-            names(data_to_add)[1] <- "unique_ID"
94
-            if (ncol(data_to_add) == 2) {
95
-                names(data_to_add)[2] <- names(pre_mapped)[data_column_no]
96
-            }
97
-            
90
+            data_to_add <- data.frame("unique_ID" = pre_mapped$unique_ID, stringsAsFactors = FALSE)
91
+            data_to_add <- cbind(data_to_add, pre_mapped[, data_column_no])
92
+
98 93
             data_to_add <- data_to_add[order(data_to_add$unique_ID), ]
99 94
             
100 95
             annotated_edges <- merge(edge_set, data_to_add, "unique_ID",