You'r absoultely right. This worked for me as well. Many thanks Sean!
• 0 views
•
link
Hi,
How can I remove duplicate rows from the output of my toptableF? I have tried the following without success:
if (unique(fit2$genes)){
Sigenes.F <- topTableF(fit2, number=100, genelist=fit2$genes, adjust.method="bonferroni",
sort.by="F")
}
Thanks
You'll need to pay attention to what you are doing. If you are new to R, you will need to do some reading on R data structures, as each behaves differently with regard to indexing. Just guessing, but you probably want:
SigGenes.F[!duplicated(SigGenes.F$genes),]
You'r absoultely right. This worked for me as well. Many thanks Sean!
Read ?duplicated:
> x = c(1:10,1:10)
> x
[1] 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10
> x[!duplicated(x)]
[1] 1 2 3 4 5 6 7 8 9 10
>
I used duplicated() this way:
SigGenes.F[!duplicated(SigGenes.F)]
Got this output:
Error in `[.data.frame`(SigGenes.F, !duplicated(SigGenes.F)) :
undefined columns selected
Then tried:
SigGenes.F[!duplicated(SigGenes.F[2])]
Output:
columns 3:7 have been removed
Thanks
Please consider accepting as an answer and/or upvoting useful answers.
Log in to answer this question.
Is it from the fit2 data frame or the Sigenes.F data frame that you want to remove the duplicates?
From the Sigenes.F data frame. Thanks.
you can do as Michael Dondrup says below, but that might be removing important information. Often, you have duplicated genes in microarray data because there are multiple probes for a single gene. E.g. what if one of them is up-regulated and one is down-regulated (due to alternative transcript use) and you discard one?
I don't think you want to remove duplicated genes, you probably want to keep the best p-value for each gene. Have a look into the aggregate() function
Thanks again, Irsan. I was able to get get aggregate() to work. It makes sense in the way you have explained, and not just throwing genes away.