[Bioc-devel] Protection stack overflow

Ivana Ihnatová |v@n@@|hn@tov@ @end|ng |rom recetox@mun|@cz
Mon Jul 22 16:45:35 CEST 2019


Dear mailing list members,

my implementation (part of a package) throws "protect(): protection stack overflow" during check.  The only solution for this error I could find, suggest to modify --max-ppsize parameter or replace data.frames with matrices.  I don't find the former acceptible for packages and the latter is not related to the task to be solved.

The task to solve is to calculate multiple metrics for each node of a pathway represented by graphNEL. Some of them require lengths of the shortest path between all pairs of nodes.  For the other metrics I could possibly use matrix as graph representation.

I would greatly apprieciate any help.

I attach my current implementation below. But this is not necessary working example, as in clean R session it seems to run.  Moreover, it is called from a wrapper function, if this is relevant. The tracebacks point either to the
setNames(rep(1, length(geneNames)), geneNames) or RBGL::floyd.warshall.all.pairs.sp.

Best whishes,

Ivana


.indegree<-function(px){
  return(degree(px)$inDegree)
}

.outdegree<-function(px){
  return(degree(px)$outDegree)
}

.inreach<-function(px){
  sp<-RBGL::floyd.warshall.all.pairs.sp(px)
  sp[is.infinite(sp)]<-NA
  out<-apply(sp, 2, max, na.rm=TRUE) #inreach
  return(out)
}

.outreach<-function(px){
  sp<-RBGL::floyd.warshall.all.pairs.sp(px)
  sp[is.infinite(sp)]<-NA
  out<-apply(sp, 1, max, na.rm=TRUE) #outreach
  return(out)
}

.between<-function(px){
  return(betweenness(as(px,"matrix"), nodes(px)))
}

.CePaWeights<-function(x, method){
  out<-list()
  length(out)<-length(method)
  names(out)<-method
  geneNames<-nodes(x)
  if (any(method == "equal.weight")) {
    out[["equal.weight"]] <- setNames(rep(1, length(geneNames)),
                                      geneNames)
  }
  if (any(method == "in.degree")) {
    out[["in.degree"]]<-.indegree(x)
  }
  if (any(method == "out.degree")) {
    out[["out.degree"]]<-.outdegree(x)
  }
  if (any(method == "degree")) {
    out[["degree"]]<-graph::degree(x, nodes(x))
  }
  if (any(method == "betweenness")) {
    out[["betweenness"]]<-.between(x)
  }
  if (any(method == "in.reach")) {
    out[["in.reach"]]<-.inreach(x)
  }
  if (any(method == "out.reach")) {
    out[["out.reach"]]<-.outreach(x)
  }

  out<-lapply(out, function(x) {
    nz<-x>0
    if (sum(nz)>0) return(x+min(x[nz])/100) else return(x)
  })
  return(out)
}


library(graphite)
pathways<-pathways("hsapiens","biocarta")
paths<-lapply(pathways, function(x) list(pathwayGraph(x), x using title))
cen <- c("equal.weight", "in.degree", "out.degree", "in.reach",
         "out.reach", "betweenness")

CenList <- lapply(paths[2], function(x) {
  .CePaWeights(x[[1]], cen)
})

	[[alternative HTML version deleted]]



More information about the Bioc-devel mailing list