#' Creates HTML links to an UCSC Genome Browser from a feature file.
#'
#' @param i <bed/gff/vcf> > out.html
#' @param base The browser basename. Default: http://genome.ucsc.edu
#'
#' @param org The organism. Default: human
#'
#' @param db The build. Default: hg18
#'
#' @param output Output filepath instead of returning output in R.
#'
bt.links <- function(i, base = NULL, org = NULL, db = NULL, output = NULL)
{
# Required Inputs
i <- establishPaths(input=i, name="i", allowRobjects=TRUE)
options <- ""
# Options
options <- createOptions(names=c("base", "org", "db"), values=list(base, org, db))
# establish output file
tempfile <- tempfile("bedtoolsr", fileext=".txt")
tempfile <- gsub("\\", "/", tempfile, fixed=TRUE)
bedtools.path <- getOption("bedtools.path")
if(!is.null(bedtools.path)) bedtools.path <- paste0(bedtools.path, "/")
cmd <- paste0(bedtools.path, "bedtools links ", options, " -i ", i[[1]], " > ", tempfile)
if(.Platform$OS.type == "windows") shell(cmd) else system(cmd)
if(!is.null(output)) {
if(file.info(tempfile)$size > 0)
file.copy(tempfile, output)
} else {
if(file.info(tempfile)$size > 0)
results <- utils::read.table(tempfile, header=FALSE, sep="\t", quote='')
else
results <- data.frame()
}
# Delete temp files
temp.files <- c(tempfile, i[[2]])
deleteTempFiles(temp.files)
if(is.null(output))
return(results)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.