-1

I have a shiny like below, where I can add genomic coordinate and separate them by Space. I would like to know, how can I save data in a .bed format.

Code:

ui <- fluidPage(
textAreaInput("list", "Input List"),
actionButton("submit", "Submit",  style="color: white; background-color: gray; border-color: black"),
downloadButton("download", "Download results", style="color: white; background-color: gray; border-color: black"),
mainPanel(  textOutput("out") )
)

server <- function(input, output, session) {
  my_text <- reactive({
    data.matrix(input$list)
  }) %>% 
    shiny::bindCache(input$list
    ) %>% 
shiny::bindEvent(input$submit)
  output$out  <- renderText({
   my_text()
  })

## Download results
 shinyjs::disable("download")
observeEvent(my_text(), {
shinyjs::enable("download")
})

output$download <- downloadHandler(
 filename = ".csv",
 content = function(file) {
   write.csv(my_text(), file, row.names = FALSE,sep="\t")
  }
)
}

shinyApp(ui, server)

enter image description here

I would like to save them like below, each region in a given row and separated by Tab

chr1 10 20
chr2 20 30
star
  • 743
  • 1
  • 7
  • 19

1 Answers1

0

I don't know anything about bed files or their specifications, and no information is in the question. However, if all you need to do is write tab-separated files that is a simple task. You can try using write.table, specifying \t (tab) as a separator. Here is a small example:

write.table(x = df, sep = "\t", file = "file.bed)
mhovd
  • 3,724
  • 2
  • 21
  • 47