Dear Stuart and Paul,

    In the latest check-out you can find the KEGGgraph version 1.21.1,
where mergeKEGGgraphs accept NULL as list items. In addition the bug
identified by Paul in parseKGML2DataFrame in the unit test seems to have
been fixed - it was caused by redudant edges in the KGML file and the
latest version should be able to handle such cases.

   In case of further problems or questions please let me know.

   Best,
David


On Thu, Oct 17, 2013 at 4:14 AM, Stuart Bradley <stuy.bradley@gmail.com>wrote:

> Hi David,
>
> So I've done some testing, and it appears that assuming my list has no
> NULL elements it works fine. Tested on:
>
> [ko00010.xml, ko00020.xml, ko00030.xml,ko00040.xml]
>
> The moment there are NULL graphs (in the metabolic/ko folder there are 12)
> it produces the error.
>
> Interestingly, it produces the error even after I've - or assumed I'd
> removed - the null entries using: AllGraphs[sapply(AllGraphs, is.null)] <-
> NULL or AllGraphs <- AllGraphs[!sapply(AllGraphs, is.null)]
>
> Both of which remove the 12 entries.
>
> This used to work fine.
>
> As you asked, I've worked out which entries are NULL (these were NULL in
> 1.16.0 as well). I am unable to do the whole of KEGG at home, so this is
> just the NULL entries from metabolic/ko:
>
> ko00121.xml
> ko00190.xml
> ko00195.xml
> ko00196.xml
> ko00271.xml
> ko00312.xml
> ko00511.xml
> ko00514.xml
>
> All these produce the: 'The pathway contains no chemical reactions!'
> warning.
>
> Hope this helps,
> Stuart
>
>
>
> On Thu, Oct 17, 2013 at 2:58 AM, Zhang, Jitao David <
> jitao_david.zhang@roche.com> wrote:
>
>> Dear Stuart,
>>
>>    The uniqueReaction option has been deleted in the latest release.
>>
>>    Could you tell which graph was NULL from AllGraphs? And the KGML file
>> of that? If so I can have a deeper look into the issue.
>>
>>    Best,
>> David
>>
>>
>> On Wed, Oct 16, 2013 at 9:50 AM, Stuart Bradley <stuy.bradley@gmail.com>wrote:
>>
>>> Right final email before I go to sleep. Probably should've kept these
>>> together. Apologies!
>>>
>>> After removing uniqueReaction = FALSE, the: FinalGraph <-
>>> mergeKEGGgraphs(AllGraphs, edgemode = "directed") ; line throws the
>>> following error:
>>>
>>> Error in (function (classes, fdef, mtable)  :
>>>   unable to find an inherited method for function ‘getName’ for
>>> signature ‘"NULL"’
>>>
>>> Is that likely to be related? Or something else entirely?
>>>
>>> Cheers,
>>> Stuart
>>>
>>>
>>> On Wed, Oct 16, 2013 at 8:27 PM, Stuart Bradley <stuy.bradley@gmail.com>wrote:
>>>
>>>> Ok found the actual culprit. It appears UniqueReaction = FALSE is an
>>>> unused argument in KEGGpathway2reactionGraph. Did this change? Or is
>>>> something funny going on? I've used it previously.
>>>>
>>>> Stuart
>>>>
>>>>
>>>> On Wed, Oct 16, 2013 at 8:18 PM, Stuart Bradley <stuy.bradley@gmail.com
>>>> > wrote:
>>>>
>>>>> Correction; Error hasn't disappeared; KEGGpathway2reactionGraph is
>>>>> returning all NULL entries.
>>>>>
>>>>>
>>>>> On Wed, Oct 16, 2013 at 7:53 PM, Stuart Bradley <
>>>>> stuy.bradley@gmail.com> wrote:
>>>>>
>>>>>> Hi David,
>>>>>>
>>>>>> Appears to be working as normal on my laptop now. Not sure why,
>>>>>> haven't changed anything. But the error has dissappeared. Will use exact
>>>>>> files from laptop on the workstation on Monday to confirm it's a non-issue.
>>>>>>
>>>>>> Cheers,
>>>>>> Stuart
>>>>>>
>>>>>>
>>>>>> On Tue, Oct 15, 2013 at 9:47 PM, Zhang, Jitao David <
>>>>>> jitao_david.zhang@roche.com> wrote:
>>>>>>
>>>>>>> Dear Stuart, do you have an idea which file broke the code?
>>>>>>>
>>>>>>> Best, David
>>>>>>>
>>>>>>>
>>>>>>> On Mon, Oct 14, 2013 at 6:48 PM, Stuart Bradley <
>>>>>>> stuy.bradley@gmail.com> wrote:
>>>>>>>
>>>>>>>> Hi all,
>>>>>>>>
>>>>>>>> 1.19.0 appears to break our code (tried it on my laptop this
>>>>>>>> morning) see: https://gist.github.com/lutrasdebtra/6978575 for
>>>>>>>> code and Session Info.
>>>>>>>>
>>>>>>>> Cheers,
>>>>>>>> Stuart
>>>>>>>>
>>>>>>>>
>>>>>>>> On Mon, Oct 14, 2013 at 7:21 PM, Stuart Bradley <
>>>>>>>> stuy.bradley@gmail.com> wrote:
>>>>>>>>
>>>>>>>>> Hi folks,
>>>>>>>>>
>>>>>>>>> Finally got hold of our KEGG data to test, and it works!
>>>>>>>>>
>>>>>>>>> Well, only on my laptop - and not the workstation, but that's a
>>>>>>>>> problem for tomorrow.
>>>>>>>>>
>>>>>>>>> I believe it's a setup issue, since I'm running 1.17.0 fine on my
>>>>>>>>> end, and Paul says 1.19.0 (the workstation version) is working.
>>>>>>>>>
>>>>>>>>> If it appears to be related I'll let everyone know.
>>>>>>>>>
>>>>>>>>> Otherwise, thank you all for your help! Our department is quite
>>>>>>>>> excited to get KEGG into Cytoscape!
>>>>>>>>>
>>>>>>>>> Cheers,
>>>>>>>>> Stuart Bradley
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Fri, Oct 11, 2013 at 7:50 AM, Paul Shannon <
>>>>>>>>> paul.thurmond.shannon@gmail.com> wrote:
>>>>>>>>>
>>>>>>>>>> Hi David,
>>>>>>>>>>
>>>>>>>>>> I tried out the new code (KEGGgraph v 1.19.0), and it works
>>>>>>>>>> great.  Thanks!
>>>>>>>>>>
>>>>>>>>>> I took the liberty (I hope you don't mind) of adding a unitTest
>>>>>>>>>> to your package which
>>>>>>>>>>
>>>>>>>>>>   1) fails with the old version, demonstrating Stuart's problem
>>>>>>>>>>   2) succeeds with the new
>>>>>>>>>>
>>>>>>>>>> The file is inst/unitTests/test_KEGGgraph.R
>>>>>>>>>>
>>>>>>>>>>  - Paul
>>>>>>>>>>
>>>>>>>>>> On Oct 7, 2013, at 11:35 PM, Zhang, Jitao David wrote:
>>>>>>>>>>
>>>>>>>>>> > Dear both,
>>>>>>>>>> >
>>>>>>>>>> >    I have updated KEGGgraph to version 1.18.0 (subversion
>>>>>>>>>> revision: 81275) in the devel branch of bioconductor. The
>>>>>>>>>> KEGGpathway2reactionGraph function now returns a reaction graph that can be
>>>>>>>>>> merged with other KEGG pathway/reaction graphs.
>>>>>>>>>> >
>>>>>>>>>> >    The updated function is given below.
>>>>>>>>>> >
>>>>>>>>>> > KEGGpathway2reactionGraph <- function(pathway) {
>>>>>>>>>> >   reactions <- getReactions(pathway)
>>>>>>>>>> >   if(length(reactions)==0) {
>>>>>>>>>> >     stop("The pathway contains no chemical reactions!\n")
>>>>>>>>>> >   }
>>>>>>>>>> >   subs <- sapply(reactions, getSubstrate)
>>>>>>>>>> >   prods <- sapply(reactions, getProduct)
>>>>>>>>>> >   types <- sapply(reactions, getType)
>>>>>>>>>> >   gridlist <- lapply(seq(along=reactions),
>>>>>>>>>> >                        function(i)
>>>>>>>>>> >                        expand.grid(subs[[i]], prods[[i]],
>>>>>>>>>> stringsAsFactors=FALSE))
>>>>>>>>>> >   grid <- as.matrix(do.call(rbind, gridlist))
>>>>>>>>>> >   isRepGrid <- duplicated(grid)
>>>>>>>>>> >   uniqGrid <- grid[!isRepGrid,,drop=FALSE]
>>>>>>>>>> >   gridTypes <- rep(types, sapply(gridlist, nrow))
>>>>>>>>>> >   uniqGridTypes <- gridTypes[!isRepGrid]
>>>>>>>>>> >
>>>>>>>>>> >   cg <- ftM2graphNEL(uniqGrid)
>>>>>>>>>> >   allNodes <- nodes(pathway)
>>>>>>>>>> >   allNodeNames <- sapply(allNodes, function(x)
>>>>>>>>>> paste(getName(x), collapse=","))
>>>>>>>>>> >   cgNodes <- allNodes[match(nodes(cg), allNodeNames)]
>>>>>>>>>> >
>>>>>>>>>> >   cgEdges <- sapply(1:nrow(uniqGrid),
>>>>>>>>>> >                     function(x)
>>>>>>>>>> >                     new("KEGGEdge",
>>>>>>>>>> >                         entry1ID=uniqGrid[x,1],
>>>>>>>>>> >                         entry2ID=uniqGrid[x,2],
>>>>>>>>>> >                         type=uniqGridTypes[x],
>>>>>>>>>> >                         subtype=list()))
>>>>>>>>>> >
>>>>>>>>>> >   ## set node and edge data - as KEGGNode and KEGGEdge
>>>>>>>>>> >   ## attention: KEGGEdges may be more than graph edges, due to
>>>>>>>>>> non-genes
>>>>>>>>>> >   names(cgEdges) <- apply(uniqGrid,1L, paste, collapse="~")
>>>>>>>>>> >   env.node <- new.env()
>>>>>>>>>> >   env.edge <- new.env()
>>>>>>>>>> >   assign("nodes", cgNodes, envir=env.node)
>>>>>>>>>> >   assign("edges", cgEdges, envir=env.edge)
>>>>>>>>>> >
>>>>>>>>>> >   nodeDataDefaults(cg, "KEGGNode") <- env.node
>>>>>>>>>> >   edgeDataDefaults(cg, "KEGGEdge") <- env.edge
>>>>>>>>>> >
>>>>>>>>>> >   return(cg)
>>>>>>>>>> > }
>>>>>>>>>> >
>>>>>>>>>> >    Try it out and please let me know if you encounter any
>>>>>>>>>> problem.
>>>>>>>>>> >
>>>>>>>>>> >    Best wishes,
>>>>>>>>>> > David
>>>>>>>>>> >
>>>>>>>>>> >
>>>>>>>>>> >
>>>>>>>>>> > On Tue, Sep 3, 2013 at 9:47 PM, Paul Shannon <
>>>>>>>>>> paul.thurmond.shannon@gmail.com> wrote:
>>>>>>>>>> > Hi Stuart,
>>>>>>>>>> >
>>>>>>>>>> > I have included Jitao David Zhang here as well, the package
>>>>>>>>>> author and maintainer.
>>>>>>>>>> >
>>>>>>>>>> > I think I can reduce your problem report to these steps:
>>>>>>>>>> >
>>>>>>>>>> > library(KEGGgraph)
>>>>>>>>>> > filename <- "hsa00260.kgml"
>>>>>>>>>> > retrieveKGML("00260", organism="hsa", destfile=filename, method
>>>>>>>>>> = "internal")
>>>>>>>>>> > pathway <- parseKGML(filename)
>>>>>>>>>> >
>>>>>>>>>> > g.reaction <- KEGGpathway2reactionGraph(pathway, uniqueReaction
>>>>>>>>>> = FALSE)
>>>>>>>>>> > g.pathway <- KEGGpathway2Graph(pathway, genesOnly=FALSE)
>>>>>>>>>> >
>>>>>>>>>> > names(nodeDataDefaults(g.reaction))   # NULL
>>>>>>>>>> > names(nodeDataDefaults(g.pathway))    # KEGGNode
>>>>>>>>>> >
>>>>>>>>>> > mergeKEGGgraphs (in KEGGgraph/R/graph.R) requires that there be
>>>>>>>>>> an edge attribute "KEGGEdge" and a node attribute "KEGGNode", and fails
>>>>>>>>>> with the error you saw.
>>>>>>>>>> >
>>>>>>>>>> >
>>>>>>>>>> > So the reaction graph does not have the two attributes required
>>>>>>>>>> by mergeKEGGgraphs.  I am not sure whether this is by design, or whether it
>>>>>>>>>> is an oversight.
>>>>>>>>>> > Once David clarifies that, we can devise some possible next
>>>>>>>>>> steps for you.
>>>>>>>>>> >
>>>>>>>>>> >  - Paul
>>>>>>>>>> >
>>>>>>>>>> > P.S   For future posts, please include (as I have tried to do
>>>>>>>>>> here) a smallish, self-contained and reproducible example, along with your
>>>>>>>>>> sessionInfo:
>>>>>>>>>> >
>>>>>>>>>> > R version 3.0.1 Patched (2013-05-26 r62815)
>>>>>>>>>> > Platform: x86_64-apple-darwin10.8.0 (64-bit)
>>>>>>>>>> >
>>>>>>>>>> > locale:
>>>>>>>>>> > [1] C
>>>>>>>>>> >
>>>>>>>>>> > attached base packages:
>>>>>>>>>> > [1] stats     graphics  grDevices utils     datasets  methods
>>>>>>>>>> base
>>>>>>>>>> >
>>>>>>>>>> > other attached packages:
>>>>>>>>>> > [1] KEGGgraph_1.17.0 graph_1.39.3     XML_3.95-0.2
>>>>>>>>>> >
>>>>>>>>>> > loaded via a namespace (and not attached):
>>>>>>>>>> > [1] BiocGenerics_0.7.4 parallel_3.0.1     stats4_3.0.1
>>>>>>>>>> tools_3.0.1
>>>>>>>>>> >
>>>>>>>>>> >
>>>>>>>>>> > On Sep 2, 2013, at 2:51 PM, Stuart Bradley wrote:
>>>>>>>>>> >
>>>>>>>>>> > > Hello all,
>>>>>>>>>> > >
>>>>>>>>>> > > I'm trying to build unified compound pathway maps, and have
>>>>>>>>>> been successful
>>>>>>>>>> > > using this method:
>>>>>>>>>> > >
>>>>>>>>>> > > library(graph)
>>>>>>>>>> > > library(KEGGgraph)
>>>>>>>>>> > >
>>>>>>>>>> > > KEGGList <- list.files(path = "C:/Users/Castor
>>>>>>>>>> > > Castle/Documents/kgml/metabolic/ko/subset/", full.names =
>>>>>>>>>> TRUE)
>>>>>>>>>> > >
>>>>>>>>>> > > AllGraphs <- lapply(KEGGList, function(x) {
>>>>>>>>>> > >  pathway <- parseKGML(x)
>>>>>>>>>> > >  pathway <- KEGGpathway2reactionGraph(pathway, uniqueReaction
>>>>>>>>>> = FALSE)
>>>>>>>>>> > > })
>>>>>>>>>> > >
>>>>>>>>>> > > FinalGraph <- mergeGraphs(AllGraphs, edgemode = "directed")
>>>>>>>>>> > >
>>>>>>>>>> > > However, I'd like to be able to use mergeKEGGgraphs as it
>>>>>>>>>> retains more
>>>>>>>>>> > > information. The problem is that when I replace  mergeGraphs
>>>>>>>>>> with
>>>>>>>>>> > > mergeKEGGgraphs
>>>>>>>>>> > > I get the following error (regardless of whether it's my own
>>>>>>>>>> files, or the
>>>>>>>>>> > > example ones provided):
>>>>>>>>>> > >
>>>>>>>>>> > > Error in .verifyAttrName(attr, names(self@defaults)):
>>>>>>>>>> > >  unknown attribute name: ŒKEGGNode‚
>>>>>>>>>> > >
>>>>>>>>>> > > Has anyone found a work around for this? I was fiddling with
>>>>>>>>>> > > setKEGGnodeData/setKEGGEdgeData in conjunction with
>>>>>>>>>> mergeGraphs, but I
>>>>>>>>>> > > can't get it to work.
>>>>>>>>>> > >
>>>>>>>>>> > > Any help would be greatly appreciated.
>>>>>>>>>> > >
>>>>>>>>>> > > Cheers,
>>>>>>>>>> > > Stuart Bradley
>>>>>>>>>> > >
>>>>>>>>>> > >       [[alternative HTML version deleted]]
>>>>>>>>>> > >
>>>>>>>>>> > > _______________________________________________
>>>>>>>>>> > > Bioconductor mailing list
>>>>>>>>>> > > Bioconductor@r-project.org
>>>>>>>>>> > > https://stat.ethz.ch/mailman/listinfo/bioconductor
>>>>>>>>>> > > Search the archives:
>>>>>>>>>> http://news.gmane.org/gmane.science.biology.informatics.conductor
>>>>>>>>>> >
>>>>>>>>>> >
>>>>>>>>>> >
>>>>>>>>>> >
>>>>>>>>>> > --
>>>>>>>>>> >
>>>>>>>>>> > Jitao David Zhang | 张继涛 | Computational Biology and
>>>>>>>>>> Bioinformatics | Pharmaceutical Divison | F. Hoffmann-La-Roche AG | CH-4070
>>>>>>>>>> Basel | Switzerland
>>>>>>>>>> >
>>>>>>>>>> > Tel +41 61 688 62 51
>>>>>>>>>> >
>>>>>>>>>> > Confidentiality Note: This message is intended only for the use
>>>>>>>>>> of the named recipient(s) and may contain confidential and/or privileged
>>>>>>>>>> information. If you are not the intended recipient, please contact the
>>>>>>>>>> sender and delete this message. Any unauthorized use of the information
>>>>>>>>>> contained in this message is prohibited.
>>>>>>>>>> >
>>>>>>>>>> > Please inform me immediately in case attached documents are
>>>>>>>>>> missing!
>>>>>>>>>> >
>>>>>>>>>> >
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>>
>>>>>>> *Jitao David Zhang | **张继涛** | Computational Biology and
>>>>>>> Bioinformatics | Pharmaceutical Divison | F. Hoffmann-La-Roche AG | CH-4070
>>>>>>> Basel | Switzerland*****
>>>>>>>
>>>>>>> *Tel +41 61 688 62 51 *
>>>>>>>
>>>>>>> Confidentiality Note: This message is intended only for the use of
>>>>>>> the named recipient(s) and may contain confidential and/or privileged
>>>>>>> information. If you are not the intended recipient, please contact the
>>>>>>> sender and delete this message. Any unauthorized use of the information
>>>>>>> contained in this message is prohibited.****
>>>>>>>
>>>>>>> *Please inform me immediately in case attached documents are
>>>>>>> missing!*
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>>
>> --
>>
>> *Jitao David Zhang | **张继涛** | Computational Biology and Bioinformatics
>> | Pharmaceutical Divison | F. Hoffmann-La-Roche AG | CH-4070 Basel |
>> Switzerland*****
>>
>> *Tel +41 61 688 62 51 *
>>
>> Confidentiality Note: This message is intended only for the use of the
>> named recipient(s) and may contain confidential and/or privileged
>> information. If you are not the intended recipient, please contact the
>> sender and delete this message. Any unauthorized use of the information
>> contained in this message is prohibited.****
>>
>> *Please inform me immediately in case attached documents are missing!*
>>
>>
>


-- 

*Jitao David Zhang | **张继涛** | Computational Biology and Bioinformatics |
Pharmaceutical Divison | F. Hoffmann-La-Roche AG | CH-4070 Basel |
Switzerland*****

*Tel +41 61 688 62 51 *

Confidentiality Note: This message is intended only for ...{{dropped:11}}

