densvis 1.6.1

Non-linear dimensionality reduction techniques such as t-SNE (Maaten and Hinton 2008)
and UMAP (McInnes, Healy, and Melville 2020) produce a low-dimensional embedding that summarises
the global structure of high-dimensional data. These techniques can be
particularly useful when visualising high-dimensional data in a biological
setting.
However, these embeddings may not accurately represent the local density
of data in the original space, resulting in misleading visualisations where
the space given to clusters of data does not represent the fraction of the
high dimensional space that they occupy.
`densvis`

implements the density-preserving objective function described by
(Narayan, Berger, and Cho 2020) which aims to address this deficiency by including a
density-preserving term in the t-SNE and UMAP optimisation procedures.
This can enable the creation of visualisations that accurately capture
differing degrees of transcriptional heterogeneity within different cell
subpopulations in scRNAseq experiments, for example.

We will illustrate the use of densvis
using simulated data.
We will first load the `densvis`

and `Rtsne`

libraries
and set a random seed to ensure the t-SNE visualisation is reproducible
(note: it is good practice to ensure that a t-SNE embedding is robust
by running the algorithm multiple times).

```
library("densvis")
library("Rtsne")
library("uwot")
library("ggplot2")
theme_set(theme_bw())
set.seed(14)
```

```
data <- data.frame(
x = c(rnorm(1000, 5), rnorm(1000, 0, 0.2)),
y = c(rnorm(1000, 5), rnorm(1000, 0, 0.2)),
class = c(rep("Class 1", 1000), rep("Class 2", 1000))
)
ggplot() +
aes(data[, 1], data[, 2], colour = data$class) +
geom_point(pch = 19) +
scale_colour_discrete(name = "Cluster") +
ggtitle("Original co-ordinates")
```