View source: R/calc-frequency.R
plot_frequency | R Documentation |
Plot the frequency of each cell label present in the provided meta.data column. This is useful for comparing the proportion of cells belonging to different samples, cell types, clonotypes, isotypes, etc.
plot_frequency(
input,
data_col,
cluster_col = NULL,
group_col = NULL,
method = "bar",
stack = NULL,
units = "percent",
top = NULL,
other_label = "other",
plot_colors = NULL,
plot_lvls = NULL,
na_color = "grey80",
trans = "identity",
show_points = TRUE,
show_zeros = TRUE,
n_label = NULL,
p_label = c(value = 0.05),
p_method = NULL,
p_file = NULL,
label_params = list(),
...,
per_chain = FALSE,
chain = NULL,
chain_col = global$chain_col,
sep = global$sep
)
input |
Single cell object or data.frame containing V(D)J data. If a data.frame is provided, the cell barcodes should be stored as row names. |
data_col |
meta.data column containing cell labels to use for calculating frequency, e.g. cell types, isotypes etc. |
cluster_col |
meta.data column containing cluster IDs (or patients, treatment conditions, etc.) to use when calculating frequency. Calculations will be performed separately for each cluster. |
group_col |
meta.data column to use for grouping cluster IDs present in cluster_col. This is useful when there are multiple replicates or patients for each treatment condition. |
method |
Method to use for plotting when |
stack |
If |
units |
Units to plot on the y-axis, either 'frequency' or 'percent' |
top |
To only show the top cell groups present in
|
other_label |
Label to use for 'other' cells when |
plot_colors |
Character vector containing colors for plotting |
plot_lvls |
Levels to use for ordering clusters or groups |
na_color |
Color to use for missing values |
trans |
Transformation to use for plotting data, e.g. 'log10'. By
default values are not transformed, refer to |
show_points |
If |
show_zeros |
If |
n_label |
Location on plot where n label should be added, this can be any combination of the following:
|
p_label |
Specification indicating how p-values should be labeled on plot, this can one of the following:
|
p_method |
Method to use for calculating p-values, by default when comparing two groups a t-test will be used. When comparing more than two groups the Kruskal-Wallis test will be used. With the exception of the edgeR method, p-values are adjusted for multiple testing using Bonferroni correction. Possible methods include:
|
p_file |
File path to save table containing p-values for each comparison. |
label_params |
Named list providing additional parameters to modify n label aesthetics, e.g. list(size = 4, color = "red") |
... |
Additional arguments to pass to ggplot2, e.g. color, fill, size, linetype, etc. |
per_chain |
If |
chain |
Chain(s) to use for calculating frequency. Set to |
chain_col |
meta.data column(s) containing chains for each cell |
sep |
Separator for storing per-chain data |
ggplot object
calc_frequency()
, plot_clone_frequency()
# Plot frequency of different isotypes
plot_frequency(
vdj_sce,
data_col = "isotype"
)
# Plot frequency separately for cell clusters
plot_frequency(
vdj_sce,
data_col = "isotype",
cluster_col = "orig.ident"
)
# Create grouped bar graphs
plot_frequency(
vdj_sce,
data_col = "isotype",
cluster_col = "orig.ident",
stack = FALSE
)
# Plot number of cells on the y-axis
plot_frequency(
vdj_sce,
data_col = "seurat_clusters",
cluster_col = "orig.ident",
units = "frequency"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.