SummarizedExperiment
R/AllGenerics.R
, R/plotGraph.R
plotGraph.Rd
plotGraph
plots an igraph
object with additional information
matched from a SummarizedExperiment
object for the nodes only.
Information on the edges have to provided manually.
plotColGraph(x, y, ...)
plotRowGraph(x, y, ...)
# S4 method for class 'ANY,SummarizedExperiment'
plotColGraph(
x,
y,
show.label = show_label,
show_label = FALSE,
add.legend = add_legend,
add_legend = TRUE,
layout = "kk",
edge.type = edge_type,
edge_type = c("fan", "link", "arc", "parallel"),
edge.colour.by = edge_colour_by,
edge_colour_by = NULL,
edge.width.by = edge_width_by,
edge_width_by = NULL,
colour.by = colour_by,
colour_by = NULL,
shape.by = shape_by,
shape_by = NULL,
size.by = size_by,
size_by = NULL,
assay.type = by_exprs_values,
by_exprs_values = "counts",
other.fields = other_fields,
other_fields = list(),
...
)
# S4 method for class 'SummarizedExperiment,missing'
plotColGraph(x, y, name = "graph", ...)
# S4 method for class 'ANY,SummarizedExperiment'
plotRowGraph(
x,
y,
show.label = show_label,
show_label = FALSE,
add.legend = add_legend,
add_legend = TRUE,
layout = "kk",
edge.type = edge_type,
edge_type = c("fan", "link", "arc", "parallel"),
edge.colour.by = edge_colour_by,
edge_colour_by = NULL,
edge.width.by = edge_width_by,
edge_width_by = NULL,
colour.by = colour_by,
colour_by = NULL,
shape.by = shape_by,
shape_by = NULL,
size.by = NULL,
assay.type = by_exprs_values,
by_exprs_values = "counts",
other.fields = other_fields,
other_fields = list(),
...
)
# S4 method for class 'SummarizedExperiment,missing'
plotRowGraph(x, y, name = "graph", ...)
a graph object and a
SummarizedExperiment
object or just a
SummarizedExperiment
.
For the latter object a graph object must be stored in
metadata(x)$name
.
additional arguments for plotting. See
mia-plot-args
for more details i.e. call
help("mia-plot-args")
Logical scalar
, integer vector
or
character vector
If a logical
scalar is given, should tip labels be plotted
or if a logical vector is provided, which labels should be shown? If an
integer
or character
vector is provided, it will be converted
to a logical vector. The integer
values must be in the range of 1
and number of nodes, whereas the values of a character
vector must
match values of a label
or name
column in the node data. In
case of a character
vector only values corresponding to actual
labels will be plotted and if no labels are provided no labels will be
shown. (Default: FALSE
)
Deprecated. Use show.label
instead.
Logical scalar
. Should legends be plotted?
(Default: TRUE
)
Deprecated. Use add.legend
instead.
Character scalar
. Layout for the plotted graph. See
ggraph
for details. (Default: "kk"
)
Character scalar
. Type of edge plotted on the graph.
See geom_edge_fan
for details and other
available geoms. (Default: "fan"
)
Deprecated. Use edge.type
instead.
Character scalar
. Specification of an edge
metadata field to use for setting colours of the edges.
(Default: NULL
)
Deprecated. Use edge.colour.by
instead.
Character scalar
. Specification of an edge
metadata
field to use for setting width of the edges. (Default: NULL
)
Deprecated. Use edge.width.by
instead.
Character scalar
. Specification of a column metadata
field or a feature to colour graph nodes by, see the by argument in
?retrieveCellInfo
for possible
values. (Default: NULL
)
Deprecated. Use colour.by
instead.
Character scalar
. Specification of a column metadata
field or a feature to shape graph nodes by, see the by argument in
?retrieveCellInfo
for possible
values. (Default: NULL
)
Deprecated. Use shape.by
instead.
Character scalar
. Specification of a column metadata
field or a feature to size graph nodes by, see the by argument in
?retrieveCellInfo
for possible
values. (Default: NULL
)
Deprecated. Use size.by
instead.
Character scalar
. or integer scalar
.
Specifies which assay to obtain expression values from, for use in point
aesthetics - see the exprs_values
argument in
?retrieveCellInfo
.
(Default: "counts"
)
Deprecated. Use assay.type
instead.
Additional fields to include in the node information without plotting them.
Deprecated. Use other.fields
instead.
Character scalar
. If x
is a
SummarizedExperiment
the key for subsetting the metadata(x)
to a graph object.
(Default: "graph"
)
a ggtree
plot
Internally tidygraph
and ggraph
are used. Therefore, all
graph types which can be converted by tidygraph::as_tbl_graph
can
be used.
# \donttest{
# data setup
library(mia)
data(GlobalPatterns)
data(col_graph)
data(row_graph)
data(row_graph_order)
metadata(GlobalPatterns)$col_graph <- col_graph
genus <- agglomerateByRank(GlobalPatterns,"Genus",na.rm=TRUE)
metadata(genus)$row_graph <- row_graph
order <- agglomerateByRank(genus,"Order",na.rm=TRUE)
#> Warning: The following values are already present in `metadata` and will be overwritten: 'agglomerated_by_rank'. Consider using the 'name' argument to specify alternative names.
metadata(order)$row_graph <- row_graph_order
# plot a graph independently
plotColGraph(col_graph,
genus,
colour.by = "SampleType",
edge.colour.by = "weight",
edge.width.by = "weight",
show.label = TRUE)
#> This graph was created by an old(er) igraph version.
#> ℹ Call `igraph::upgrade_graph()` on it to use with the current igraph version.
#> For now we convert it on the fly...
# plot the graph stored in the object
plotColGraph(genus,
name = "col_graph",
colour.by = "SampleType",
edge.colour.by = "weight",
edge.width.by = "weight")
# plot a graph independently
plotRowGraph(row_graph,
genus,
colour.by = "Kingdom",
edge.colour.by = "weight",
edge.width.by = "weight")
#> This graph was created by an old(er) igraph version.
#> ℹ Call `igraph::upgrade_graph()` on it to use with the current igraph version.
#> For now we convert it on the fly...
# plot the graph stored in the object
plotRowGraph(genus,
name = "row_graph",
colour.by = "Phylum",
edge.colour.by = "weight",
edge.width.by = "weight")
# plot a graph independently
plotRowGraph(row_graph_order,
order,
colour.by = "Kingdom",
edge.colour.by = "weight",
edge.width.by = "weight")
#> This graph was created by an old(er) igraph version.
#> ℹ Call `igraph::upgrade_graph()` on it to use with the current igraph version.
#> For now we convert it on the fly...
# plot the graph stored in the object and include some labels
plotRowGraph(order,
name = "row_graph",
colour.by = "Phylum",
edge.colour.by = "weight",
edge.width.by = "weight",
show.label = c("Sulfolobales","Spirochaetales",
"Verrucomicrobiales"))
# labels can also be included via selecting specific rownames of x/y
plotRowGraph(order,
name = "row_graph",
colour.by = "Phylum",
edge.colour.by = "weight",
edge.width.by = "weight",
show.label = c(1,10,50))
# labels can also be included via a logical vector, which has the same length
# as nodes are present
label_select <- rep(FALSE,nrow(order))
label_select[c(1,10,50)] <- TRUE
plotRowGraph(order,
name = "row_graph",
colour.by = "Phylum",
edge.colour.by = "weight",
edge.width.by = "weight",
show.label = label_select)
# }