Browse code

fix gtf/gdm conversion

Simone authored on 18/02/2018 15:59:48
Showing 2 changed files

... ...
@@ -256,6 +256,7 @@ gmql_take <- function(input_data, rows)
256 256
     sampleList <- lapply(list, function(x){
257 257
         x <- x[-1]
258 258
         names(x) <- seq_name
259
+        x$start = x$start +1
259 260
         g <- GenomicRanges::makeGRangesFromDataFrame(x,
260 261
                                     keep.extra.columns = TRUE,
261 262
                                     start.field = "start",
... ...
@@ -174,9 +174,7 @@ read_GRangesList <- function(samples)
174 174
     df <- data.frame(samples)
175 175
     df <- df[-2] #delete group_name
176 176
     len_df <- dim(df)[1] # number of rows
177
-    region_matrix <- as.matrix(vapply(df, as.character,character(len_df)))
178
-    region_matrix[is.na(region_matrix)] <- "NA"
179
-    region_matrix <- region_matrix[,setdiff(colnames(region_matrix),"width")]
177
+
180 178
     col_types <- vapply(df,class,character(1))
181 179
     col_names <- names(col_types)
182 180
     #re order the schema?
... ...
@@ -193,9 +191,13 @@ read_GRangesList <- function(samples)
193 191
         col_names <- plyr::revalue(col_names,c(start = "left", 
194 192
                                         end = "right", seqnames = "chr"))
195 193
         schema_matrix <- cbind(col_names,toupper(col_types))
194
+        df$start = df$start - 1
196 195
         schema_matrix<- schema_matrix[setdiff(rownames(schema_matrix),
197 196
                                         c("group","width")),]
198 197
     }
198
+    region_matrix <- as.matrix(vapply(df, as.character,character(len_df)))
199
+    region_matrix[is.na(region_matrix)] <- "NA"
200
+    region_matrix <- region_matrix[,setdiff(colnames(region_matrix),"width")]
199 201
     rownames(schema_matrix) <- NULL
200 202
     colnames(schema_matrix) <- NULL
201 203