This is a test version of Biostars. For the public version, visit https://www.biostars.org.
extracting multiple columns from a file

Hi,

I have a file like below

https://k52i.imgup.net/Untitled763f.jpg

I want to extract rest of columns if in gene column we have MYC, YY1 and TP53 and in organism column we have human

how I can do that please?

excel

Have you tried anything in R?

Since you have an Excel file, I would save as text tab-delimited.

egrep 'MYC|YY1|TP53' transmir_v1.2.txt | awk -F'\t' '{if ($6=="human") { print } } > filtered.txt

Please do not use irrelevant tags. You're using Excel here, why use the R tag?

Thank you Ram. I edited the tag. Actually at first I was only thinking about R (in the absence of Linux) but genomax2 abruptly solved the problem by Excel.

I think the OP had an excel file, but wanted to use R.

2 answers

You just need the auto-filter of Excel: http://www.wikihow.com/Use-AutoFilter-in-MS-Excel

After saving the table, check if excel hasn't modified some gene names.

First sort on the organism column (and save the part with "human") as text (comma or tab delimited format) from Excel.

Take inspiration from this post and try a few things out: A: Split single columm into multiple colums

You can also use awk with correct delimiter, along with a checking if/else construct as an alternative.

Note: Someone will spoil your learning by posting a ready-made solution before long but resist the urge to use that solution :)

thank you I will try that. no access to Linux at the time but I will try in R and excel.

If you only have excel then use the data --> filter options.

thank you, data -- > filter worked well.

Log in to answer this question.