Question: Identifying Genes in Gene_table1 that are also present in Gene_table2 and produce a new Gene_tabel with information from Gene_table2
0
gravatar for Ksandersen
4 days ago by
Ksandersen10
Ksandersen10 wrote:

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 • 100 views
ADD COMMENTlink modified 4 days ago • written 4 days ago by Ksandersen10
2

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

ADD REPLYlink written 4 days ago by RamRS30k

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

ADD REPLYlink written 4 days ago by Ksandersen10
1

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

ADD REPLYlink written 4 days ago by RamRS30k

Would linux commands work for you? AWK and grep?

ADD REPLYlink modified 4 days ago • written 4 days ago by Fatima630
1

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

ADD REPLYlink written 4 days ago by RamRS30k

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 REPLYlink modified 4 days ago by RamRS30k • written 4 days ago by Ksandersen10

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

ADD REPLYlink written 4 days ago by rpolicastro1.9k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1764 users visited in the last hour