Box plot showing the expression or activity of selected features by self-defined groups
feature_boxplot.Rd
This function is used to draw a box plot of selected features among self-defined groups from a sparse eset object.
Usage
feature_boxplot(
input_eset,
features = NULL,
group_by = "clusterID",
ncol = 3,
colors = NULL,
legend.position = "right",
fontsize.legend_title = 10,
fontsize.legend_text = 8,
fontsize.strip = 10,
fontsize.axis_title = 10,
fontsize.axis_text = 8,
xlabel.angle = 0,
ylabel.text = "Expression (log2CPM)",
stat_method = "median",
add_jitter = FALSE,
jitter.height = 0,
jitter.width = 0.3,
jitter.size = 0.1
)
Arguments
- input_eset
The expression set object that filtered, normalized and log-transformed
- features
A vector of genes or drivers (row.names of the input eset) to plot
- group_by
Character, name of the column for grouping, usually the column of cell types or clusters. Default: "
clusterID
".- ncol
Integer, number of columns when multiple plots are displayed. Default: 3.
- colors
A vector of colors for filling the violins. The length should be same as the number of groups. Default:
NULL
(ggplot default colors).- legend.position
Character, position of legend: "
right
" (the default), "left
", "top
", "bottom
" or "none
".- fontsize.legend_title
Integer, font size of the legend title. Default: 10.
- fontsize.legend_text
Integer, font size of the legend text. Default: 8.
- fontsize.strip
Integer, font size of the plot strip. Default: 10.
- fontsize.axis_title
Integer, font size of the axis label and text. Default: 10.
- fontsize.axis_text
Integer, font size of the axis label and text. Default: 8.
- xlabel.angle
Numeric, the angle of the a-axis title. When it's set not 0, the x-axis text will automatically right-justified. Default: 0.
- ylabel.text
Character, the title of y-axis. Default: "
Expression (log2CPM)
"- stat_method
Character or NULL. method of the stat point to show: "
median
" (the default), "mean
". IfNULL
, the stat point won't show up.- add_jitter
Logical, whether to add jittered points. Default:
FALSE
.- jitter.height
Numeric, amount of vertical jitter. Default: 0.
- jitter.width
Numeric, amount of horizontal jitter. Default: 0.3.
- jitter.size
Numeric, size of the jittered points. Default: 0.1.
Examples
data(pbmc14k_expression.eset)
## 1. violin plots grouped by clusters (say the column name is 'clusterID')
p_box <- feature_boxplot(input_eset = pbmc14k_expression.eset,
features = c("CD14", "CD19", "CD8A"),
group_by = "clusterID")
## 2. violin plots grouped by cell types (say the column name is 'cellType')
p_box <- feature_boxplot(input_eset = pbmc14k_expression.eset,
features = c("CD14", "CD19", "CD8A"),
group_by = "cellType")
## 3. customize the colors to fill the violin plots
p_box <- feature_boxplot(input_eset = pbmc14k_expression.eset,
features = c("CD14", "CD19", "CD8A"),
group_by = "clusterID",
colors = c("blue", "red", "green", "orange", "purple", "grey", "brown"))
## 4. add jittered points
p_box <- feature_boxplot(input_eset = pbmc14k_expression.eset,
features = c("CD14", "CD19", "CD8A"),
group_by = "clusterID",
add_jitter = TRUE,
jitter.width = 0.5, jitter.size = 0.5)