-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
130 lines (99 loc) · 4.2 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup1, include=FALSE}
knitr::opts_chunk$set(fig.path=".readme_files/", warning=FALSE, message=FALSE, error=FALSE, echo = TRUE)
```
<a href="https://travis-ci.org/dynverse/dynplot"><img src="https://travis-ci.org/dynverse/dynplot.svg" align="left"></a> <a href="https://codecov.io/gh/dynverse/dynplot"> <img src="https://codecov.io/gh/dynverse/dynplot/branch/master/graph/badge.svg" align="left" /></a> [**ℹ️ Tutorials**](https://dynverse.org) [**ℹ️ Reference documentation**](https://dynverse.org/reference/dynplot) <br><img src="man/figures/logo.png" align="right" />
# Common visualisation tools for single-cell trajectories
## Installation
```r
devtools::install_github("dynverse/dynplot")
```
On linux, udunits2 has to be installed:
* Debian / Ubuntu / Linux mint: `sudo apt-get install libudunits2-dev`
* Fedora / CentOS: `sudo dnf install udunits2-devel`
## Usage
The package provides different ways to plot both the topology and cellular properties of a trajectory:
```{r, echo=FALSE}
library(dplyr)
library(dynplot)
library(dynutils)
library(dynwrap)
library(tidyverse)
library(patchwork)
data(example_bifurcating)
trajectory <- example_bifurcating
trajectory <- trajectory %>% add_root()
grouping <- trajectory$prior_information$groups_id
groups <- tibble(dynwrap::group_onto_nearest_milestones(trajectory)) %>%
mutate(color=dynplot:::milestone_palette_list$auto(n()))
features_oi <- apply(as.matrix(trajectory$counts), 2, sd) %>% sort() %>% names() %>% tail(10)
feature_oi <- features_oi[[10]]
```
```{r cells, fig.width=15, fig.height=10, echo=FALSE}
empty <- ggplot() + theme_void()
question <- empty + geom_text(aes(0, 0, label="????"))
unavailable <- empty + geom_text(aes(0, 0, label="----"))
title <- list(
dynplot:::empty_plot(),
# empty + geom_label(aes(0, 0, label="Topology")),
empty + geom_label(aes(0, 0, label="Ordering")),
empty + geom_label(aes(0, 0, label="Grouping/clustering")),
empty + geom_label(aes(0, 0, label="Expression of \n a single gene")),
empty + geom_label(aes(0, 0, label="Pseudotime"))
)
dendro <- list(
empty + geom_label(aes(0, 0, label="Dendrogram")),
# plot_dendro(trajectory),
plot_dendro(trajectory, "milestone"),
plot_dendro(trajectory, grouping=grouping, groups=groups),
plot_dendro(trajectory, feature_oi=feature_oi),
plot_dendro(trajectory, "pseudotime")
)
onedim <- list(
empty + geom_label(aes(0, 0, label="Onedim")),
# plot_onedim(trajectory),
plot_onedim(trajectory, "milestone"),
plot_onedim(trajectory, grouping=grouping, groups=groups),
plot_onedim(trajectory, feature_oi=feature_oi),
plot_onedim(trajectory, "pseudotime")
)
graph <- list(
empty + geom_label(aes(0, 0, label="Graph")),
# plot_graph(trajectory),
plot_graph(trajectory, "milestone"),
plot_graph(trajectory, grouping=grouping, groups=groups),
plot_graph(trajectory, feature_oi=feature_oi),
plot_graph(trajectory, "pseudotime")
)
dimred <- list(
empty + geom_label(aes(0, 0, label="Dimensionality reduction")),
# plot_dimred(trajectory),
plot_dimred(trajectory, "milestone"),
plot_dimred(trajectory, grouping=grouping, groups=groups),
plot_dimred(trajectory, feature_oi=feature_oi),
plot_dimred(trajectory, "pseudotime")
)
wrap_plots(
c(title, dendro, onedim, graph, dimred),
nrow=5,
byrow=TRUE
) & theme(legend.position = "none")
```
And to plot the expression and feature importances of many genes along the trajectory
```{r heatmap, echo=FALSE, fig.width=10, fig.height=6}
cell_feature_importance <- dynfeature::calculate_cell_feature_importance(trajectory %>% dynwrap::add_waypoints())
plot_heatmap(trajectory, grouping = trajectory$prior_information$grouping_assignment)
```
## Latest changes
Check out `news(package = "dynwrap")` or [NEWS.md](inst/NEWS.md) for a full list of changes.
<!-- This section gets automatically generated from inst/NEWS.md, and also generates inst/NEWS -->
```{r news, echo=FALSE, results="asis"}
dynutils::update_news()
cat(dynutils::recent_news())
```
## Dynverse dependencies
<!-- Generated by "update_dependency_graphs.R" in the main dynverse repo -->
![](man/figures/dependencies.png)