thank you but how i can have two files one contains which column 10> 0 and another column 10 <0 ???
hi,
I have this file from cuffdiff
> head(mycounts[,1:14])
test_id gene_id gene locus sample_1 sample_2 status value_1 value_2 log2.fold_change. test_stat p_value q_value
1 XLOC_000001 XLOC_000001 NAC001 1:3630-5899 C1 C2 OK 8.16533 8.82461 0.1120220 0.2496490 0.79700 0.999241
2 XLOC_000002 XLOC_000002 DCL1 1:23145-33153 C1 C2 OK 12.65950 15.12090 0.2563240 0.0853285 0.73045 0.999241
3 XLOC_000003 XLOC_000003 AT1G01073 1:44676-44787 C1 C2 NOTEST 0.00000 0.00000 0.0000000 0.0000000 1.00000 1.000000
4 XLOC_000004 XLOC_000004 IQD18 1:52091-54692 C1 C2 OK 2.98590 3.46625 0.2152080 0.3954010 0.68640 0.999241
5 XLOC_000005 XLOC_000005 AT1G01115 1:56623-56740 C1 C2 NOTEST 0.00000 0.00000 0.0000000 0.0000000 1.00000 1.000000
6 XLOC_000006 XLOC_000006 GIF2 1:72324-74737 C1 C2 OK 23.01450 21.96440 -0.0673764 -0.0884016 0.93085 0.999241
significant
1 no
2 no
3 no
4 no
5 no
6 no
How I can extract columns 3 and 10 if only the column 14(significant) is yes and only between sample C1 and C2 because I have another samples in lower rows??
Thank you
1 answer
In R :
mycounts.filt <- mycounts[mycounts$significant=="yes" & mycounts$sample_1=="C1" & mycounts$sample_2=="C2",c(3,10)]
mycounts.filt.over10 <- mycounts[mycounts$significant=="yes" & mycounts$sample_1=="C1" & mycounts$sample_2=="C2" & mycounts[,10]>0,c(3,10)]
mycounts.filt.under10 <- mycounts[mycounts$significant=="yes" & mycounts$sample_1=="C1" & mycounts$sample_2=="C2" & mycounts[,10]<0,c(3,10)]
I really encourage you to better learn R as it's a really basic feature of R (subsetting a data.frame). Also it's not really a bioinformatics question (more a stackoverflow related question) ;)
Thank you but in stackoverflow I don't have needed scores then they don't allow me to ask any question :)
Search stackoverflow for existing questions. Most of your questions are basic enough that a google search will give you straightforward results.
We appreciate your drive to keep learning, but you'll have to improve and work on putting in a bit more effort before asking here. Unlike stackoverflow, we do not have automated reputation based limitations, but that does not mean that you can invest near-zero effort and expect people to provide you with exact commands.
Please avoid "read the manual" or "google it" style questions in the future.
I'm so sorry...
Didn't know you could combine multiple & statements like this, it's good to know. Thanks!
The double && is a single-value "AND". The single & operator is a vectorized boolean AND. So it works like "+" in regards to using multiple in sequence.
So you can
c(T,F,T) & c(F,F,T) & c(T,T,T)
and get c(F,F,T), which would be a well functioning vector index.
Log in to answer this question.
Something like this might work. I've only started learning R a few days ago though. You might not even need the if statement to be honest. You probably don't but I don't have a dataset to test it.
Thank you
but nothing happened and the output is the same with input
Yea I thought about this just now and edited my previous comment. Give this a try instead of the if statement:
If you only want columns 3 AND 10 and not 3 THROUGH 10 then you'd need to do this I think:
Thank you, but
Wow, I'm so sorry. I didn't realize I had totally mistyped the variable for the second parameter. I updated my previous comment to the "correct" code. Try it now.
Thank you
What is the output of
class(mycounts) and class(mycounts2)? I was assuming it was a data.frame.The commands I gave you should have worked, I tested it on my own dataset and it was fine.
Thank you
That's odd. Alright I'll take one more crack at it.
First extracting and separating down and up regulated gene
then extracting the significant one (yes in column 14)
But I donno how to combine these
Simply add
$14=="yes"in the first awk commandYou've got to learn how to Google. For example, googling "extract subset of data frame R" will get you leads on
Unless you invest time on understanding what you're trying to do, just running commands given by people here will not help you in the long run. I say this because you've been here a long time and your questions follow a pattern of asking for commands and interactively debugging minor errors in them with folks on the forum.
Hello Fereshteh!
We believe that this post does not fit the main topic of this site.
Please see my comment here: C: extracting some information from cuffdiff output
For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.
If you disagree please tell us why in a reply below, we'll be happy to talk about it.
Cheers!