---
title: "VeloViz Vignette"
author: "Lyla Atta"
output: rmarkdown::html_document
vignette: >
  %\VignetteIndexEntry{Visualizing cell cycle trajectory in MERFISH data using VeloViz}
  %\VignetteEncoding{UTF-8}
  %\VignetteEngine{knitr::rmarkdown}
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, results = 'hide')
library(veloviz)
```

# Installation

```{r, eval = FALSE}
if(!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
BiocManager::install("veloviz")

```

# Introduction

VeloViz creates RNA-velocity-informed 2D embeddings for single cell transcriptomics data. Inputs to VeloViz are the current and projected transcriptional states, which are obtained from RNA velocity analysis (e.g. using velocyto.R or scVelo).


We start by extracting the current and projected transcriptional states from the output of velocyto.R. An example velocity output is provided with VeloViz for illustration purposes.  

```{r}
data(vel)

curr <- vel$current #observed current transcriptional state
proj <- vel$projected #predicted future transcriptional state

```

Now we can build the VeloViz graph using the current and projected transcriptional states using the VeloViz function `buildVeloviz`. User inputted parameters are explained at https://jef.works/veloviz/.
```{r}
veloviz <-  veloviz::buildVeloviz(curr = curr, proj = proj,
                         normalize.depth = TRUE,
                         use.ods.genes = FALSE,  
                         pca = TRUE, nPCs = 3,
                         center = TRUE, scale = TRUE,
                         k = 10, similarity.threshold = -1,
                         distance.weight = 1, distance.threshold = 1,
                         weighted = TRUE, verbose = FALSE)
```

From the VeloViz object, we can extract the 2D embedding coordinates for plotting.
```{r}
emb.veloviz <- veloviz$fdg_coords
plot(emb.veloviz)
```

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