Hi,

I have managed to merge two different files using a common column which has the same information using the below function:

    Combine_Files <- merge(File1, File2, by="Symbols")

However, I would like to know if its possible to merge two different *.csv files i.e. one file (file 1) with the gene symbols only (one gene per row), and the other file (file 2) with the gene symbols and other annotation columns (many related genes per row separated by comma but one of the gene is common as (file 1). I would like to merge both the files based on the mapping of the gene symbols from file1 and extract other annotations columns from (file 2) in the combined file for further data analysis. I would like to know how this could be done.

For example: File_1

        Gene_Symbols
    
     1. GeneA1
     2. GeneA2
     3. GeneA3

For example: File_2

        Gene_Symbols
    
     1. GeneA1, GeneX1, GeneX2, GeneD
     2. GeneA2, GeneL1, GeneP2, GeneNA
     3. GeneB3, GeneA3, GeneLP1, GeneNA1

Other columns in File_2

    Phenotype, GO Ontology, Pathways

Expected Output

    Gene_Symbols, Phenotype, GO Ontology, Pathways

Thank you,

Toufiq



Use the `tidyr` package. The function `separate_rows` will allow you to take you file_2 and split each row so that each row has only one gene symbol, and the information in the other columns is copied. Thus

    GeneA1,GeneX1,GeneX2    WO cell processes Pathway 1

becomes

    GeneA1    WO cell processes Pathway 1
    GeneX1    WO cell processes Pathway 1
    GeneX2    WO cell processes Pathway 1

You can then do your merge as before. 