How to pull logFC values for a select ENTREZID from a gene-list on R?
1
0
Entering edit mode
3.9 years ago
tpm ▴ 30

Hello, I am working on R using the compareCluster package.

I have a gene list like this (with ENTREZID on top and logFC at the bottom):

head(genelist)

949101       945316       945807       947239       946699       945783       945780       94603 
4.311420437  3.762809441  3.529820947  3.333709954  3.317216812  3.255953865  3.160993457  3.160993457

With say 1000 rows.

I want to extract a select specific list of ENREZID along with their logFC, such as for example:

948683
947293
947227
947693
948129
947872
944778
947968
944799
945102
944803
944982
944823
947969
948249
945238
947011
947673
946662
946625
948900
945328
947352

What codes do I use to make that execution on R?

bioconductor R DEP • 913 views
ADD COMMENT
1
Entering edit mode
3.9 years ago
Papyrus ★ 2.9k

The genelist object you show looks more like a named vector (you can check with class(genelist)). If this is the case, you can extract the list by, for example:

genenames <- as.character(c(948683,947293,947227)) # set as character to avoid asking for positions instead of names

genelist_filtered <- genelist[genenames]
ADD COMMENT
0
Entering edit mode

Thank you very much.

ADD REPLY
0
Entering edit mode

If I may ask, a follow up question, how about if my gene list looks like this, how can I extract the desired list of genes from this kind of dataframe:

head(genelist)

ENTREZID           FC
1     947315  1.576377015
2     944895 -0.023717866
3     947758 -0.125816872
4     947761  0.104652669
5     946796 -0.045722731
6     948517 -0.028024538
ADD REPLY
1
Entering edit mode

These questions are generic R issues which may better fit in other forums such as Stack Overlow (and most probably have already been answered there or referred to basic R use courses). Nonetheless:

That last object is two-dimensional and may be filtered in different ways, one of which could be:

genenames <- as.character(c(948683,947293,947227))
genelist_filtered <- genelist[genelist$ENTREZID %in% genenames,]
ADD REPLY
0
Entering edit mode

Million thank you. I honestly did not know I could use StackOverflow. I am still a newbie on R :)). Thank you for the clarity.

ADD REPLY

Login before adding your answer.

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