Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bed file coordinate sorting

    Apparently, I don't quite understand how a bed file should be sorted. I can't quite figure out what's wrong.

    Code:
    bedops --ec --everything myData.bed > /dev/null
    May use bedops --help for more help.
    
    Error: in oncosnp.bed
    Bed file not properly sorted by first column.
    See row: 771
    
    cat myData.bed | awk 'NR>=769' | head
    9	138338321	138339032
    9	139327439	140167730
    10	69083	3368595
    10	367632	393272
    10	448018	448786
    10	703003	763714
    10	998193	999290
    10	1084691	1123868
    10	1368946	1369689
    10	1500525	1503838

    Any idea? How does the ordering rule work for bed files?

    A related question: when I used bedtools and use the "-sorted" flag, how should that bed file be sorted?

    Thanks in advance.
    Last edited by lethalfang; 05-18-2014, 07:06 PM.

  • #2
    You treated them as numbers, so they're in numeric order. However, they need to be in lexicographic order, since "10" as a word comes before "9" as a word (the normal order would be something like: 1, 10, 11 ... 19, 2, 3, ...). This will make more sense if you have chromosomes X and Y and/or MT (or are using UCSC chromosome names).

    Comment


    • #3
      Originally posted by lethalfang View Post
      A related question: when I used bedtools and use the "-sorted" flag, how should that bed file be sorted?
      Sort by chromosome (lexicograhic) then by position. Something like this will do

      Code:
      sort -k1,1 -k2,2n -k3,3n a.bed > asort.bed
      (In fact I suspect that for -sorted option to work, what matters is that chromosomes are in the same order in both files).

      By the way, if records within chromosomes are already sorted by position and so you just want to sort chromosomes, use the --stable option in sort. It will save quite some time for big files.

      Comment


      • #4
        You can use BEDOPS sort-bed to sort BED files:



        GNU sort is not as fast as sort-bed (even with various tricks, like --parallel and so forth) and it's easy to get the options wrong.

        Comment

        Latest Articles

        Collapse

        • seqadmin
          Essential Discoveries and Tools in Epitranscriptomics
          by seqadmin




          The field of epigenetics has traditionally concentrated more on DNA and how changes like methylation and phosphorylation of histones impact gene expression and regulation. However, our increased understanding of RNA modifications and their importance in cellular processes has led to a rise in epitranscriptomics research. “Epitranscriptomics brings together the concepts of epigenetics and gene expression,” explained Adrien Leger, PhD, Principal Research Scientist...
          04-22-2024, 07:01 AM
        • seqadmin
          Current Approaches to Protein Sequencing
          by seqadmin


          Proteins are often described as the workhorses of the cell, and identifying their sequences is key to understanding their role in biological processes and disease. Currently, the most common technique used to determine protein sequences is mass spectrometry. While still a valuable tool, mass spectrometry faces several limitations and requires a highly experienced scientist familiar with the equipment to operate it. Additionally, other proteomic methods, like affinity assays, are constrained...
          04-04-2024, 04:25 PM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by seqadmin, 04-25-2024, 11:49 AM
        0 responses
        15 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-24-2024, 08:47 AM
        0 responses
        17 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-11-2024, 12:08 PM
        0 responses
        62 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-10-2024, 10:19 PM
        0 responses
        60 views
        0 likes
        Last Post seqadmin  
        Working...
        X