Description Usage Arguments Details Examples
These methods convert graph objects (e.g. edgeList
)
and objects containing graph data (e.g. sparsebnFit
,
sparsebnPath
) to other formats including igraph
,
graphNEL
, network
, and
bn-class
.
Only graph objects are modified with these methods. For example, if the input
is either sparsebnFit
or sparsebnPath
,
the output will still be a sparsebnFit
or sparsebnPath
object. Only the edges
slots will be converted to a different graph type.
This will be the case for the default output from estimate.dag
,
so that metadata from the learning phase is not lost during conversion.
If, on the other hand, the input is already an edgeList
, then the
output will directly be a graph object.
1 2 3 4 5 6 7 | to_bn(x)
to_graphNEL(x)
to_igraph(x)
to_network(x)
|
x |
An object of type |
to_igraph
converts sparsebn objects to igraph
-compatible
objects.
to_graph
converts sparsebn objects to graphNEL
-compatible
objects.
to_network
converts sparsebn objects to network
-compatible
objects.
to_bn
converts sparsebn objects to bn-class
-compatible
objects.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ## Not run:
### Learn the cytometry network
library(sparsebn)
data(cytometryContinuous)
cyto.data <- sparsebnData(cytometryContinuous[["data"]],
type = "continuous",
ivn = cytometryContinuous[["ivn"]])
cyto.learn <- estimate.dag(data = cyto.data)
### The output is a sparsebnPath object, which is a list of sparsebnFit objects
class(cyto.learn)
class(cyto.learn[[1]])
### Convert to igraph
cyto.igraph <- to_igraph(cyto.learn)
class(cyto.igraph) # not an igraph object!
class(cyto.igraph[[1]]$edges) # the graph data in the 'edges' slot is converted to igraph
gr <- cyto.igraph[[1]]$edges
### Different behaviour when input is already an edgeList
edgeL <- cyto.learn[[1]]$edges
gr <- to_igraph(edgeL) # input is edgeList, not sparsebnFit or sparsebnPath
class(gr) # igraph object
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.