Seqanswers Leaderboard Ad

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

    [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


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


      • #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
          Quality Control Essentials for Next-Generation Sequencing Workflows
          by seqadmin




          Like all molecular biology applications, next-generation sequencing (NGS) workflows require diligent quality control (QC) measures to ensure accurate and reproducible results. Proper QC begins at nucleic acid extraction and continues all the way through to data analysis. This article outlines the key QC steps in an NGS workflow, along with the commonly used tools and techniques.

          Nucleic Acid Quality Control
          Preparing for NGS starts with isolating the...
          02-10-2025, 01:58 PM
        • seqadmin
          An Introduction to the Technologies Transforming Precision Medicine
          by seqadmin


          In recent years, precision medicine has become a major focus for researchers and healthcare professionals. This approach offers personalized treatment and wellness plans by utilizing insights from each person's unique biology and lifestyle to deliver more effective care. Its advancement relies on innovative technologies that enable a deeper understanding of individual variability. In a joint documentary with our colleagues at Biocompare, we examined the foundational principles of precision...
          01-27-2025, 07:46 AM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by seqadmin, 02-07-2025, 09:30 AM
        0 responses
        72 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 02-05-2025, 10:34 AM
        0 responses
        113 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 02-03-2025, 09:07 AM
        0 responses
        89 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 01-31-2025, 08:31 AM
        0 responses
        49 views
        0 likes
        Last Post seqadmin  
        Working...
        X