Diff of /man/add_boxplot.Rd [000000] .. [0f2269]

Switch to unified view

a b/man/add_boxplot.Rd
1
% Generated by roxygen2: do not edit by hand
2
% Please edit documentation in R/CircosFruits.R
3
\name{add_boxplot}
4
\alias{add_boxplot}
5
\title{Add a boxplot layer to a `ggtree` plot}
6
\usage{
7
add_boxplot(
8
  p,
9
  data,
10
  fill_color = "#f28131",
11
  alpha = 0.6,
12
  offset = 0.22,
13
  pwidth = 0.5
14
)
15
}
16
\arguments{
17
\item{p}{An existing ggtree plot object.}
18
19
\item{data}{A data frame containing the data to be plotted. Expected to have columns for 'Sample' and 'value'.}
20
21
\item{fill_color}{A character string specifying the fill color for the boxplots. Default is "#f28131".}
22
23
\item{alpha}{Numeric value for the transparency of the boxplots. Default is 0.6.}
24
25
\item{offset}{Numeric value, the position of the boxplot on the x-axis relative to its gene name. Default is 0.22.}
26
27
\item{pwidth}{Numeric value, the width of the boxplot. Default is 0.5.}
28
}
29
\value{
30
A `ggtree` plot object with the added boxplot layer.
31
}
32
\description{
33
This function adds a boxplot layer to an existing `ggtree` plot object using ggtreeExtra's geom_fruit for boxplots.
34
It is primarily used to display statistical summaries of the data related to gene expressions or other metrics.
35
}
36
\examples{
37
\donttest{
38
# Check and load required packages
39
if (requireNamespace("ggtreeExtra", quietly = TRUE) &&
40
 requireNamespace("ggplot2", quietly = TRUE)) {
41
  library(ggtreeExtra)
42
  library(ggplot2)
43
44
  file_path <- system.file("extdata", "p_tree_test.rds", package = "TransProR")
45
  p <- readRDS(file_path)
46
47
  # Create boxplot data frame
48
  boxplot_data <- data.frame(
49
    Sample = rep(c("Species_A", "Species_B", "Species_C", "Species_D"), each = 30),
50
    value = c(
51
      rnorm(30, mean = 5, sd = 1),   # Data for Species_A
52
      rnorm(30, mean = 7, sd = 1.5), # Data for Species_B
53
      rnorm(30, mean = 6, sd = 1.2), # Data for Species_C
54
      rnorm(30, mean = 8, sd = 1.3)  # Data for Species_D
55
    )
56
  )
57
58
  # Call add_boxplot function to add boxplot layer
59
  p_with_boxplot <- add_boxplot(p, boxplot_data)
60
} else {
61
  message("Required packages 'ggtreeExtra' and 'ggplot2' are not installed.")
62
}
63
}
64
65
}