Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • semna
    Member
    • Apr 2010
    • 55

    concatenate??

    Hi
    I have some bed files that I want to concatenate and also I want to have unique file as output(not overlapping). I tried with this script:
    cat files | sort -u
    But it seems that some overlapping. Anyone knows new script for this purpose?
    Thanks in advance.
  • steven
    Senior Member
    • Aug 2009
    • 269

    #2
    you mean that you still have identical lines? that should not happen..
    maybe because of leading/trailing spaces/tabs. i would try to remove them by inserting the command
    sed 's/^[ \t]*//;s/[ \t]*$//'
    between the cat and the sort.

    Comment

    • steven
      Senior Member
      • Aug 2009
      • 269

      #3
      oh, if you mean "overlapping intervals", then try to use BEDtools to collapse/project/contig overlapping intervals -i don't remember the precise command though. does anyone else?

      Comment

      • semna
        Member
        • Apr 2010
        • 55

        #4
        Hi again,
        let me explain more. I have some files like this:
        chr7 27803437 27803887
        chr7 36732616 36732791
        chr7 81504256 81504424
        chr7 101933606 101934986
        chr7 57992467 57993280
        chr7 81973420 81973558
        chr7 43411272 43437604
        I like to concatenate them and want to have unique lines as a result. because I know there are some repeated line that I don't want to come in my final ouput.
        Thanks for your help

        Comment

        • steven
          Senior Member
          • Aug 2009
          • 269

          #5
          well, then your "sort -u" should work fine. do you have an example of unfiltered duplicates?

          Comment

          • semna
            Member
            • Apr 2010
            • 55

            #6
            Hi steven
            Thanks for your help. unfortunately I don't have. if this script is ok how can I test my output in order to sure about the result?
            thanks

            Comment

            • steven
              Senior Member
              • Aug 2009
              • 269

              #7
              yes, you can get duplicated lines by using.. "sort | uniq -d"
              I would just trust "sort -u". Make sure all files come from the same source (windows/linux en of lines differ), have properly tab-separated fields (not some with spaces), have the same number of fields (not some with strand), and do not have trailing spaces.
              I would use the sed command just in case, and test on the final bed file something like
              cat bedfile | awk -F"\t" '{print NF}' | sort -u
              should only return one number (3).

              Comment

              • semna
                Member
                • Apr 2010
                • 55

                #8
                Thanks very much steven. Actually I used your command :cat bedfile | awk -F"\t" '{print NF}' | sort -u . but the result was 1 and 3. So I think it means that something wrong. I found it in some part that there was not tab space. So I am trying to correct it. Honestly I am not good in bioinformatics.
                Thanks

                Comment

                • steven
                  Senior Member
                  • Aug 2009
                  • 269

                  #9
                  ok, let's have a look at these problematic lines, just in case. try
                  awk -F "\t" 'NF!=3'
                  to check them, and if this is about an improper bed format with spaces instead of tabs, try
                  awk '{OFS="\t";print $0}'
                  to correct it.
                  let me know!

                  Comment

                  • semna
                    Member
                    • Apr 2010
                    • 55

                    #10
                    First for second command I try but it's not corrected. but about the first one If I understand I use this:awk -F "\t" 'NF!=3' with my file but the result was just this:
                    track name='HMMSplicer Junctions' description='HMMSplicer Junctions' useScore=1
                    track name='HMMSplicer Non-cannonical Junctions' description='HMMSplicer Non-cannonical Junctions' useScore=1
                    and this is my output in some part:
                    chr6 383200 383444
                    chr6 383254 383453
                    chr6 383254 383456
                    chr6 38339289 38340680
                    chr6 38339296 38340680
                    chr6 38340702 38342087
                    chr6 383468 384211
                    chr6 383476 384207
                    chr6 38352485 38803482
                    chr6 38352516 38356426
                    chr6 38352518 38356428
                    chr6 38356435 38358938
                    some part is space but for the rest is tab. Thanks

                    Comment

                    • steven
                      Senior Member
                      • Aug 2009
                      • 269

                      #11
                      OK
                      looks like some of the bed have a header.
                      i'd then do
                      cat files.bed | awk 'NF==3{OFS="\t";print $1,$2,$3}' | sort -u > merged_unique.bed
                      and i would double check if there are lines starting with something else than "chr" with
                      awk '!/^chr/' merged_unique.bed
                      cheers,
                      s.

                      Comment

                      • semna
                        Member
                        • Apr 2010
                        • 55

                        #12
                        thanks so much steven.it works.great

                        Comment

                        • steven
                          Senior Member
                          • Aug 2009
                          • 269

                          #13
                          cool. welcome.

                          Comment

                          Latest Articles

                          Collapse

                          • SEQadmin2
                            Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
                            by SEQadmin2



                            Genomics studies in neuroscience face a special challenge due to the brain’s complexity and scarcity of samples. Mapping changes in cell type and state using conventional next-generation sequencing methods remains challenging. Advances in technologies like single-cell sequencing, spatial transcriptomics, and long-read sequencing have opened the door to deeper studies of the brain and diseases like Alzheimer’s, amyotrophic lateral sclerosis (ALS), and schizophrenia.
                            ...
                            07-09-2026, 11:10 AM
                          • SEQadmin2
                            Cancer Drug Resistance: The Lingering Barrier to Rising Survival
                            by SEQadmin2



                            Cancer survival rates have significantly increased in the last few decades in the United States, reaching a combined 70% 5-year survival rate by 2021. Behind this number, there are years of research to find new therapies, drug targets, and early detection methods. But there is one core challenge that keeps slowing down these advances, and it’s about drug resistance.

                            There is no single reason why many patients don’t respond to treatment as expected. Cancer is...
                            07-08-2026, 05:17 AM
                          • GATTACAT
                            Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
                            by GATTACAT
                            Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
                            07-01-2026, 11:43 AM

                          ad_right_rmr

                          Collapse

                          News

                          Collapse

                          Topics Statistics Last Post
                          Started by SEQadmin2, 07-13-2026, 10:26 AM
                          0 responses
                          20 views
                          0 reactions
                          Last Post SEQadmin2  
                          Started by SEQadmin2, 07-09-2026, 10:04 AM
                          0 responses
                          32 views
                          0 reactions
                          Last Post SEQadmin2  
                          Started by SEQadmin2, 07-08-2026, 10:08 AM
                          0 responses
                          20 views
                          0 reactions
                          Last Post SEQadmin2  
                          Started by SEQadmin2, 07-07-2026, 11:05 AM
                          0 responses
                          34 views
                          0 reactions
                          Last Post SEQadmin2  
                          Working...