plot_composition_bar: Create barplot of average cell type composition

View source: R/plot_composition_bar.R

plot_composition_barR Documentation

Create barplot of average cell type composition

Description

Create barplot of average cell type composition

Usage

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
)

Arguments

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

Value

stacked barplot representing mean proportion of cell types for each group

Examples

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")


lahuuki/DeconvoBuddies documentation built on May 5, 2024, 9:35 a.m.