converting numbers to names
1
0
Entering edit mode
Angel ▴ 40
@angel-7981
Last seen 7.7 years ago
Berlin

hi,

if i have two lists, name

A

B

C

and interaction

from   to    InteractionType
1        3     0.179539385
2        1     0.176986341
2        3    0.169999731

and i know A=1 , B=2 and C=3

then how i can replace the number with A , B and C????

thank u

 

software error R • 879 views
ADD COMMENT
0
Entering edit mode
Aaron Lun ★ 28k
@alun
Last seen 6 hours ago
The city by the bay

Well, you could just use the LETTERS vector. If your "interaction" is some data frame x, you could use x$from <- LETTERS[x$from], for example. Same applies with the to field. On another note, this question doesn't seem related to Bioconductor software, so this forum isn't really the right place to ask it.

ADD COMMENT
0
Entering edit mode

sorry, you all right but in stackflow i don't have needed score then i can't ask any question

but i could not get what to do, u mean like below??

LETTER <- c("A", "B","C")

x$from <- LETTERS[x$from]

 

ADD REPLY
0
Entering edit mode

Well, that was just an example. You haven't specified what the "to" and "from" fields are; are they fields in a data.frame? Or are they part of some other structure? More detail is necessary if you want exact code.

ADD REPLY
0
Entering edit mode

I have this genes 

> head(genes[,1])
[1] AT1G01170 AT1G01260 AT1G01380 AT1G01490 AT1G01500 AT1G01610
2884 Levels: AT1G01170 AT1G01260 AT1G01380 AT1G01490 AT1G01500 AT1G01610 ... AT5G67430
also I have this edge list of the above genes derived from a gene regulatory inferring algorithm but as you conider the output is not by gene name anymore and is by number of genes like below

> head(edgelist[1:10,1:3])
TFLocus    TargetLocus    InteractionType
177    18    0.179539385
539    306    0.176986341
539    422    0.169999731
580    270    0.154084348
529    416    0.136705154
383    97    0.12308019
for example gene 18 and gene 177 connect with  0.179539384784291 value

how i can replace these numbers with the name of my genes???? for example genes 1 is AT1G01170 and gene 2 is AT1G01260

thank you

ADD REPLY
1
Entering edit mode

Well, if edgelist is a data.frame, and the numbers are indices pointing to the gene, you should be able to do:

edgelist$TFLocus <- genes[,1][edgelist$TFLocus]
edgelist$TargetLocus <- genes[,1][edgelist$TargetLocus]
ADD REPLY
0
Entering edit mode

thank you so much, it worked 

I am really thankful

ADD REPLY

Login before adding your answer.

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