How to keep the gene id with highly FPKM.
2
0
Entering edit mode
7.2 years ago
M K ▴ 660

I have a text file contains three columns; the first coulmn is the Ensemble gene id, the second column is gene name, and the third column is FPKM. I am looking for R function to keep the Ensemble gene id that highly expressed (i.e has highest FPKM) only in this file.

Example: from the data below, I want only to keep ENSMUST00000062483 Gli2 0.157666 which has the highest FPKM

ex

R • 1.8k views
ADD COMMENT
0
Entering edit mode

That's a very basic R question. I would suggest you to follow tutorial on basic R programming, this will make everything less painful in the long run. Specifically, you are looking for the row (slicing) for which the FPKM value is equal to the maximum value of all FPKM values.

ADD REPLY
2
Entering edit mode
7.2 years ago
Pol ▴ 70
newdata <- yourdataframe[order(-yourdataframe$FPKM),]

The "-" before yourdataframe$FPKM indicates "descending" without it will be "ascending"

ADD COMMENT
0
Entering edit mode

That's worked, but it gave me all highest FPKMs. What I need to keep the highest one only (i.e the highest value among all higher FPKM values)

ADD REPLY
2
Entering edit mode
    highest <- newdata [1,]

I hope this helps

ADD REPLY
1
Entering edit mode
7.2 years ago
shunyip ▴ 250
Yourdata <- read.table("yourfile.txt", sep="\t", row.names=1, header=FALSE)
HighlyExpressedID <- rownames(Yourdata[order(Yourdata[,2],decreasing=TRUE),])[1:n]

Just replace "n" with the number of gene id that you want to keep.

I hope this helps

ADD COMMENT

Login before adding your answer.

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