Identifying Genes in Gene_table1 that are also present in Gene_table2 and produce a new Gene_tabel with information from Gene_table2
0
0
Entering edit mode
3.5 years ago
Ksandersen ▴ 20

Hello All

I have two gene tables in R. I want to make some code, which can do the following.

  1. Take the genes in Gene_Tabel1 and compare if they are present in Gene_tabel2
  2. If The genes are present in Gene_Tabel2 I want to add the information from Gene_Table2 into a new Table as shown in Gene_Table3

I believe this could be done through a loop and some extra coding. However, I do not know exactly to produce this code (I am very new to coding).

Gene_Tabel1:

     Gene
1   ENSDARG00000063908
2   ENSDARG00000070083
3   ENSDARG00000063911
4   ENSDARG00000099499
5   ENSDARG00000092553
6   ENSDARG00000056008
7   ENSDARG00000098355
8   ENSDARG00000088383
9   ENSDARG00000063924
10   ENSDARG00000068738

etc...

Gene_Tabel2:

     Gene
1   ENSDARG00000102123   phtf2
2   ENSDARG00000114503   phtf21
3   ENSDARG00000070083   atp5f1b
4   ENSDARG00000098311   si:zfos-932h1.3
5   ENSDARG00000104839   mansc1
6   ENSDARG00000100143   Irp6
7   ENSDARG00000068738   dusp16
8   ENSDARG00000104049   crebl2
9   ENSDARG00000102226   gpr19
10  ENSDARG00000103095   tbk1

etc...

Gene_Tabel3:

    Gene
1: ENSDARG00000070083   atp5f1b
2: ENSDARG00000068738   dusp16

I hope there is someone who can give me a helping hand.

Best Regards
Kristian Andersen

RNA-Seq R • 951 views
ADD COMMENT
2
Entering edit mode

You should look into the merge function. That does exactly what you're looking for.

ADD REPLY
1
Entering edit mode

Thanks for the hint. :) I figured out how to do the merging.

I used the following code:

merge(Gene_Table1, Gene_Table2, by = "Gene", sort = FALSE)
ADD REPLY
0
Entering edit mode

Could you posible provide me with the coding? It doesn't seem to work for me?

ADD REPLY
1
Entering edit mode

Please read up on the documentation and show us what you've tried. Asking for exact code is not good etiquette.

ADD REPLY
0
Entering edit mode

Would linux commands work for you? AWK and grep?

ADD REPLY
1
Entering edit mode

Please do not supply users with code - it interferes with their learning.

ADD REPLY
0
Entering edit mode

Can you post some example data from both tables using dput(head(Gene_Table1)) and dput(head(Gene_Table2))?

ADD REPLY

Login before adding your answer.

Traffic: 2826 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6