Seqanswers Leaderboard Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • ron128
    Member
    • Sep 2011
    • 38

    Comparing data from two columns

    Hello everybody,
    I am analysing variant calls from two different pipelines. What i need to do for my downstream analysis is combine all the variant calls into a single file, column.

    eg:

    file 1:
    Chr Position Chr_position gene_id
    1 1234 1_1234 ABCD
    1 12345 1_12345 ABCD
    1 123456 1_123456 ZXYW

    file2:
    Chr Position Chr_position protein_id
    1 1234 1_1234 ABCD1
    2 1234 2_1234 EFGH2
    2 123456 2_1234566 EFGH2
    1 12345 1_12345 ABCD1
    1 123456 1_123456 ABCD1

    What i would like to do is the following:

    file 3:
    Chr Position Chr_position gene_id protein_id
    1 1234 1_1234 ABCD ABCD1
    1 12345 1_12345 ABCD ABCD1
    1 123456 1_123456 ZXYW ABCD1
    2 1234 2_1234 EFGH2
    2 123456 2_1234566 EFGH2

    The number of rows in both the files are different, so using the Match option in excel is not going to work out. using Mysql is an option, but I am not that well versed in SQL. is there a way i could do this using AWK or any other scripting language? I am at a loss working on this! Any inputs would be mightily appreciated. Thanks!
  • pallevillesen
    Member
    • May 2012
    • 19

    #2
    >sort
    >join

    cat file1 |sort >file1.sort
    cat file2 |sort >file2.sort

    [palle@fe1 ~]$ join -v 1 -j 3 file1.sort file2.sort # All lines from file 1 found a match
    [palle@fe1 ~]$ join -v 2 -j 3 file1.sort file2.sort # Lines missing a match
    2_1234 2 1234 EFGH2
    2_1234566 2 123456 EFGH2
    [palle@fe1 ~]$ join -j 3 file1.sort file2.sort # Matched lines
    1_1234 1 1234 ABCD 1 1234 ABCD1
    1_12345 1 12345 ABCD 1 12345 ABCD1
    1_123456 1 123456 ZXYW 1 123456 ABCD1
    [palle@fe1 ~]$

    Comment

    • ron128
      Member
      • Sep 2011
      • 38

      #3
      many thanks! I will try this out and post the results.

      Originally posted by pallevillesen View Post
      >sort
      >join

      cat file1 |sort >file1.sort
      cat file2 |sort >file2.sort

      [palle@fe1 ~]$ join -v 1 -j 3 file1.sort file2.sort # All lines from file 1 found a match
      [palle@fe1 ~]$ join -v 2 -j 3 file1.sort file2.sort # Lines missing a match
      2_1234 2 1234 EFGH2
      2_1234566 2 123456 EFGH2
      [palle@fe1 ~]$ join -j 3 file1.sort file2.sort # Matched lines
      1_1234 1 1234 ABCD 1 1234 ABCD1
      1_12345 1 12345 ABCD 1 12345 ABCD1
      1_123456 1 123456 ZXYW 1 123456 ABCD1
      [palle@fe1 ~]$

      Comment

      • ron128
        Member
        • Sep 2011
        • 38

        #4
        Dude, Many many thanks! this is working out absolutely fine now. Looks like i should explore more of the Unix environment tools! This has streamlined my analysis and cut down a lot of time. Thanks a loT!

        Comment

        Latest Articles

        Collapse

        • seqadmin
          New Genomics Tools and Methods Shared at AGBT 2025
          by seqadmin


          This year’s Advances in Genome Biology and Technology (AGBT) General Meeting commemorated the 25th anniversary of the event at its original venue on Marco Island, Florida. While this year’s event didn’t include high-profile musical performances, the industry announcements and cutting-edge research still drew the attention of leading scientists.

          The Headliner
          The biggest announcement was Roche stepping back into the sequencing platform market. In the years since...
          03-03-2025, 01:39 PM
        • seqadmin
          Investigating the Gut Microbiome Through Diet and Spatial Biology
          by seqadmin




          The human gut contains trillions of microorganisms that impact digestion, immune functions, and overall health1. Despite major breakthroughs, we’re only beginning to understand the full extent of the microbiome’s influence on health and disease. Advances in next-generation sequencing and spatial biology have opened new windows into this complex environment, yet many questions remain. This article highlights two recent studies exploring how diet influences microbial...
          02-24-2025, 06:31 AM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by seqadmin, Today, 05:03 AM
        0 responses
        15 views
        0 reactions
        Last Post seqadmin  
        Started by seqadmin, Yesterday, 07:27 AM
        0 responses
        12 views
        0 reactions
        Last Post seqadmin  
        Started by seqadmin, 03-18-2025, 12:50 PM
        0 responses
        14 views
        0 reactions
        Last Post seqadmin  
        Started by seqadmin, 03-03-2025, 01:15 PM
        0 responses
        185 views
        0 reactions
        Last Post seqadmin  
        Working...