Question

I have this mutual information matrix:

 X1053_at   X117_at X121_at X1255_g_at  X1294_at    X1316_at    X1320_at
X1053_at    0   0.00040833  0.052000448 0.101470422 0.00040833  0.223143551
X117_at     0.00040833  0   0.00040833  0.174561677 0.174561677 0.034204976
X121_at     0.052000448 0.00040833  0   0.020410997 0.010309644 0.034204976
X1255_g_at  0.101470422 0.174561677 0.020410997 0   0.020410997 0.174561677
X1294_at    0.00040833  0.174561677 0.010309644 0.020410997 0   0.101470422
X1316_at    0.223143551 0.034204976 0.034204976 0.174561677 0.101470422 0
X1320_at    0.074226329 0.134540323 0.052000448 0.00368703  0.020410997 0.101470422

then i want to make a gene list tab deliminated matrix in R such as:

 
geneX    geneY  weight   
geneX    geneY  weight   
geneX    geneY  weight   
geneX    geneY  weight   
geneX    geneY  weight   
geneX    geneY  weight  

could anyone help me on this? actually i want to export this matrix and then import by cytoscape or gephi or ... thanks

Was it helpful?

Solution

The following hack might help:

x <- as.matrix(read.table(textConnection("X1053_at   X117_at X121_at X1255_g_at  X1294_at    X1316_at    X1320_at
X1053_at    0   0.00040833  0.052000448 0.101470422 0.00040833  0.223143551
X117_at     0.00040833  0   0.00040833  0.174561677 0.174561677 0.034204976
X121_at     0.052000448 0.00040833  0   0.020410997 0.010309644 0.034204976
X1255_g_at  0.101470422 0.174561677 0.020410997 0   0.020410997 0.174561677
X1294_at    0.00040833  0.174561677 0.010309644 0.020410997 0   0.101470422
X1316_at    0.223143551 0.034204976 0.034204976 0.174561677 0.101470422 0
X1320_at    0.074226329 0.134540323 0.052000448 0.00368703  0.020410997 0.101470422"), header=TRUE, row.names=1))

# not sure if this is correctly aligned as you have 7 column names for 6 columns

as.data.frame(as.table(x))

Result:

         Var1       Var2       Freq
1    X1053_at    X117_at 0.00000000
2     X117_at    X117_at 0.00040833
3     X121_at    X117_at 0.05200045
4  X1255_g_at    X117_at 0.10147042
5    X1294_at    X117_at 0.00040833
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top