Skip to content

Instantly share code, notes, and snippets.

@wckdouglas
Last active February 1, 2016 22:39
Show Gist options
  • Save wckdouglas/c4049cc584020a32d909 to your computer and use it in GitHub Desktop.
Save wckdouglas/c4049cc584020a32d909 to your computer and use it in GitHub Desktop.
#!/bin/env Rscript
library(RMySQL)
library(dplyr)
library(stringr)
library(readr)
conn <- dbConnect(MySQL(),
user='genome',
dbname='hg38',
host='genome-mysql.cse.ucsc.edu')
bedFile <- 'repUCSC.bed'
df <- dbSendQuery(conn,'select genoName,genoStart,genoEnd,
repName,swScore, strand,
repClass, repFamily from rmsk') %>%
dbFetch(n=-1) %>%
mutate(genoName = str_replace(genoName,'chr','')) %>%
tbl_df %>%
write_tsv(bedFile,col_names=F)
message('written ',bedFile)
dbDisconnect(conn)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment