This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Merging two files based on the identifier column (gene symbols)

Hi,

I have two different *.csv files with different column headers except one column, i.e, one with the gene symbols and expression data (samples), and the other with the gene symbols and phenotypic data/attributes, in both the files, one column (gene symbols) is same. I would like to merge both the files based on mapping with the gene symbol column and save all the data in one file for further data analysis. I would like to know how this could be done.

Thank you,

Toufiq

gene-annotation r

Have you read the help page of the merge function?

?merge

1 answer

This can be done in the terminal with the join utility (sort the files on gene symbol first), e.g. join -a1 -a2 file1.csv file2.csv

The -a option is used to keep unpairable lines from the corresponding file, i.e. in case a gene symbol is in one file but not the other.

Log in to answer this question.