igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] Adjacency list to edgelist


From: anupam sinha
Subject: Re: [igraph] Adjacency list to edgelist
Date: Tue, 9 Mar 2010 22:37:43 +0530

Hi Gabor,
                   Tried your code but it is giving an empty edgelist object. Any suggestions ?

Regards,

Anupam

On Tue, Mar 9, 2010 at 10:15 PM, anupam sinha <address@hidden> wrote:
Dear Gabor,

                         Thanks a lot for your reply.

Regards,

Anupam
 

On Tue, Mar 9, 2010 at 6:22 PM, Gábor Csárdi <address@hidden> wrote:
Dear Anupam,

you don't really need igraph for this:

lines <- readLines("adjlist.txt")
lines <- gsub("[ ]+$", "", gsub("[ ]+", " ", lines))   # remove
trailing and multiple spaces
adjlist <- strsplit(lines, " ")

col1 <- unlist(lapply(adjlist, function(x) rep(x[1], length(x)-1)))
col2 <- unlist(lapply(adjlist, "[", -1))

edgelist <- cbind(col1, col2)

Best,
Gabor

On Tue, Mar 9, 2010 at 1:39 PM, anupam sinha <address@hidden> wrote:
> Dear all,
>
>                    I have a number of graphs in this format (adjacency list)
> :
>
> PABPC4    PABPC4    EEF1A1    SETDB1    XRN1    RIF1
> AHCY         AHCY
> PSCDBP   PSCDBP    PSCD1
> ITSN2        ITSN2    WAS    RAD9A    LSM8    SYNJ2
> TICAM2     TICAM2    IL1R1    IRAK1    TRAF6    IRF3    TLR4    IL1RAP
> IRAK3    IRF7    TIRAP
> ADCY3      CAMK2G    ADCY3
> ADCY6      ADCY6    CHRNA7    GNAS    RAF1
> FHL3          FHL3    ACTB    CDC25B    MAPK1    LASP1    KLF8    CTBP2
> FHL2    ZNF42    SRF    CDC42EP1    PHC2    PCQAP
> TM9SF2    TM9SF2    RAB9A
>
> where the alphanumeric id represents the node name (gene name). The first
> column contains the source node and the other columns have the destination
> nodes. How do I convert this into an edgelist format using R implementation
> of igraph ? Thanks in advance for any suggestions.
>
>
> Regards,
>
>
> Anupam
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>
>



--
Gabor Csardi <address@hidden>     UNIL DGM


_______________________________________________
igraph-help mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/igraph-help



--
Graduate Student,
Laboratory of Computtational Biology,
Centre For DNA Fingerprinting And Diagnostics,
4-1-714 to 725/2, Tuljaguda complex
Mozamzahi Road, Nampally,
Hyderabad-500001



--
Graduate Student,
Laboratory of Computtational Biology,
Centre For DNA Fingerprinting And Diagnostics,
4-1-714 to 725/2, Tuljaguda complex
Mozamzahi Road, Nampally,
Hyderabad-500001

reply via email to

[Prev in Thread] Current Thread [Next in Thread]