[BioC] LambdaSets converting the results into a data.frame

joe j joe.stata at gmail.com
Mon May 16 22:03:20 CEST 2011


Thanks very much Steve. Just what I wanted.
Joe

On Mon, May 16, 2011 at 5:56 PM, Steve Lianoglou
<mailinglist.honeypot at gmail.com> wrote:
> Hi,
>
> On Mon, May 16, 2011 at 11:18 AM, joe j <joe.stata at gmail.com> wrote:
>> Thanks, Steve,
>> What I've in mind is essentially a matrix of 3 columns:
>> 1.vertex label, 2. edge connectivity (from 1 to maximum edge
>> connectivity) or let's call it Lambda-K-set,3. a lambda set group
>> identifier; let's call it group
>>
>> For the example:
>>  con <- file(system.file("XML/snalambdaex.gxl",package="RBGL"))
>>  coex <- fromGXL(con)
>>  close(con)
>>  lambdaSets(coex)
>>
>> I'd like the following output:
>>
>> 1. Node; 2. Lambda-K-set; 3. Group
>>
>> A1        1        1
>> A2        1        1
>> --
>> A12      1        1
>>
>>
>> A1        2        1
>> A2        2        1
>> --
>> A8        2        1
>>
>> A9        2       2
>> A10      2       2
>> --
>> A12      2       2
>>
>>
>> A1       3       1
>> A2       3       1
>> --
>> A4       3       1
>>
>>
>> A5      3       2
>> A6      3       2
>> --
>> A8      3       2
>
> Here's a way -- maybe not the prettiest, but I think it's (more or
> less) what you're after. The `lsets` variable should have. The parse*
> functions may not be so durable/robust, and might require tweaking:
>
> library(RGDL)
>
> con <- file(system.file("XML/snalambdaex.gxl",package="RBGL"))
> coex <- fromGXL(con)
> close(con)
> lset <- lambdaSets(coex)
>
> parse.me <- unlist(lset[[2]], recursive=FALSE)
>
> parseLambda <- function(name) {
>  gsub('lambda-(\\d+).*', '\\1', name)
> }
>
> parseSet <- function(name) {
>  idx <- gsub('lambda-(\\d+) sets(\\d+)', '\\2', name)
>  if (nchar(idx) == nchar(name)) {
>    ## idx not found, assume 1
>    idx <- "1"
>  }
>  idx
> }
>
> lsets <- lapply(names(parse.me), function(name) {
>  lambda <- parseLambda(name)
>  group <- parseSet(name)
>  data.frame(node=parse.me[[name]], lambda=lambda, group=group)
> })
>
> lsets <- do.call(rbind, lsets)
>
> head(lsets)
>  node lambda group
> 1   A1      0     1
> 2   A2      0     1
> 3   A3      0     1
> 4   A4      0     1
> 5   A5      0     1
> 6   A6      0     1
>
> --
> Steve Lianoglou
> Graduate Student: Computational Systems Biology
>  | Memorial Sloan-Kettering Cancer Center
>  | Weill Medical College of Cornell University
> Contact Info: http://cbio.mskcc.org/~lianos/contact
>



More information about the Bioconductor mailing list