Row extraction problems
0
1
Entering edit mode
7.3 years ago
Janey ▴ 30

Hi At first I thought that this work is so simple for me. I have File1 (ID list) and File2 (reference file). I want to extract some full rows by ID list from File2. I am not familiar to R and Python. I used "grep -f File1 File2" and some other commands but i got errors. Can anyone show me a simple solution to solve this problem.

RNA-Seq • 1.5k views
ADD COMMENT
0
Entering edit mode
ADD REPLY
0
Entering edit mode

What errors did you get? grep -f is a pretty standard approach.

ADD REPLY
0
Entering edit mode

Hi Alex I run this command "grep -f File1.txt (IDs) File2.txt(Ref) > output" several times for avoiding error but I output file containing the entire of file 2.

ADD REPLY
1
Entering edit mode

Maybe you need a literal string search, if you need exact matches: $ grep -Ff file1.txt file2.txt > output

ADD REPLY
0
Entering edit mode

I thank you very much Alex, your command solved my problem.

ADD REPLY
0
Entering edit mode

when I extracted the columns, folowing command was pretty good: cut -f 1,2,3 File_name | sed 's/[\t]/,/g' > output

ADD REPLY

Login before adding your answer.

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