treecortreatplot: Visualize TreeCorTreat

View source: R/treecortreatplot.R

treecortreatplotR Documentation

Visualize TreeCorTreat

Description

Generate TreeCorTreat plot to summarize and visualize the result.

Usage

treecortreatplot(
  hierarchy_list,
  annotated_df,
  response_variable,
  separate = T,
  num_cancor_components = 1,
  color_variable = NULL,
  size_variable = NULL,
  alpha_variable = NULL,
  advanced_list = NULL,
  annotate_number = F,
  annotate_number_column = NULL,
  annotate_number_fontsize = 5,
  annotate_number_color = "black",
  font_size = 10,
  nonleaf_label_pos = 0.6,
  nonleaf_point_gap = NULL,
  edge_path_type = "link",
  plot_type = "balloon",
  line_color = "black",
  line_type = "solid",
  plot = T
)

Arguments

hierarchy_list

A hierarchy list by running 'extract_hrchy_text()' or 'extract_hrchy_seurat()' function. Contains 'edges', 'layout', 'immediate_children' and 'leaves_info' as 4 elements.

annotated_df

A data frame contains summary statistic (canonical correlation or number of differential expressed genes, etc) and/or adjusted p-value for each tree node. Can be obtained by running 'treecor_ctprop()$canonical_corr' or 'treecor_expr()$canonical_corr' or 'treecor_deg()$dge.summary'.

response_variable

A vector of response variables.

separate

A TRUE (default) or FALSE indicator, specifying whether response variables are evaluated separately (TRUE) or jointly (FALSE). This should be the same 'separate' parameter specified in 'treecor_ctprop()$canonical_corr' or 'treecor_expr()$canonical_corr'.

num_cancor_components

Number of canonical components to be extracted (by default: 1). Only works when separate = F.

color_variable

Set color aesthetics to a variable. This variable should be one of column names in annotated_df.

size_variable

Set size aesthetics to a variable. This variable should be one of column names in annotated_df.

alpha_variable

Set alpha (transparency) aesthetics to a variable. This variable should be one of column names in annotated_df.

advanced_list

A list for more advanced figure configuration. Default is NULL. Users can specify label color or manually specify your own set of mappings from levels in the data to aesthetic values. Names of this list must be one of 'label_info','size_info','color_info', 'alpha_info','palette','plot_layout'.

  • label_info: a data frame that contains two columns: 'label' and 'label.color'. The label name should be same as the ones provided in annotated_df, which will be used to merged with annotated_df data frame.

  • color_info: a data frame that contains two columns: 'breaks' and 'values'. This will be used to override default setting using scale_color_manual() function (currently only support discrete variables)

  • size_info: a data frame that contains two columns: 'breaks' and 'values'. This will be used to override default setting using scale_size_manual() function (currently only support discrete variables)

  • alpha_info: a data frame that contains two columns: 'breaks' and 'values'. This will be used to override default setting using scale_alpha_manual() function (currently only support discrete variables)

  • palette: a string or an index specify palette when plotting continuous variable. Default is 'Spectral'.

  • layout_widths: a vector of two numbers to specify plot layout (left:right). The relative widths of non-leaf (left) and leaf part (right) in the grid. Default is c(10,5).

annotate_number

A TRUE or FALSE (default) indicator, specifying whether to annotate numbers in the plot.

annotate_number_column

Specify column names to annotate text

annotate_number_fontsize

Specify size of annotated text. Default is 5.

annotate_number_color

Specify color of annotated text if annotate_number = T. Default is 'black'.

font_size

Font size

nonleaf_label_pos

A number from 0 to 1, controlling the relative positions of non-leaf labels (default: 0.6). Default tree height between adjacent hierarchy levels is 1.

nonleaf_point_gap

Specify the gap between circles in non-leaf (left) part, especially useful when works with multivariate phenotypes.

edge_path_type

Specify an edge type, must be one of:

  • link (default): Use straight lines to connect start and end nodes by applying geom_edge_link() in ggraph package. Recommended only for pre-set approach (i.e. generate hierarchy_list using extract_hrchy_string()).

  • diagonal: Use diagonal bezier curves to connect start and end nodes by applying geom_edge_diagonal() in ggraph package. Recommended only for pre-set approach (i.e. generate hierarchy_list using extract_hrchy_string()).

  • elbow: Draw classical dendrograms by applying geom_edge_elbow() in ggraph package. Recommended only for data-driven approach (i.e. generate hierarchy_list using extract_hrchy_seurat()).

plot_type

Specify a type to display the leaf part, must be one of:

  • balloon (default): balloon plot, where size of a dot reflects magnitude of result.

  • bar: bar plot, where height of each bar reflects magnitude of result.

  • heatmap: heatmap, where color of each grid reflects magnitude of result.

line_color

Specify line color for hierarchical tree structure (default: black).

line_type

Specify line type for hierarchical tree structure, can be one of 'solid' (default), 'dashed', 'dotted', 'dotdash', 'longdash' and 'twodash'.

plot

Print the plot

Value

A list of ggplot class objects and annotated data frames (in a long format):

  • left: a ggplot class object for non-leaf part

  • right: a ggplot class object for leaf part

  • combine: full TreeCorTreat plot by combining left and right parts

  • left_data: annotated data frame for non-leaf part

  • right_data: annotated data frame for leaf part, including id, xy coordinates, label, response variable(s), aesthetics (size, color, alpha)

Author(s)

Boyang Zhang <bzhang34@jhu.edu>, Hongkai Ji

Examples

treecortreatplot(hierarchy_list, annotated_df, response_variable = 'severity', color_variable = 'adjp.sign', size_variable = 'cancor', alpha_variable = 'adjp.sign',nonleaf_label_pos = 0.25,nonleaf_point_gap = 0.15, plot = T)

byzhang23/TreeCorTreat documentation built on May 7, 2024, 8:37 a.m.