This is a test version of Biostars. For the public version, visit https://www.biostars.org.
relating the number with gene names in a list of genes

hi,

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 but not by gene name and by number of genes like below

> head(edgelist[1:10,1:3])
 0.179539384784291 18 177
         0.1769863 306  539
          0.1699997 422  539
         0.1540843 270  580
         0.1367052 416  529
          0.1230802  97  383
         0.1227789  73  557

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

software-error r

Hi,

Is your length of gene list names and length of edgelist are equal? If they are equal then you can use either cbind function to a new column of your gene names to the existing edgelist or you can make use of gsub function.

Yes the length is the same. Sorry I could not figure out what to do. May you please write the code here? Thank you

1 answer

If edgelist is a data.frame, and the numbers are indices pointing to the gene

edgelist$TFLocus <- genes[,1][edgelist$TFLocus]
edgelist$TargetLocus <- genes[,1][edgelist$TargetLocus]

Log in to answer this question.