## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  message = FALSE,
  warning = FALSE,
  rmarkdown.html_vignette.check_title = FALSE
)

## ----message=FALSE------------------------------------------------------------
# Load the packages
library(LongDat)
library(kableExtra)

## ----message=FALSE, tidy=TRUE, tidy.opts=list(width.cutoff=80)----------------
# Read in the data frame. LongDat_disc_master_table is already lazily loaded.
master <- LongDat_disc_master_table
master %>%
  kableExtra::kbl() %>%
  kableExtra::kable_paper(bootstrap_options = "responsive", font_size = 12) %>% 
  kableExtra::scroll_box(width = "700px", height = "200px")

## ----message=FALSE, tidy=TRUE, tidy.opts=list(width.cutoff=80)----------------
# Read in the data frame. LongDat_disc_metadata_table is already lazily loaded.
metadata <- LongDat_disc_metadata_table
metadata %>%
  kableExtra::kbl() %>%
  kableExtra::kable_paper(bootstrap_options = "responsive", font_size = 12) %>% 
  kableExtra::scroll_box(width = "700px", height = "200px")

## ----message=FALSE, tidy=TRUE, tidy.opts=list(width.cutoff=80)----------------
# Read in the data frame. LongDat_disc_feature_table is already lazily loaded.
feature <- LongDat_disc_feature_table
feature %>%
  kableExtra::kbl() %>%
  kableExtra::kable_paper(bootstrap_options = "responsive", font_size = 12) %>% 
  kableExtra::scroll_box(width = "700px", height = "200px")

## ----message=FALSE, tidy=TRUE, tidy.opts=list(width.cutoff=80)----------------
master_created <- make_master_table(
metadata_table = LongDat_disc_metadata_table,
feature_table = LongDat_disc_feature_table,
sample_ID = "Sample_ID",
individual = "Individual")

master_created %>%
  kableExtra::kbl() %>%
  kableExtra::kable_paper(bootstrap_options = "responsive", font_size = 12) %>% 
  kableExtra::scroll_box(width = "700px", height = "200px")

## ----message=FALSE, tidy=TRUE, tidy.opts=list(width.cutoff=80)----------------
# Run longdat_disc() on LongDat_disc_master_table
set.seed(100)
test_disc <- longdat_disc(input = LongDat_disc_master_table,
data_type = "count",
test_var = "Time_point",
variable_col = 7, 
fac_var = c(1:3))

## ----message=FALSE, tidy=TRUE, tidy.opts=list(width.cutoff=80)----------------
# The first dataframe in the list is the result table
result_table <- test_disc[[1]]
result_table %>%
  kableExtra::kbl() %>%
  kableExtra::kable_paper(bootstrap_options = "responsive", font_size = 12, position = "center") %>% 
  kableExtra::scroll_box(width = "700px")

## ----message=FALSE, tidy=TRUE, tidy.opts=list(width.cutoff=80)----------------
# The second dataframe in the list is the covariate table
covariate_table <- test_disc[[2]]
covariate_table %>%
  kableExtra::kbl() %>%
  kableExtra::kable_paper(bootstrap_options = "responsive", font_size = 12, position = "center") %>% 
  kableExtra::scroll_box(width = "700px")

## ----message=FALSE, tidy=TRUE, tidy.opts=list(width.cutoff=80)----------------
test_plot <- cuneiform_plot(result_table = test_disc[[1]],
                            x_axis_order = c("Effect_1_2", "Effect_2_3",                             "Effect_1_3"),
                            title_size = 15)

## ----fig.asp = 0.6, fig.width = 8, out.width = "80%", dpi = 600---------------
test_plot

