Skip to content

How to replace values?

2 messages · Suhaila Zainudin, Sigbert Klinke

#
Hello all,

I have a list of genes as follows (A)

Number? GeneName
0???????????? YAR003W
1???????????? YAR007C
2???????????? YAR008W
3???????????? YBL035C
4???????????? YBL111C
5???????????? YBL112C

And I have a list of gene interactions as follows (B)

0 -> 1
1 -> 5
3 -> 4
2 -> 3

I want to replace the values in (B) with the corresponding values in
(A) ie, I want to achieve the following

0 -> 1 replaced with YAR003W ->YAR007C
1 -> 5 replaced with YAR007C -> YBL112C
3 -> 4 replaced with YBL035C ->?? YBL111C
2 -> 3 replaced with YAR008W -> YBL035C

The example is simple with (A) and (B) only having a few lines.? But
in reality, (A) may contain more than 1000 genes and (B) may contain
thousands of interactions.

Any suggestions? on how to achieve the above task are welcomed!



--
Suhaila Zainudin
PhD Candidate
Universiti Teknologi Malaysia
#
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

If the coding would start at 1 rather than 0 then +1's in the
penultimate line could be eliminated.

Sigbert

- ---

gene <- c("YAR003W", "YAR007C", "YAR008W", "YBL035C", "YBL111C", "YBL112C")
print(gene)
to   <- c(0,1,3,2)             # to   <- c(1,2,4,3)
from <- c(1,5,4,3)             # from <- c(2,6,5,4)
gene[to+1] <- gene[from+1]     # gene[to] <- gene[from]
print(gene)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD4DBQFJ+YKUWvYUYQkj1zkRAjlVAJ9NrHySXnFCUmyBS7XbBwgAeOu1XQCVHvCa
omPs62LERNyQJ/+I9uL52g==
=seex
-----END PGP SIGNATURE-----