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

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by seqadmin, 03-03-2025, 01:15 PM
        0 responses
        149 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 02-28-2025, 12:58 PM
        0 responses
        223 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 02-24-2025, 02:48 PM
        0 responses
        590 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 02-21-2025, 02:46 PM
        0 responses
        259 views
        0 likes
        Last Post seqadmin  
        Working...
        X