Mercurial > repos > petr-novak > various_galaxy_tools
annotate gff2tabular.R @ 3:1069776f7ae2 draft default tip
planemo upload for repository https://github.com/kavonrtep/galaxy_packages commit 3b9f93ed06cc32dbfa271789739e7a1e8fac528c
author | petr-novak |
---|---|
date | Tue, 30 Apr 2024 08:27:27 +0000 |
parents | 639c0edb7e64 |
children |
rev | line source |
---|---|
0
696e702ebf74
"planemo upload commit 0f6eca49bafc3c946189d793161a7f81d595e1a1-dirty"
petr-novak
parents:
diff
changeset
|
1 #!/usr/bin/env Rscript |
696e702ebf74
"planemo upload commit 0f6eca49bafc3c946189d793161a7f81d595e1a1-dirty"
petr-novak
parents:
diff
changeset
|
2 library(rtracklayer) |
696e702ebf74
"planemo upload commit 0f6eca49bafc3c946189d793161a7f81d595e1a1-dirty"
petr-novak
parents:
diff
changeset
|
3 gff <- import(commandArgs(T)[1], format='GFF') |
696e702ebf74
"planemo upload commit 0f6eca49bafc3c946189d793161a7f81d595e1a1-dirty"
petr-novak
parents:
diff
changeset
|
4 tabular <- as.data.frame(gff) |
1
639c0edb7e64
planemo upload for repository https://github.com/kavonrtep/galaxy_packages commit 248ffeb6792d5807820b664eae3e88306f3f395e-dirty
petr-novak
parents:
0
diff
changeset
|
5 head(tabular) |
639c0edb7e64
planemo upload for repository https://github.com/kavonrtep/galaxy_packages commit 248ffeb6792d5807820b664eae3e88306f3f395e-dirty
petr-novak
parents:
0
diff
changeset
|
6 # some columns are lists, we need to convert them to vectors before writing to file |
639c0edb7e64
planemo upload for repository https://github.com/kavonrtep/galaxy_packages commit 248ffeb6792d5807820b664eae3e88306f3f395e-dirty
petr-novak
parents:
0
diff
changeset
|
7 for (i in 1:ncol(tabular)){ |
639c0edb7e64
planemo upload for repository https://github.com/kavonrtep/galaxy_packages commit 248ffeb6792d5807820b664eae3e88306f3f395e-dirty
petr-novak
parents:
0
diff
changeset
|
8 if (is.list(tabular[[i]])){ |
639c0edb7e64
planemo upload for repository https://github.com/kavonrtep/galaxy_packages commit 248ffeb6792d5807820b664eae3e88306f3f395e-dirty
petr-novak
parents:
0
diff
changeset
|
9 tabular[[i]] <- sapply(tabular[[i]], function(x) paste(x, collapse = ";")) |
639c0edb7e64
planemo upload for repository https://github.com/kavonrtep/galaxy_packages commit 248ffeb6792d5807820b664eae3e88306f3f395e-dirty
petr-novak
parents:
0
diff
changeset
|
10 } |
639c0edb7e64
planemo upload for repository https://github.com/kavonrtep/galaxy_packages commit 248ffeb6792d5807820b664eae3e88306f3f395e-dirty
petr-novak
parents:
0
diff
changeset
|
11 } |
0
696e702ebf74
"planemo upload commit 0f6eca49bafc3c946189d793161a7f81d595e1a1-dirty"
petr-novak
parents:
diff
changeset
|
12 write.table(tabular, file = commandArgs(T)[2], quote=FALSE, sep="\t", row.names=FALSE) |
696e702ebf74
"planemo upload commit 0f6eca49bafc3c946189d793161a7f81d595e1a1-dirty"
petr-novak
parents:
diff
changeset
|
13 |