Question: LambdaSets converting the results into a data.frame
0
gravatar for joe j
8.4 years ago by
joe j70
joe j70 wrote:
Dear all, This is probably a simple question, but any pointers would be great. I am using "lambdaSets" in the package "RBGL" in R. What I would like is to have all the results of "lambdaSets" in a data.frame because I will be comparing the results for different years. Best regards, Joe
• 390 views
ADD COMMENTlink modified 8.4 years ago by Steve Lianoglou12k • written 8.4 years ago by joe j70
Answer: LambdaSets converting the results into a data.frame
0
gravatar for Steve Lianoglou
8.4 years ago by
Denali
Steve Lianoglou12k wrote:
Hi, On Mon, May 16, 2011 at 4:29 AM, joe j <joe.stata at="" gmail.com=""> wrote: > Dear all, > > This is probably a simple question, but any pointers would be great. > > I am using ?"lambdaSets" in the package "RBGL" in R. What I would like > is to have all the results of "lambdaSets" in a data.frame because I > will be comparing the results for different years. How do you expect that data.frame to look like? For instance, if we run the example code in the lambdaSets function and set the last statement to a variable (`lset`): R> con <- file(system.file("XML/snalambdaex.gxl",package="RBGL")) R> coex <- fromGXL(con) R> close(con) R> lset <- lambdaSets(coex) What do you expect `lset` as a data.frame to look like? lset[[1]] is a single integer, and lset[[2]] is a list of lists of nodes -- each of varying lengths. It seems that this type of data isn't well suited to be stuffed into a data.frame, but if you can give us an idea of how this `lset` object might look like as a data.frame, perhaps someone can help you get it into that form. -steve -- 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
ADD COMMENTlink written 8.4 years ago by Steve Lianoglou12k
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 Best regards, Joe On Mon, May 16, 2011 at 3:50 PM, Steve Lianoglou <mailinglist.honeypot at="" gmail.com=""> wrote: > Hi, > > On Mon, May 16, 2011 at 4:29 AM, joe j <joe.stata at="" gmail.com=""> wrote: >> Dear all, >> >> This is probably a simple question, but any pointers would be great. >> >> I am using ?"lambdaSets" in the package "RBGL" in R. What I would like >> is to have all the results of "lambdaSets" in a data.frame because I >> will be comparing the results for different years. > > How do you expect that data.frame to look like? > > For instance, if we run the example code in the lambdaSets function > and set the last statement to a variable (`lset`): > > R> con <- file(system.file("XML/snalambdaex.gxl",package="RBGL")) > R> coex <- fromGXL(con) > R> close(con) > R> lset <- lambdaSets(coex) > > What do you expect `lset` as a data.frame to look like? > > lset[[1]] is a single integer, and lset[[2]] is a list of lists of > nodes -- each of varying lengths. It seems that this type of data > isn't well suited to be stuffed into a data.frame, but if you can give > us an idea of how this `lset` object might look like as a data.frame, > perhaps someone can help you get it into that form. > > -steve > > -- > 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 >
ADD REPLYlink written 8.4 years ago by joe j70
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(namesparse.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
ADD REPLYlink written 8.4 years ago by Steve Lianoglou12k
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(namesparse.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 >
ADD REPLYlink written 8.4 years ago by joe j70
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 250 users visited in the last hour