Header Leaderboard Ad

Collapse

Comparing data from two columns

Collapse

Announcement

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

  • 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!

  • #2
    >sort
    >join

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

    [[email protected] ~]$ join -v 1 -j 3 file1.sort file2.sort # All lines from file 1 found a match
    [[email protected] ~]$ join -v 2 -j 3 file1.sort file2.sort # Lines missing a match
    2_1234 2 1234 EFGH2
    2_1234566 2 123456 EFGH2
    [[email protected] ~]$ 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
    [[email protected] ~]$

    Comment


    • #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

      [[email protected] ~]$ join -v 1 -j 3 file1.sort file2.sort # All lines from file 1 found a match
      [[email protected] ~]$ join -v 2 -j 3 file1.sort file2.sort # Lines missing a match
      2_1234 2 1234 EFGH2
      2_1234566 2 123456 EFGH2
      [[email protected] ~]$ 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
      [[email protected] ~]$

      Comment


      • #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
          Targeted Sequencing: Choosing Between Hybridization Capture and Amplicon Sequencing
          by seqadmin




          Targeted sequencing is an effective way to sequence and analyze specific genomic regions of interest. This method enables researchers to focus their efforts on their desired targets, as opposed to other methods like whole genome sequencing that involve the sequencing of total DNA. Utilizing targeted sequencing is an attractive option for many researchers because it is often faster, more cost-effective, and only generates applicable data. While there are many approaches...
          03-10-2023, 05:31 AM
        • seqadmin
          Expert Advice on Automating Your Library Preparations
          by seqadmin



          Using automation to prepare sequencing libraries isn’t a new concept, and most researchers are aware that there are numerous benefits to automating this process. However, many labs are still hesitant to switch to automation and often believe that it’s not suitable for their lab. To combat these concerns, we’ll cover some of the key advantages, review the most important considerations, and get real-world advice from automation experts to remove any lingering anxieties....
          02-21-2023, 02:14 PM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by seqadmin, 03-17-2023, 12:32 PM
        0 responses
        7 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 03-15-2023, 12:42 PM
        0 responses
        17 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 03-09-2023, 10:17 AM
        0 responses
        66 views
        1 like
        Last Post seqadmin  
        Started by seqadmin, 03-03-2023, 12:03 PM
        0 responses
        64 views
        0 likes
        Last Post seqadmin  
        Working...
        X