View source: R/plot_composition_bar.R
plot_composition_bar | R Documentation |
Create barplot of average cell type composition
plot_composition_bar(
prop_long,
sample_col = "RNum",
x_col = "ALL",
prop_col = "prop",
ct_col = "cell_type",
add_text = TRUE,
min_prop_text = 0
)
prop_long |
data.frame of cell type portions in long form |
sample_col |
name of column that identifies samples |
x_col |
category to divide samples by |
prop_col |
name of column containing proportion values |
ct_col |
name of column containing cell type names |
add_text |
Add rounded proportion value to bars |
min_prop_text |
Minimum proportion to display text |
stacked barplot representing mean proportion of cell types for each group
pd <- SummarizedExperiment::colData(rse_bulk_test) |>
as.data.frame()
est_prop_long <- est_prop |>
tibble::rownames_to_column("RNum") |>
tidyr::pivot_longer(!RNum, names_to = "cell_type", values_to = "prop") |>
dplyr::inner_join(pd |> dplyr::select(RNum, Dx)) ## TODO fix example data
plot_composition_bar(est_prop_long)
plot_composition_bar(est_prop_long, x_col = "Dx")
plot_composition_bar(est_prop_long, x_col = "Dx", min_prop_text = 0.1)
plot_composition_bar(est_prop_long, x_col = "RNum", add_text = FALSE) + ggplot2::facet_wrap(~Dx, scales="free_x")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.