plotTree | R Documentation |
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(object, ...)
plotColTree(object, ...)
## S4 method for signature 'TreeSummarizedExperiment'
plotColTree(
object,
tree_name = "phylo",
relabel_tree = FALSE,
order_tree = FALSE,
remove_levels = FALSE,
show_label = FALSE,
show_highlights = FALSE,
show_highlight_label = FALSE,
abbr_label = FALSE,
add_legend = TRUE,
layout = "circular",
edge_colour_by = NULL,
edge_size_by = NULL,
tip_colour_by = NULL,
tip_shape_by = NULL,
tip_size_by = NULL,
node_colour_by = NULL,
node_shape_by = NULL,
node_size_by = NULL,
colour_highlights_by = NULL,
by_exprs_values = "counts",
other_fields = list(),
...
)
## S4 method for signature 'TreeSummarizedExperiment'
plotRowTree(
object,
tree_name = "phylo",
relabel_tree = FALSE,
order_tree = FALSE,
remove_levels = FALSE,
show_label = FALSE,
show_highlights = FALSE,
show_highlight_label = FALSE,
abbr_label = FALSE,
add_legend = TRUE,
layout = "circular",
edge_colour_by = NULL,
edge_size_by = NULL,
tip_colour_by = NULL,
tip_shape_by = NULL,
tip_size_by = NULL,
node_colour_by = NULL,
node_shape_by = NULL,
node_size_by = NULL,
colour_highlights_by = NULL,
by_exprs_values = "counts",
other_fields = list(),
...
)
object |
a
|
... |
additional arguments for plotting. See
|
tree_name |
a single |
relabel_tree |
logical scalar, Should the tip labels be relabeled using
the output of |
order_tree |
logical scalar, Should the tree be ordered based on
alphabetic order of taxonomic levels?
(default: |
remove_levels |
logical scalar, Should taxonomic level information
be removed from labels? (default: |
show_label , show_highlights , show_highlight_label , abbr_label |
|
add_legend |
logical scalar. Should legends be plotted?
(default: |
layout |
layout for the plotted tree. See
|
edge_colour_by |
Specification of a column metadata field or a feature
to colour tree edges by, see the by argument in
|
edge_size_by |
Specification of a column metadata field or a feature
to size tree edges by, see the by argument in
|
tip_colour_by |
Specification of a column metadata field or a feature to
colour tree tips by, see the by argument in
|
tip_shape_by |
Specification of a column metadata field or a feature to
shape tree tips by, see the by argument in
|
tip_size_by |
Specification of a column metadata field or a feature to
size tree tips by, see the by argument in
|
node_colour_by |
Specification of a column metadata field or a feature to
colour tree nodes by. Must be a field from |
node_shape_by |
Specification of a column metadata field or a feature to
shape tree nodes by. Must be a field from |
node_size_by |
Specification of a column metadata field or a feature to
size tree nodes by. Must be a field from |
colour_highlights_by |
Should the highlights be colour differently?
If |
by_exprs_values |
A string or integer scalar specifying which assay to
obtain expression values from, for use in point aesthetics - see the
|
other_fields |
Additional fields to include in the node information without plotting them. |
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.
a ggtree
plot
splitByRanks
library(scater)
library(mia)
# preparation of some data
data(GlobalPatterns)
altExps(GlobalPatterns) <- splitByRanks(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 <- getTopFeatures(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 <- getTopFeatures(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)
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.