Skip to content

Instantly share code, notes, and snippets.

@pansapiens
Created August 8, 2019 03:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pansapiens/5f871b5ab104c0dc75d310cfadc54fee to your computer and use it in GitHub Desktop.
Save pansapiens/5f871b5ab104c0dc75d310cfadc54fee to your computer and use it in GitHub Desktop.
gff2gtf.R
#!/usr/bin/env Rscript
# Based on https://www.biostars.org/p/45791/#45804
#
# Usage:
# ./gff2gtf.R genes.gff genes.gtf
#
# Dependencies can be easily installed like:
# conda create -n gff2gtf bioconductor-rtracklayer
# conda activate gff2gtf
# Set a working CRAN mirror
local({r <- getOption("repos")
r["CRAN"] <- "http://cloud.r-project.org"
options(repos=r)
})
# Install pacman and rtracklayer if not present
if (!require("pacman")) {
install.packages("pacman")
}
pacman::p_install(rtracklayer,
try.bioconductor=TRUE,
force=FALSE,
update.bioconductor=TRUE)
library(rtracklayer)
args = commandArgs(trailingOnly=TRUE)
gff_features <- import(args[1])
export(gff_features, args[2], "gtf")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment