Skip to contents

Plotting function

Usage

# S3 method for class 'emuFit'
plot(
  x,
  plot_key = NULL,
  title = NULL,
  taxon_names = NULL,
  display_taxon_names = TRUE,
  data_only = FALSE,
  ...
)

Arguments

x

Output from emuFit()

plot_key

(Optional) Default NULL. List of named vectors containing names in the "covariate" column of the coef output of the radEmu model object. If you wish for multiple covariate values to be plotted on the same plot, then those variables should be included in the same named vector. By default, each column of the design matrix receives its own plot.

title

(Optional). Default NULL. Character string. The main title for the graphic.

taxon_names

(Optional). Default NULL. Data frame. If NULL, keep taxon names as listed in radEmu model. Otherwise, users can input a data frame with two columns: one labelled "category" with the same levels as in the radEmu output and another labelled "cat_small" with the preferred labels.

display_taxon_names

(Optional). Default TRUE. Boolean. If FALSE, remove sample names from the plot.

data_only

(Optional). Default FALSE. Boolean. If TRUE, only returns data frame.

...

There are no optional parameters at this time.

Value

Object of class ggplot. Plot of radEmu model fit with 95% confidence intervals.

Examples

data(wirbel_sample)
data(wirbel_otu)

subset_studies <- which(wirbel_sample$Study %in% c("FR-CRC", "US-CRC", "AT-CRC"))

chosen_genera <- c("Eubacterium", "Faecalibacterium", "Fusobacterium", "Porphyromonas")

mOTU_names <- colnames(wirbel_otu)
mOTU_name_df <- data.frame(name = mOTU_names) %>% 
  dplyr::mutate(base_name = stringr::str_remove(mOTU_names, "unknown ") %>%
  stringr::str_remove("uncultured ")) %>%
  dplyr::mutate(genus_name = stringr::word(base_name, 1))

restricted_mOTU_names <- mOTU_name_df %>%
  dplyr::filter(genus_name %in% chosen_genera) %>%
  dplyr::pull(name)

small_Y <- wirbel_otu[subset_studies, restricted_mOTU_names]
category_to_rm <- which(colSums(small_Y) == 0)

small_sample <- wirbel_sample[subset_studies, ]

ch_fit <- emuFit(formula = ~ Group + Study, 
                 data = small_sample,
                 Y = small_Y,
                 run_score_tests = FALSE)

plot_key <- list(p1 = c("Control" = "GroupCTR"),
                 p2 = c("FR-Control" = "StudyFR-CRC",
                        "US-Control" = "StudyUS-CRC"))

out <- plot(x = ch_fit,
            plot_key = plot_key,
            display_taxon_names = FALSE)

out$plots$p1

out$plots$p2