Unconfigured Ad

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

    #1

    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
                            Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
                            by SEQadmin2



                            Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

                            Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
                            ...
                            10-14-2026, 09:55 AM
                          • SEQadmin2
                            New Genomics Technologies Take Aim at Long-Standing Limits
                            by SEQadmin2


                            Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

                            We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
                            ...
                            09-28-2026, 10:25 AM

                          ad_right_rmr

                          Collapse

                          News

                          Collapse

                          Topics Statistics Last Post
                          Started by SEQadmin2, 10-15-2026, 10:52 AM
                          0 responses
                          17 views
                          0 reactions
                          Last Post SEQadmin2  
                          Started by SEQadmin2, 10-14-2026, 05:39 AM
                          0 responses
                          26 views
                          0 reactions
                          Last Post SEQadmin2  
                          Started by SEQadmin2, 10-13-2026, 09:56 AM
                          0 responses
                          22 views
                          0 reactions
                          Last Post SEQadmin2  
                          Started by SEQadmin2, 10-09-2026, 11:14 AM
                          0 responses
                          28 views
                          0 reactions
                          Last Post SEQadmin2  
                          Working...