Reshape data in R -


I have to be a matrix from this data frame. On the basis of values, if there is a connection between a pair of 1 gene, and if not then 0. Therefore, the value of ADRA1D and ADK will be 1, and such other pairs will also be there. But there is no pair of ADK and AR, so in that matrix this should be 0.

  tab & lt; - read.table (text = "ID gene1 gene2 1 ADRA1D ADK 2 ADRA1B ADK 3 ADRA1A ADK 4 ADRB 1 ASIC 1 5 ADRB 1 ADK 6 ADRB 2 ASIC 1 ADRB 2 ADK 8 AGTR 1 ACH 9 AGTR 1 ADK 10 ELLOS 5 ADRB 1 11 ALOX 5 ADRB 2 12 LPPL 2 ADRB 1 13 ALPPL 2 ADRB 2 14 A2 A2 ART 1 15 AR ADARA 1 AR ADRAID 17 AR ADARA 1 B 18 AR ADARA 1A AR ADR 2 A 20 Mainly, I Want to build phylogenetic tree, so a matrix like this I do not have any price column, so how can I revive the library for this?  

The code below does not work:

 < Code> library (reshape) ct = cast (tab, gene1 ~ gene2)  

if Using the reshape is not mandatory, so I had a look at the igraph. using the igraph package to get the symmetric matrix There is a way we First, change your data frame (the relevant 2 column) into a igraph object, and then get_adjacency is required.

Library (igraph) g < - graph.data.frame (tab [, c (2,3)] get.adjacency (g)

This gives you the proximity matrix for you to analyze the rest of the igraph Should be used. [16 x 16 spectrum matrix of class "dgCMatrix" [[16 column names 'ADRA1D', 'ADRA1B', 'suppressing ADRA1A]' ...]] ADRA1D. . . . . . . . . 1. . . . ADRA1B . . . . . . . . 1. . . . ADRA1A . . . . . . . . 1. . . . ADRB1. . . . . . . . . 1 1. . . . ADRB2. . . . . . . . . 1 1. . . . AGTR1. . . . . . . . . 1 1. . AOLX5 . 1 1. . . . . . . . . . . ALPPL2. . 1 1. . . . . . . . . . . AMY2A . . . 1. . . . . . . . . AR1 1 1. . . . . . . . . 1 1 1 ADK . . . . . . . . . . . . . . ASIC 1. . . . . . . . . . . . . . . HE . . . . . . . . . . . . . . ADORA1. . . . . . . . . . . . . . . ADRA2A . . . . . . . . . . . . . . ADRA2B . . . . . . . . . . . . . . One advantage of using

igraph is that many graph-based distance calculation methods are available to you shortest.paths < / P>


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -