diff --git a/NAMESPACE b/NAMESPACE index df1e5917..a48a203c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -114,6 +114,7 @@ S3method(ndigest,neuron) S3method(ndigest,neuronlistfh) S3method(nvertices,default) S3method(nvertices,dotprops) +S3method(nvertices,igraph) S3method(nvertices,neuron) S3method(nvertices,neuronlist) S3method(nvertices,shapelist3d) diff --git a/R/neuron.R b/R/neuron.R index d1174029..bc51a25e 100644 --- a/R/neuron.R +++ b/R/neuron.R @@ -290,7 +290,7 @@ as.neuron.ngraph<-function(x, vertexData=NULL, origin=NULL, Verbose=FALSE, ...){ d=seglist2swc(x=subtrees,d=d) d=normalise_swc(d) - n=list(d=d,NumPoints=igraph::vcount(masterg), + n=list(d=d,NumPoints=nvertices(masterg), StartPoint=StartPoint, BranchPoints=branchpoints(masterg, original.ids='vid'), EndPoints=endpoints(masterg, original.ids='vid'), diff --git a/R/xform.R b/R/xform.R index 4a766445..e4b14a99 100644 --- a/R/xform.R +++ b/R/xform.R @@ -230,6 +230,13 @@ xform.neuronlist<-function(x, reg, subset=NULL, ..., OmitFailures=NA, } +#' @rdname nvertices +#' @export +nvertices.igraph <- function(x, ...) { + # as of igraph 2.0 this is numeric + as.integer(igraph::vcount(x)) +} + #' Mirror 3D object about a given axis, optionally using a warping registration #' #' @description mirroring with a warping registration can be used to account diff --git a/man/nvertices.Rd b/man/nvertices.Rd index 8de405a7..136faf04 100644 --- a/man/nvertices.Rd +++ b/man/nvertices.Rd @@ -1,12 +1,15 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/xyzmatrix.R -\name{nvertices} +% Please edit documentation in R/xform.R, R/xyzmatrix.R +\name{nvertices.igraph} +\alias{nvertices.igraph} \alias{nvertices} \alias{nvertices.default} \alias{nvertices.neuronlist} \alias{nvertices.shapelist3d} \title{Find the number of vertices in an object (or each element of a neuronlist)} \usage{ +\method{nvertices}{igraph}(x, ...) + nvertices(x, ...) \method{nvertices}{default}(x, ...)