Question: Confusion with grep command
0
gravatar for jaqx008
2.7 years ago by
jaqx00870
jaqx00870 wrote:

Hey all. I am doing a differential expression analysis and trying to use grep to find genes that are up-regulated and also those that are down-regulated by comparing the genes ortholog of different species of a bacteria to the Deseq2 result of each species. However, I think something is wrong with my grep command and I am getting an error. I would appreciate any help or explanation.

the command I am using to find the up-regulated gene (in terminal) is

grep -f up./Users/flynt/Desktop/Deseq2/3084DEortho.txt geneortholg./Users/flynt/Desktop/Deseq2/30_84_vs_all.txt > 3084DE.txt

I am a beginner in this field. Thanks in advance

ADD COMMENTlink modified 2.7 years ago by genomax89k • written 2.7 years ago by jaqx00870
2

Adding to what genomax said: if you're finding a list of genes using grep, it is always good idea to add -F where it evaluates the search terms as fixed strings and -w for whole word, so you don't bring up 10, 100, 1000 when searched with 10.

ADD REPLYlink modified 2.7 years ago • written 2.7 years ago by arnstrm1.8k

Thanks Arnstrm. your suggestion was helpful. Thanks again

ADD REPLYlink written 2.7 years ago by jaqx00870

When you are specifying full directory paths such as /Users/flynt/Desktop/Deseq2/3084DEortho.txt there is no reason to add . at the beginning. I assume up is a a file containing the genes that are up-regulated? Try:

grep -f up /Users/flynt/Desktop/Deseq2/3084DEortho.txt geneortholg /Users/flynt/Desktop/Deseq2/30_84_vs_all.txt > 3084DE.txt
ADD REPLYlink written 2.7 years ago by genomax89k

Thanks Max. I tried the command and got same error

grep -f up /Users/flynt/Desktop/Deseq2/3084DEortho.txt geneortholg./Users/flynt/Desktop/Deseq2/30_84_vs_all.txt > checked3084.txt
grep: up: No such file or directory
ADD REPLYlink modified 2.7 years ago by genomax89k • written 2.7 years ago by jaqx00870

That means you don't have a file called up in the directory you are running this from. If that file is in some other directory then provide full path for up file in your command. Also consider adding additional options suggested by @arnstrm below.

ADD REPLYlink modified 2.7 years ago • written 2.7 years ago by genomax89k

Ok. I think the "up" is just part of the command to help grep find up-regulated genes in the ortholog? I don't have an actual file called 'up'.

ADD REPLYlink modified 2.7 years ago • written 2.7 years ago by jaqx00870
1

If you take a look at the help for grep you will see that -f option expects a filename. That file will contain pattern(s) (one per line, say a gene name) that it will use to search. You can't do any quantitative searching with grep. You will need to use sort to sort your file by columns (if you have values in columns) to get genes that may be over-expressed (based on ratios/fold-change what ever it is that you have in the file) to get them to the top or bottom of the file.

ADD REPLYlink modified 2.7 years ago • written 2.7 years ago by genomax89k

Ok. My file has a sorted (based on 2foldchange) list of gene id's. so I now used this command

grep -f /Users/flynt/Desktop/Deseq2/3084DEortho.txt /Users/flynt/Desktop/Deseq2/30_84_vs_all.txt > file.txt

and got an out put .txt file.

The idea was to include up to generate up-regulated and repeat the command with down, to get down regulated I guess. But I am thinking this is wrong.

I can't tell if the text file generated form the above command is up or down since I didn't specify in the command.

ADD REPLYlink modified 2.7 years ago • written 2.7 years ago by jaqx00870

Thanks Max. I figured I didn't understand the instruction . The command works fine now. Thanks again

ADD REPLYlink modified 2.2 years ago • written 2.7 years ago by jaqx00870
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: 1580 users visited in the last hour