This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Renaming Bedtools outputs individually

I ran a Bedtools function to extract particular segments from a genome I am working with and got an output with all of them however they are all named with the word "unspecified" and a number. I want to name these all using R scripts based on their chromosome location but I am not sure how to go about this at all. Any help?

r genome sequence gene

1 answer

Let's say your file has the following columns:

  1. chromosome
  2. start
  3. end
  4. name

You read this into R as "data":

data <- read.table("file.bed", sep = "\t", colnames = c("chromosome", "start", "end", "name")

In R, it's pretty easy to rename based on position:

data[data$chromosome == "I" & data$start > 300 & data$start <1000, "name"] <- "segment_name"

Log in to answer this question.