How to merge column text files using terminal command?
2
0
Entering edit mode
7.9 years ago
Genosa ▴ 160

Sorry if this question is really basic, but I'm at loss of trying to find a simple way to join / merge data of 2 cuffdiff output files

in one of the tracking output file, the columns listed are: (let's call this file 1)

tracking_id condition replicate raw_frags internal_scaled_frags external_scaled_frags FPKM effective_length status

In the other file containing differential gene expression analysis, the columns listed are: (let's call this file 2)

test_id gene_id gene locus sample_1 sample_2 status value_1 value_2 log2(fold_change) test_stat p_value q_value significant

I would like to analyse the data from file 1, however the columns only give the gene ID (ENSG00000xxx) format without the gene name. I would like to have a way to merge the test ID (identical as tracking_id in file 1) and gene_id from file 2 with file 1.

What is the terminal command to do this please? I also need to retain the information and format of the remaining columns of file 1 for further analysis.

I tried the command 'join' However, my joined file contains all the columns from tracking_id to gene_id and rest all merged into a SINGLE column. Is there a way I can stop terminal from doing this please?

terminal linux rnaseq • 4.1k views
ADD COMMENT
0
Entering edit mode

I have never worked with cuffdiff output files,maybe you can use {paste}?

ADD REPLY
2
Entering edit mode
7.9 years ago
Benn 8.3k

Best way is to use the R terminal here for. Use the function merge

Check the manual page with:

?merge
ADD COMMENT
1
Entering edit mode
7.9 years ago
michael.ante ★ 3.9k

Hi Genosa,

You can specify in the join command on which columns you want to join:

join -1 1 -2 2 file1 file2

If you only need selected columns in your output, you can control this by -o (here joining-column, second column of first file and 5th column of second file):

join -1 1 -2 2 -0 0,1.2,2.5 file1 file2

Stackoverflow has a couple of nice examples like this one.

Cheers,

Michael

ADD COMMENT
0
Entering edit mode

Hi Michael, thanks! But the joine data all appear in 1 column rather than separated columns. Is there a way that I can do to separate them? Thank you !

ADD REPLY
0
Entering edit mode

AFAIK, the standard delimiter of join is a blank space rather than a tab. With -t, you can change it.

ADD REPLY

Login before adding your answer.

Traffic: 2717 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