R/AllGenerics.R
, R/plotTree.R
plotTree.Rd
Based on the stored data in a TreeSummarizedExperiment
a tree can
be plotted. From the rowData
, the assays
as well as the
colData
information can be taken for enriching the tree plots with
additional information.
plotRowTree(x, ...)
plotColTree(x, ...)
# S4 method for class 'TreeSummarizedExperiment'
plotColTree(
x,
tree.name = tree_name,
tree_name = "phylo",
relabel.tree = relabel_tree,
relabel_tree = FALSE,
order.tree = order_tree,
order_tree = FALSE,
levels.rm = remove_levels,
remove_levels = FALSE,
show.label = show_label,
show_label = FALSE,
show.highlights = show_highlights,
show_highlights = FALSE,
show.highlight.label = show_highlight_label,
show_highlight_label = FALSE,
abbr.label = abbr_label,
abbr_label = FALSE,
add.legend = add_legend,
add_legend = TRUE,
layout = "circular",
edge.colour.by = edge.colour.by,
edge_colour_by = NULL,
edge.size.by = edge_size_by,
edge_size_by = NULL,
tip.colour.by = tip_colour_by,
tip_colour_by = NULL,
tip.shape.by = tip_shape_by,
tip_shape_by = NULL,
tip.size.by = tip_size_by,
tip_size_by = NULL,
node.colour.by = node_colour_by,
node_colour_by = NULL,
node.shape.by = node_shape_by,
node_shape_by = NULL,
node.size.by = node_size_by,
node_size_by = NULL,
colour.highlights.by = colour_highlights_by,
colour_highlights_by = NULL,
assay.type = by_exprs_values,
by_exprs_values = "counts",
other.fields = other_fields,
other_fields = list(),
...
)
# S4 method for class 'TreeSummarizedExperiment'
plotRowTree(
x,
tree.name = tree_name,
tree_name = "phylo",
relabel.tree = relabel_tree,
relabel_tree = FALSE,
order.tree = order_tree,
order_tree = FALSE,
levels.rm = remove_levels,
remove_levels = FALSE,
show.label = show_label,
show_label = FALSE,
show.highlights = show_highlights,
show_highlights = FALSE,
show.highlight.label = show_highlight_label,
show_highlight_label = FALSE,
abbr.label = abbr_label,
abbr_label = FALSE,
add.legend = add_legend,
add_legend = TRUE,
layout = "circular",
edge.colour.by = edge_colour_by,
edge_colour_by = NULL,
edge.size.by = edge_size_by,
edge_size_by = NULL,
tip.colour.by = tip_colour_by,
tip_colour_by = NULL,
tip.shape.by = tip_shape_by,
tip_shape_by = NULL,
tip.size.by = tip_size_by,
tip_size_by = NULL,
node.colour.by = node_colour_by,
node_colour_by = NULL,
node.shape.by = node_shape_by,
node_shape_by = NULL,
node.size.by = node_size_by,
node_size_by = NULL,
colour.highlights.by = colour_highlights_by,
colour_highlights_by = NULL,
assay.type = by_exprs_values,
by_exprs_values = "counts",
other.fields = other_fields,
other_fields = list(),
...
)
additional arguments for plotting. See
mia-plot-args
for more details i.e. call
help("mia-plot-args")
Character scalar
. Specifies a rowTree/colTree from
x
. (Default: tree.name = "phylo"
)
Deprecated. Use tree.name
instead.
Logical scalar
. Should the tip labels be relabeled
using the output of getTaxonomyLabels(x, with_rank = TRUE)
?
(Default: FALSE
)
Deprecated. Use relavel.tree
instead.
Logical scalar
. Should the tree be ordered based on
alphabetic order of taxonomic levels? (Default: FALSE
)
Deprecated. Use order.tree
instead.
Logical scalar
. Should taxonomic level information
be removed from labels? (Default: FALSE
)
Deprecated. Use levels.rm
instead.
logical
(scalar), integer
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 the label
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, show.highlights, show.highlight.label, abbr_label
instead.
Logical scalar
. Should legends be plotted?
(Default: TRUE
)
Deprecated. Use add.legend
instead.
layout for the plotted tree. See
ggtree
for details.
Character scalar
. Specification of a column
metadata field or a feature to colour tree edges by, see the by argument in
?retrieveCellInfo
for possible
values.
Deprecated. Use edge.colour.by
instead.
Character scalar
. Specification of a column
metadata field or a feature to size tree edges by, see the by argument in
?retrieveCellInfo
for possible
values. (Default: NULL
)
Deprecated. Use edge.size.by
instead.
Character scalar
. Specification of a column
metadata field or a feature to colour tree tips by, see the by argument in
?retrieveCellInfo
for possible
values. (Default: NULL
)
Deprecated. Use tip.colour.by
instead.
Character scalar
. Specification of a column
metadata field or a feature to shape tree tips by, see the by argument in
?retrieveCellInfo
for possible
values. (Default: NULL
)
Deprecated. Use tip.shape.by
isntead.
Character scalar
. Specification of a column
metadata field or a feature to size tree tips by, see the by argument in
?retrieveCellInfo
for possible
values. (Default: NULL
)
Deprecated. Use tip.size.by
instead.
Character scalar
. Specification of a column
metadata field or a feature to colour tree nodes by. Must be a field from
other.fields
. (Default: NULL
)
Deprecated. Use node.colour.by
instead.
Character scalar
. Specification of a column
metadata field or a feature to shape tree nodes by. Must be a field from
other.fields
. (Default: NULL
)
Deprecated. Use node.shape.by
instead.
Character scalar
. Specification of a column
metadata field or a feature to size tree nodes by. Must be a field from
other.fields
. (Default: NULL
)
Deprecated. Use node.size.by
instead.
Logical scalar
. Should the highlights be
colour differently? If show.highlights = TRUE
,
colour_highlights
will be set to TRUE
as default.
(Default: FALSE
)
Deprecated. Use colour.highlights.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.
Character vector
. Additional fields to include in
the node information without plotting them. (Default: list()
)
Deprecated. Use other.fields
instead.
a ggtree
plot
If show.label
or show.highlight.label
have the same length
as the number of nodes, the vector will be used to relabel the nodes.
library(scater)
library(mia)
# preparation of some data
data(GlobalPatterns)
GlobalPatterns <- agglomerateByRanks(GlobalPatterns)
altExp(GlobalPatterns,"Genus") <- addPerFeatureQC(
altExp(GlobalPatterns,"Genus"))
rowData(altExp(GlobalPatterns,"Genus"))$log_mean <-
log(rowData(altExp(GlobalPatterns,"Genus"))$mean)
rowData(altExp(GlobalPatterns,"Genus"))$detected <-
rowData(altExp(GlobalPatterns,"Genus"))$detected / 100
top_genus <- getTop(altExp(GlobalPatterns,"Genus"),
method="mean",
top=100L,
assay.type="counts")
#
x <- altExp(GlobalPatterns,"Genus")
plotRowTree(x[rownames(x) %in% top_genus,],
tip.colour.by = "log_mean",
tip.size.by = "detected")
# plot with tip labels
plotRowTree(x[rownames(x) %in% top_genus,],
tip.colour.by = "log_mean",
tip.size.by = "detected",
show.label = TRUE)
# plot with selected labels
labels <- c("Genus:Providencia", "Genus:Morganella", "0.961.60")
plotRowTree(x[rownames(x) %in% top_genus,],
tip.colour.by = "log_mean",
tip.size.by = "detected",
show.label = labels,
layout="rectangular")
# plot with labeled edges
plotRowTree(x[rownames(x) %in% top_genus,],
edge.colour.by = "Phylum",
tip.colour.by = "log_mean")
# if edges are sized, colours might disappear depending on plotting device
plotRowTree(x[rownames(x) %in% top_genus,],
edge.colour.by = "Phylum",
edge.size.by = "detected",
tip.colour.by = "log_mean")
# aggregating data over the taxonomic levels for plotting a taxonomic tree
# please note that the original tree of GlobalPatterns is dropped by
# unsplitByRanks
altExps(GlobalPatterns) <- splitByRanks(GlobalPatterns)
top_phyla <- getTop(altExp(GlobalPatterns,"Phylum"),
method="mean",
top=10L,
assay.type="counts")
altExps(GlobalPatterns) <- lapply(altExps(GlobalPatterns), addPerFeatureQC)
altExps(GlobalPatterns) <-
lapply(altExps(GlobalPatterns),
function(y){
rowData(y)$log_mean <- log(rowData(y)$mean)
rowData(y)$detected <- rowData(y)$detected / 100
y
})
x <- unsplitByRanks(GlobalPatterns)
x <- addHierarchyTree(x)
#> Warning: The root is added with label 'ALL'
highlights <- c("Phylum:Firmicutes","Phylum:Bacteroidetes",
"Family:Pseudomonadaceae","Order:Bifidobacteriales")
plotRowTree(x[rowData(x)$Phylum %in% top_phyla,],
tip.colour.by = "log_mean",
node.colour.by = "log_mean",
show.highlights = highlights,
show.highlight.label = highlights,
colour.highlights.by = "Phylum")
plotRowTree(x[rowData(x)$Phylum %in% top_phyla,],
edge.colour.by = "Phylum",
edge.size.by = "detected",
tip.colour.by = "log_mean",
node.colour.by = "log_mean")