Mercurial > repos > petrn > repeatexplorer
comparison lib/tarean/mgblast2GL.R @ 0:f6ebec6e235e draft
Uploaded
author | petrn |
---|---|
date | Thu, 19 Dec 2019 13:46:43 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f6ebec6e235e |
---|---|
1 #!/usr/bin/env Rscript | |
2 ## get script dir: | |
3 initial.options <- commandArgs(trailingOnly = FALSE) | |
4 file.arg.name <- "--file=" | |
5 script.name <- sub(file.arg.name, "", initial.options[grep(file.arg.name, initial.options)]) | |
6 script.dir <- normalizePath(dirname(script.name)) | |
7 fout <- commandArgs(T)[[2]] | |
8 | |
9 source(paste(script.dir, "/methods.R", sep='')) | |
10 suppressPackageStartupMessages (library(igraph)) | |
11 fin <- commandArgs(T)[[1]] | |
12 | |
13 colcls = rep("NULL", 12) | |
14 colcls[c(1,5,11)] = c("character","character","numeric") | |
15 cat("loading mgblast table\n") | |
16 df = read.table(pipe(paste("cut -f1,5,11 ",fin)), sep="\t",comment.char="", as.is=TRUE, header= FALSE, colClasses = c("character","character","numeric")) | |
17 | |
18 cat("creating graph\n") | |
19 GL = list() | |
20 colnames(df) = c("V1", "V2", "weight") | |
21 GL$G = graph.data.frame(df , directed = FALSE) | |
22 print(summary(GL$G)) | |
23 cat("calculating ogdf layouts\n") | |
24 try({ | |
25 L1 <- OGDFlayout(GL$G, alg=c("fmmm")) | |
26 }) | |
27 cat("calculating fruchterman reingold layouts\n") | |
28 | |
29 L2 = layout.fruchterman.reingold(GL$G,dim=3) | |
30 if (class(L1) != "try-error"){ | |
31 GL$L <- cbind(L1[[1]],L2) | |
32 }else{ | |
33 GL$L <- L2 | |
34 } | |
35 cat("saving output\n") | |
36 save(GL, file=fout) |