---
title: "Using msaR"
author: "Zach Charlop-Powers"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Using msaR}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---


```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, message=FALSE)
```



## Basic Usage

msaR is a an [htmlwidgets](https://github.com/ramnathv/htmlwidgets) wrapper of the [BioJS MSA viewer](https://github.com/wilzbach/msa) javascript library. msa will pass alignments to the BioJS MSA. 


```{r}
library(msaR)

# read some sequences from a Multiple sequence alignment file.
seqfile <- system.file("sequences","AHBA.aln", package="msaR")

# display the MSA.
msaR(seqfile, menu=F, overviewbox = F)
```


## Customized MSAs

```{r}
msaR(seqfile, menu=F, overviewbox = F)
```



## Protein MSA

```{r}

# read some sequences from a Multiple sequence alignment file.
proteinseqfile <- system.file("sequences","phosphoproteins.aln", package="msaR")

# loading AA with ape. Can also use Biostrings
proteins <- ape::read.FASTA(proteinseqfile, type="AA")
                            
# note the seqlogo will show up in your widget but 
# not the vignette static output
msaR(proteins, menu=F, overviewbox = F,  colorscheme = "clustal")

```



## Use as a Shiny widget

msaR can be used as a widget with the [Shiny](https://shiny.rstudio.com/) web application framework.

In ui.R
```{r, eval=FALSE}
msaROutput("msa", width="100%")
```

In server.R
```{r, eval=FALSE}
output$msa <- renderMsaR(
  msaR(seqfile)
)
```



