Interaction with the tidyverse and ggplot2

The tidyverse, ggplot2, and destiny are a great fit!

ggplot has a peculiar method to set default scales: You just have to define certain variables.

When working mainly with dimension reductions, I suggest to hide the (useless) ticks:

Let’s load our dataset

Of course you could use [tidyr](http://tidyr.tidyverse.org/)::[gather()](https://rdrr.io/cran/tidyr/man/gather.html) to tidy or transform the data now, but the data is already in the right form for destiny, and R for Data Science is a better resource for it than this vignette. The long form of a single cell ExpressionSet would look like:

But destiny doesn’t use long form data as input, since all single cell data has always a more compact structure of genes×cells, with a certain number of per-sample covariates (The structure of ExpressionSet).

names(dm) shows what names can be used in dm$<name>, as.data.frame(dm)$<name>, or ggplot(dm, aes(<name>)):

Due to the fortify method (which here just means as.data.frame) being defined on DiffusionMap objects, ggplot directly accepts DiffusionMap objects:

When you want to use a Diffusion Map in a dplyr pipeline, you need to call fortify/as.data.frame directly:

The Diffusion Components of a converted Diffusion Map, similar to the genes in the input ExpressionSet, are individual variables instead of two columns in a long-form data frame, but sometimes it can be useful to “tidy” them:

Another tip: To reduce overplotting, use sample_frac(., 1.0, replace = FALSE) (the default) in a pipeline.

Adding a constant alpha improves this even more, and also helps you see density: