| plot_feature_by_group | R Documentation |
Plot a gene/numeric/categorical feature by group as violin or boxplot
jj_plot_sparse_by_group_seurat(
seurat_obj,
gene_plot,
group_column,
assay = NULL,
slot = "data",
...
)
jj_plot_sparse_by_group(
rna_mat,
gene_plot,
group_vec,
x_lab = "Group",
theme_use = theme_minimal(),
plot_cell_sample = FALSE,
plot_zero_fraction = TRUE,
plot_mean = TRUE,
plot_group_size = FALSE,
type = "violin",
custom_colors = NULL,
order = FALSE,
flip_coordinates = FALSE,
cap_top = NULL,
...
)
jj_plot_numeric_by_group(
df,
feature_column,
group_column,
custom_colors = NULL,
plot_cell_sample = FALSE,
plot_mean = TRUE,
show_annotation = NULL,
annotation_at = NULL,
theme_use = theme_minimal(),
type = "violin",
order = FALSE,
flip_coordinates = FALSE,
...
)
jj_plot_categorical_by_group(
df,
feature_column,
group_column,
custom_colors = NULL,
absolute_numbers = FALSE,
return_df = FALSE,
flip_coordinates = FALSE,
add_text = FALSE,
text_size = 5,
theme_use = theme_minimal(),
...
)
seurat_obj |
Seurat object that contains the |
gene_plot |
Gene from the RNA matrix to plot |
group_column |
string of the column with the variable used to group the feature |
... |
further arguments passed to the main geom of ggplot |
group_vec |
Vector of strings with the grouping information |
x_lab |
label for the groups |
theme_use |
theme to use, default: theme_minimal() |
plot_cell_sample |
if TRUE, plot a sample of cells for each group (equal number) |
plot_zero_fraction |
for sparse data, plot the fraction of zero counts per group as pie |
plot_mean |
Plot the mean value per group as horizontal line |
plot_group_size |
Plot number of cells per group, in jj_plot_numeric_by_group replaced by show_annotation with choices c('n','mean','sd') |
type |
Type of plot, options are 'violin' or 'boxplot' |
custom_colors |
named vector of colors to use to fill the violins/boxplots |
order |
if TRUE, order the groups by their mean value |
flip_coordinates |
flip coordinate system |
cap_top |
cap the values at a quantile or fixed value |
df |
data.frame containing the columns passed in feature_column and group_column |
feature_column |
string of the column with feature that should be quantified |
absolute_numbers |
if TRUE, plot absolute counts per category instead of relative fractions per group |
return_df |
if TRUE, instead of plotting, return the data.frame with the data |
text_size |
size of numbers in plots |
#plot as boxplot with additional mean, number of cells per group and cell sample (requires ggbeeswarm)
jj_plot_numeric_by_group(pbmc_small@meta.data, feature_column = 'nFeature_RNA', group_column = 'groups',
plot_mean = T, plot_cell_sample = T, type = 'boxplot')
#plot as violin with custom colours
jj_plot_numeric_by_group(pbmc_small@meta.data, feature_column = 'nFeature_RNA', group_column = 'groups',
custom_colors = c(g1='green', g2='blue'), type = 'violin')
jj_plot_numeric_by_group(pbmc_small@meta.data, feature_column = 'nFeature_RNA', group_column = 'groups',
show_annotation = c('n', 'mean', 'sd'), annotation_at = 100, type = 'violin')
#plot a sparse feature directly from Seurat
jj_plot_sparse_by_group_seurat(pbmc_small, 'CD79A', 'groups', assay='RNA', slot='data')
#or from a sparse matrix
sp_mat = GetAssayData(pbmc_small)
jj_plot_sparse_by_group(sp_mat, gene_plot = 'MS4A1', group_vec = pbmc_small$groups, order=T)
#barplot of fractions by group, eg fractions of cluster annotations per group
jj_plot_categorical_by_group(pbmc_small[[]], feature_column = 'RNA_snn_res.1', group_column = 'groups')
#or using absolute counts
jj_plot_categorical_by_group(pbmc_small[[]], feature_column = 'RNA_snn_res.1', group_column = 'groups', absolute_numbers = T)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.