[BioC] graph::subGraph() problem with node attributes

Valerie Obenchain vobencha at fhcrc.org
Mon Feb 4 21:55:07 CET 2013


Hi Robert,

Thanks for the bug report. This is now fixed in release 1.36.2 and devel 
1.37.5. Both should be available via biocLite() Tuesday after 9am PST.

Valerie



On 02/01/2013 02:50 PM, Robert Castelo wrote:
> dear list, and particularly maintainers of the graph package,
>
> i have encounter a problem with the graph package which i'll reproduce
> using the example code from the help page of the graphBAM() constructor
> function:
>
> example(graphBAM) ## run the entire example code, this creates a
> data.frame called 'df'
> df
> from to weight
> 1 a b 2.3
> 2 a c 2.3
> 3 b c 4.3
> 4 c d 1.0
> 5 d a 3.0
>
> ## using the previous data frame, i'm going to re-run some of the
> instructions of the example, starting by creating a fresh new graphBAM
> object 'g'
>
> g <- graphBAM(df)
> g
> A graphBAM graph with undirected edges
> Number of Nodes = 4
> Number of Edges = 5
>
> ## now i'm going to add a 'color' attribute to the nodes setting its
> default value to 'green', this is taken again from the example
>
> nodeDataDefaults(g, attr ="color") <- "green"
> nodeData(g)
> $color
> $color$a
> [1] "green"
>
> $color$b
> [1] "green"
>
> $color$c
> [1] "green"
>
> $color$d
> [1] "green"
>
> ## now i'm going to extract the subgraph induced by nodes 'a', 'c' and
> 'd' (taken again from the example)
>
> sg <- subGraph(c("a","c","d"), g)
> Error in nodeData(g, attr = att) : attribute not found: ‘color’
>
> ## as you see i get an error related to the attribute previously added.
> however if, as it happens in the example, i change the value of the
> 'color' attribute to some of the nodes, the problem does not show up:
>
> nodeData(g,n=c("b", "c"), attr ="color") <- "red"
> nodeData(g, nodes(g))
> $color
> $color$a
> [1] "green"
>
> $color$b
> [1] "red"
>
> $color$c
> [1] "red"
>
> $color$d
> [1] "green"
>
> sg <- subGraph(c("a","c","d"), g)
> sg
> A graphBAM graph with undirected edges
> Number of Nodes = 3
> Number of Edges = 3
>
> ## the 'green' color in particular does not seem to be problem :)
>
> nodeData(g,n=c("b", "c"), attr ="color") <- "green"
> nodeData(g, nodes(g))
> $color
> $color$a
> [1] "green"
>
> $color$b
> [1] "green"
>
> $color$c
> [1] "green"
>
> $color$d
> [1] "green"
> sg <- subGraph(c("a","c","d"), g)
> sg
> A graphBAM graph with undirected edges
> Number of Nodes = 3
> Number of Edges = 3
>
> i would expect/like that once an attribute has been added with its value
> by default, one can already apply the subGraph() function without having
> to update the attribute. could the package be fixed this way?
>
> thanks!!
> robert.
> ps: sessionInfo()
> R version 2.15.2 (2012-10-26)
> Platform: i386-apple-darwin9.8.0/i386 (32-bit)
>
> locale:
> [1] C/UTF-8/C/C/C/C
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
> other attached packages:
> [1] graph_1.36.1 vimcom_0.9-5 setwidth_1.0-3 colorout_1.0-0
>
> loaded via a namespace (and not attached):
> [1] BiocGenerics_0.4.0 stats4_2.15.2 tools_2.15.2
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives:
> http://news.gmane.org/gmane.science.biology.informatics.conductor



More information about the Bioconductor mailing list