## ----message=FALSE, warning=FALSE---------------------------------------------
library(ClassifyITS)

# Paths to example BLAST and FASTA files in the package (replace with your own paths)
blast_path <- system.file("extdata", "example_BLAST.tsv", package = "ClassifyITS")
fasta_path <- system.file("extdata", "example_FASTA.fasta", package = "ClassifyITS")

# Run the assignment pipeline (no files are written by default)
results <- ITS_assignment(
  blast_file = blast_path,
  rep_fasta  = fasta_path
)

## ----message=FALSE, warning=FALSE---------------------------------------------
outdir <- file.path(tempdir(), "ClassifyITS_outputs")
dir.create(outdir, showWarnings = FALSE)

results_written <- ITS_assignment(
  blast_file = blast_path,
  rep_fasta  = fasta_path,
  outdir     = outdir,
  verbose    = TRUE
)

results_written$assignments_file
results_written$pdf_file


## ----echo=FALSE---------------------------------------------------------------
# Create alignment histogram from pipeline outputs
hist_plot <- plot_alignment_hist(results$blast_filtered, results$rep_seqs)

# Build summary plots/tables in-memory (no PDF written by default)
graphics <- save_taxonomy_graphics(
  all_results = results$all_results,
  hist_plot   = hist_plot
)

## ----histplot, fig.width=10, fig.height=6, echo=FALSE-------------------------
# Alignment length histogram
print(graphics$hist_plot)

## ----assignment_bar_plot, fig.width=10, fig.height=6, echo=FALSE--------------
# Assignment bar chart
print(graphics$assignment_bar_plot)

## ----phylum_plot, fig.width=4, fig.height=8, echo=FALSE-----------------------

# Phylum stacked bar chart
print(graphics$phylum_plot)

## ----echo=FALSE---------------------------------------------------------------
knitr::kable(utils::head(graphics$step_table))

## ----echo=FALSE---------------------------------------------------------------
knitr::kable(graphics$final_count_tbl)

## ----message=FALSE, warning=FALSE---------------------------------------------
pdf_file <- file.path(tempdir(), "combined_taxonomy_graphics.pdf")

graphics_pdf <- save_taxonomy_graphics(
  all_results = results$all_results,
  hist_plot   = hist_plot,
  pdf_file    = pdf_file,
  verbose     = TRUE
)

graphics_pdf$pdf_file

## ----echo=FALSE---------------------------------------------------------------
# Show the first 10 rows as a preview in the vignette
knitr::kable(utils::head(results$all_results, 10))

# View the full assignments table interactively (in RStudio)
# Uncomment the following line to use View in your own R session!
# View(results$all_results)

