---
title: "Introduction"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Introduction}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---


```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  message = FALSE
)
```

# Introduction to MiscMetabar: an R package to facilitate visualization and reproducibility in metabarcoding analysis

## Raison d'être

- Complete R packages dada2 and phyloseq
- Useful visualizations (`biplot_pq`, `circle_pq`, `upset_pq`, `ggvenn_pq`) 
- Facilitate the use of targets package

## Quick overview

For an introduction to metabarcoding in R, Please visite the [state of the field](https://adrientaudiere.github.io/MiscMetabar/articles/states_of_fields_in_R.html) vignettes. The [import, export and track](https://adrientaudiere.github.io/MiscMetabar/articles/import_export_track.html) vignette explains how import and export `phyloseq` object. Its also show how to summarize useful information (number of sequences, samples and clusters) accross bioinformatic pipelines. 
 
If you are interested in ecological metrics, see the vignettes describing [alpha-diversity](https://adrientaudiere.github.io/MiscMetabar/articles/alpha-div.html) and [beta-diversity](https://adrientaudiere.github.io/MiscMetabar/articles/beta-div.html) analysis. 
The vignette [filter taxa and samples](https://adrientaudiere.github.io/MiscMetabar/articles/filter.html) describes some data-filtering processes using MiscMetabar and the [reclustering](https://adrientaudiere.github.io/MiscMetabar/articles/Reclustering.html) tutorial introduces the different way of clustering already-clustered OTU/ASV. The vignette [tengeler](https://adrientaudiere.github.io/MiscMetabar/articles/tengeler.html) explore the dataset from Tengeler et al. (2020) using some MiscMetabar functions.

For developers, I also wrote a vignette describing som [rules of codes](https://adrientaudiere.github.io/MiscMetabar/articles/Rules.html). 

### Summarize a physeq object

```{r example}
library("MiscMetabar")
library("phyloseq")
library("magrittr")
data("data_fungi")
summary_plot_pq(data_fungi)
```


### Create an interactive table of the tax_table

```{r results="asis"}
data("GlobalPatterns", package = "phyloseq")
tax_datatable(subset_taxa(
  GlobalPatterns,
  rowSums(GlobalPatterns@otu_table) > 100000
))
```

### Sankey diagram of the tax_table

```{r}
gp <- subset_taxa(GlobalPatterns, GlobalPatterns@tax_table[, 1] == "Archaea")
sankey_pq(gp, taxa = c(1:5))
```


### Upset plot for visualize distribution of taxa in function of samples variables

```{r}
upset_pq(gp, "SampleType", taxa = "Class")
```


# References

Tengeler, A.C., Dam, S.A., Wiesmann, M. et al. Gut microbiota from persons with attention-deficit/hyperactivity disorder affects the brain in mice. Microbiome 8, 44 (2020). <https://doi.org/10.1186/s40168-020-00816-x>


# Session inform

```{r}
sessionInfo()
```
