This is a test version of Biostars. For the public version, visit https://www.biostars.org.
returning the gene name back to my matrix

Hi,

I have this correlation matrix of genes

            AT1G01260   AT1G01380   AT1G01720   AT1G02340
AT1G01260  1.00000000  0.30973373  0.19123689  0.36016896
AT1G01380  0.30973373  1.00000000 -0.09697069  0.35744181
AT1G01720  0.19123689 -0.09697069  1.00000000  0.49424809
AT1G02340  0.36016896  0.35744181  0.49424809  1.00000000
AT1G03790 -0.07400291  0.28242129  0.39122829  0.65253927
AT1G03970  0.11076049  0.01556151 -0.10402186 -0.03543976

I used this as an input to a gene regulatory network inferring algorithm but the algorithm needs a double numerical array then I should remove the rownames and colnames before using the input like below

                    X0.309733732403438 X0.191236891214484 X0.360168963281104
0.309733732403438           1.00000000        -0.09697069        0.357441815
0.191236891214484          -0.09697069         1.00000000        0.494248090
0.360168963281104           0.35744181         0.49424809        1.000000000
-0.0740029149713609         0.28242129         0.39122829        0.652539269
0.110760492997642           0.01556151        -0.10402186       -0.035439755
-0.047438731071716         -0.25571616         0.14004529        0.006117701
                    X.0.0740029149713609
0.309733732403438              0.2824213
0.191236891214484              0.3912283
0.360168963281104              0.6525393
-0.0740029149713609            1.0000000
0.110760492997642             -0.2702480
-0.047438731071716             0.2014606

This is the output of algorithm

  X0.41678 X0.55274 X0.53107 X0.65984
1  0.55226  0.41678  0.38789  0.57855
2  0.53114  0.38777  0.41678  0.71718
3  0.65996  0.57920  0.71714  0.41678
4  0.39087  0.55770  0.64322  0.78354
5  0.49434  0.43998  0.34617  0.41774
6  0.42038  0.32028  0.45477  0.43176

How I can return back the gene name to column and rows to this output?

Thank you

software-error r

3 answers

If you know the rownames

rownames(yourdata)  <-c("name1",  "name2",  etc)

thanks so much, you are always helpful

rownames(my input file with header) <-c(the output of algorithm that is without header)

In R

names <- rownames(your. data) #This keeps the row names in a variable
rownames(your. data) <- NULL # This erases row names

And then...

rownames(your. data) <- names #To reestablish again the names

thank you Antonio but i don't have the original file because what I used as input for algorithm dose not have any header and of course algorithm gives me the output without header, then how i can return the name of the correlation.txt back to the output of algorithm?

You need to make clear what do you exactly want. If the number of rows and columns of the original file and the result file are the same, you only need to copy the rownames

rownames(unheader_final.file) <- rownames(original.file)
colnames(unheader_final.file) <- colnames(original.file)

If the number of rows and columns are different, I don't have a clue about what exactly you want to do

The algorithm gives me an output without header then I need header

Thank you

You can recreate the header including the colnames and rownames..

colnames and rownames are the header you are asking..

Log in to answer this question.