This change is now implemented in devel 1.37.6.

> nms <- paste0("Y", 8:11)
> df <- data.frame(from=nms, to=nms, weight=rep(1, 4))

Node names are not sorted when full vector of names is provided:
> nodes(graphBAM(df, nodes=c(nms, "foo")))
[1] "Y8"  "Y9"  "Y10" "Y11" "foo"

Names are sorted when only a zero-degree node is provided:
> nodes(graphBAM(df, nodes="foo"))
[1] "foo" "Y10" "Y11" "Y8"  "Y9"


A side effect of this change is that addNode(), which calls graphBAM(), was returning unsorted node names. To remain consistent with previous behavior I've sorted these results. Currently addNode() has no way to specify a full list of node names. Do you have an opinion on addNode() behavior? OK as is?



Valerie




On 02/07/2013 08:52 AM, Robert Castelo wrote:
Great, thanks!
robert.

On 02/07/2013 05:44 PM, Valerie Obenchain wrote:
Hi Robert,

I will look into this next week. Thanks for providing details and
examples in the request.

Valerie

On 02/06/2013 04:10 PM, Robert Castelo wrote:
dear maintainers of the graph package,

i have a small request for the constructor function graphBAM() from the
graph package.

the current help page of the graphBAM() constructor says the following
about the argument called 'nodes':

A character vector of node labels. Use this to add degree
zero nodes to the graph. If ‘NULL’, the set of nodes found
in ‘from’ and ‘to’ will be used.

It would be great if when nodes != NULL and includes the set of nodes
found in 'from' and 'to', 'nodes' would be taken as the set of nodes of
the graph, without re-ordering it.

currently this function has the following line (*):

nodes <- sort(unique(c(as.character(df$from), as.character(df$to),
nodes)))

this is a bit of a headache for me because the alphabetical ordering of
vertices does not respect integer ordering (obviously):

library(graph)
df <- data.frame(from=paste0("Y", 1:10), to=paste0("Y", 2:11),
weight=rep(1, 10))
nodes(graphBAM(df, nodes=paste0("Y", 1:10)))
[1] "Y1" "Y10" "Y11" "Y2" "Y3" "Y4" "Y5" "Y6" "Y7" "Y8" "Y9"

however, because i often deal with vectors of vertex labels created as

v <- paste0("Y", 1:p)

with p whatever positive integer, my vector of vertex labels is not
identical to the vector returned by graph::nodes() which complicates the
way i have to deal with this feature. re-ordering my vector of vertex
labels by alphabetical order implies doing it *each* time i do one of
those 'paste0()' calls, which is quite often, and this seems quite
common, see
http://simplystatistics.org/2013/01/31/paste0-is-statistical-computings-most-influential-contribution-of-the-21st-century


:)

for this reason it would be great for me if the argument 'nodes' in
graphBAM() would have this additional functionality of forcing an
ordering on the vertex labels when 'nodes' include all vertices forming
the given edges.

i think this would amount to replacing the line above (*) by

stopifnot(all(!duplicated(nodes))) ## given nodes should be unique
edgeNodes <- unique(c(as.character(df$from), as.character(df$to))
if (!all(edgeNodes %in% nodes))
nodes <- sort(unique(c(nodesEdges, nodes)))

note that with this code when one just adds extra degree zero nodes, the
behavior does not change with respect to what it is doing right now and
if one likes to stick to the alphabetical ordering, you can always give
'nodes=sort(myvertexlabels)' as argument to the graphBAM() constructor
function.

thanks!!
robert.

_______________________________________________
Bioc-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/bioc-devel




_______________________________________________
Bioc-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/bioc-devel

Reply via email to