Renaming Bedtools outputs individually
1
0
Entering edit mode
6.7 years ago
Noob • 0

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.0k views
ADD COMMENT
0
Entering edit mode
6.7 years ago
dr_bantz ▴ 110

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"
ADD COMMENT

Login before adding your answer.

Traffic: 1830 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6