prune_vertices removes vertices from a neuron
prune_edges removes edges (and any unreferenced vertices)
prune_vertices(x, verticestoprune, invert = FALSE, ...) prune_edges(x, edges, invert = FALSE, ...)
neuron to prune. This can be any object that can be
as.ngraph --- see details.
An integer vector describing which vertices to remove.
Whether to keep vertices rather than dropping them (default FALSE).
Additional arguments passed to
The edges to remove. One of i) an Nx2 matrix, each row
specifying a single edge defined by its raw edge id, ii) an integer
vector defining a path of raw vertex ids or iii) an
edge sequence --- see details and the
These are relatively low-level functions and you will probably want
friends in many cases.
prune_edges both use raw
vertex ids to specify the vertices/edges to be removed. If you want to use
the id in the PointNo field, then you must translate yourself (see
prune_edges first convert their input
x to the
ngraph representation of the neuron before
removing points. The input
x can therefore be in any form compatible
as.ngraph including an existing
ngraph. There is
an additional requirement that the input must be compatible with
Note that the
edges argument of
prune_edges must specify a
path traversing a set of vertices in a valid order. However if the input is
a matrix or vector the direction of each individual edge in this path is
ignored. So if your neuron has edges 2->1 2->3 3->4 then an edge sequence
1:3 would successfully delete 2 edges.
n=prune_vertices(Cell07PNs[], 1:25) # original neuron plot(Cell07PNs[]) # with pruned neuron superimposed plot(n, col='green', lwd=3, add=TRUE) # use the PointNo field (= the original id from an SWC file) n2=prune_vertices(n, match(26:30, n$d$PointNo)) y=prune_edges(Cell07PNs[], edges=1:25) # remove the spine of a neuron spine_ids=spine(Cell07PNs[], rval='ids') pruned=prune_edges(Cell07PNs[], spine_ids) # NB this is subtly different from this, which removes vertices along the # spine *even* if they are part of an edge that is outside the spine. pruned2=prune_vertices(Cell07PNs[], spine_ids)