[BioC] graph::edgeMatrix() fails for signature(object="graphBAM")
Paul Shannon
paul.thurmond.shannon at gmail.com
Mon Jul 8 06:30:10 CEST 2013
Hi Robert,
I just added your suggested code to the devel version of methods-graphBAM.R, along with a unit test which first reproduced the bug your found -- and which now testifies to its resolution with your fix in place.
Out of what may be an excess of caution on my part, I will wait a couple of days to see the devel build complete, before adding your bug fix to release.
Many thanks for helping out. We are grateful.
- Paul
On Jul 4, 2013, at 12:02 AM, Robert Castelo wrote:
> hi Paul, just in case it helps, the current definition of the edgeMatrix() method for 'graphBAM' is:
>
> setMethod("edgeMatrix", "graphBAM",
> function (object, duplicates = FALSE) {
> bitvec <- object at edgeSet@bit_vector
> nds <- nodes(object)
> df <- .Call(graph_bitarray_rowColPos, bitvec)
> t(df)
> })
>
> so clearly the argument 'duplicates' is not taken into account, i believe a possible fix could be the following:
>
> setMethod("edgeMatrix", "graphBAM",
> function(object, duplicates=FALSE) {
> bitvec <- object at edgeSet@bit_vector
> nds <- nodes(object)
> df <- .Call(graph_bitarray_rowColPos, bitvec)
> if (duplicates)
> df <- rbind(df, cbind(as.vector(df[, "to"]),
> as.vector(df[, "from"])))
> t(df)
> })
>
>
> cheers,
> robert.
>
> On 07/04/2013 04:59 AM, Paul Shannon wrote:
>> Hi Robert,
>>
>> Thanks for your clear bug report. I will take a look at this over the upcoming weekend.
>>
>> - Paul
>>
>> On Jul 3, 2013, at 7:17 AM, Robert Castelo wrote:
>>
>>> hi,
>>>
>>> i have come across the following problem with the graph::edgeMatrix() function when the input object is a 'graphBAM' object:
>>>
>>> library(graph)
>>> g<- graphBAM(data.frame(from="1", to="2", weight=1))
>>>
>>> edgeMatrix(g, duplicates=FALSE)
>>> [,1]
>>> from 1
>>> to 2
>>> edgeMatrix(g, duplicates=TRUE) ## here is the problem !!
>>> [,1]
>>> from 1
>>> to 2
>>> edgeMatrix(as(g, "graphNEL"), duplicates=TRUE) ## but here works !!
>>> [,1] [,2]
>>> from 1 2
>>> to 2 1
>>>
>>>
>>> note that when coercing 'g' to a 'graphNEL' object, then it works as expected.
>>>
>>>
>>> thanks!!
>>> robert.
>>> ps: sessionInfo()
>>> R version 3.0.0 (2013-04-03)
>>> Platform: x86_64-unknown-linux-gnu (64-bit)
>>>
>>> locale:
>>> [1] LC_CTYPE=en_US.UTF8 LC_NUMERIC=C
>>> [3] LC_TIME=en_US.UTF8 LC_COLLATE=en_US.UTF8
>>> [5] LC_MONETARY=en_US.UTF8 LC_MESSAGES=en_US.UTF8
>>> [7] LC_PAPER=C LC_NAME=C
>>> [9] LC_ADDRESS=C LC_TELEPHONE=C
>>> [11] LC_MEASUREMENT=en_US.UTF8 LC_IDENTIFICATION=C
>>>
>>> attached base packages:
>>> [1] stats graphics grDevices utils datasets methods base
>>>
>>> other attached packages:
>>> [1] graph_1.38.2 vimcom_0.9-8 setwidth_1.0-3 colorout_1.0-0
>>>
>>> loaded via a namespace (and not attached):
>>> [1] BiocGenerics_0.6.0 parallel_3.0.0 stats4_3.0.0 tools_3.0.0
>>>
>>> _______________________________________________
>>> 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
>>
>>
>
> --
> Robert Castelo, PhD
> Associate Professor
> Dept. of Experimental and Health Sciences
> Universitat Pompeu Fabra (UPF)
> Barcelona Biomedical Research Park (PRBB)
> Dr Aiguader 88
> E-08003 Barcelona, Spain
> telf: +34.933.160.514
> fax: +34.933.160.550
>
> _______________________________________________
> 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