Skip to content

Commit

Permalink
update html tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
scottgigante committed Jul 12, 2018
1 parent af8f31d commit be5c9f1
Show file tree
Hide file tree
Showing 30 changed files with 3,582 additions and 564 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ After installing the package, MAGIC can be run by loading the library and callin

#### Tutorials

For a working example, see the Rmarkdown tutorials at https://github.com/KrishnaswamyLab/MAGIC/blob/master/Rmagic/inst/examples/bonemarrow_tutorial.md and https://github.com/KrishnaswamyLab/MAGIC/blob/master/Rmagic/inst/examples/EMT_tutorial.md or in `R/inst/examples`.
For a working example, see the Rmarkdown tutorials at <http://htmlpreview.github.io/?https://github.com/KrishnaswamyLab/MAGIC/blob/master/Rmagic/inst/examples/bonemarrow_tutorial.html> and <http://htmlpreview.github.io/?https://github.com/KrishnaswamyLab/MAGIC/blob/master/Rmagic/inst/examples/EMT_tutorial.hmtl> or in `Rmagic/inst/examples`.

## Help

Expand Down
4 changes: 2 additions & 2 deletions Rmagic/README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ Markov Affinity-based Graph Imputation of Cells (MAGIC) is an algorithm for deno
* MAGIC can be performed on a variety of datasets
* Here, we show the usage of MAGIC on a toy dataset
* You can view further examples of MAGIC on real data in our notebooks under `inst/examples`:
* https://github.com/KrishnaswamyLab/MAGIC/blob/master/Rmagic/inst/examples/EMT_tutorial.md
* https://github.com/KrishnaswamyLab/MAGIC/blob/master/Rmagic/inst/examples/bonemarrow_tutorial.md
* http://htmlpreview.github.io/?https://github.com/KrishnaswamyLab/MAGIC/blob/master/Rmagic/inst/examples/EMT_tutorial.html
* http://htmlpreview.github.io/?https://github.com/KrishnaswamyLab/MAGIC/blob/master/Rmagic/inst/examples/bonemarrow_tutorial.html

### Installation

Expand Down
4 changes: 2 additions & 2 deletions Rmagic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ Diffusion*, Cell
- You can view further examples of MAGIC on real data in our notebooks
under
`inst/examples`:
- <https://github.com/KrishnaswamyLab/MAGIC/blob/master/Rmagic/inst/examples/EMT_tutorial.md>
- <https://github.com/KrishnaswamyLab/MAGIC/blob/master/Rmagic/inst/examples/bonemarrow_tutorial.md>
- <http://htmlpreview.github.io/?https://github.com/KrishnaswamyLab/MAGIC/blob/master/Rmagic/inst/examples/EMT_tutorial.html>
- <http://htmlpreview.github.io/?https://github.com/KrishnaswamyLab/MAGIC/blob/master/Rmagic/inst/examples/bonemarrow_tutorial.html>

### Installation

Expand Down
Binary file modified Rmagic/inst/examples/BMMSC_data_R_after_magic.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Rmagic/inst/examples/BMMSC_data_R_pca_colored_by_magic.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Rmagic/inst/examples/BMMSC_data_R_phate_colored_by_magic.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Rmagic/inst/examples/EMT_data_R_after_magic.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Rmagic/inst/examples/EMT_data_R_pca_colored_by_magic.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 17 additions & 10 deletions Rmagic/inst/examples/bonemarrow_tutorial.Rmd
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
---
title: "Rmagic Bone Marrow Tutorial"
output:
github_document: default
toc: true
html_document:
df_print: paged
toc: yes
toc_depth: '3'
---

<!-- README.md is generated from README.Rmd. Please edit that file -->
<!-- bonemarrow_tutorial.md is generated from bonemarrow_tutorial.Rmd. Please edit that file -->

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
Expand Down Expand Up @@ -66,7 +68,7 @@ library(phateR)

### Loading data

In this tutorial, we will analyse myeloid and erythroid cells in mouse bone marrow, as described in Paul et al., 2015. The example data is located in the PHATE Github repository and we can load it directly from the web.
In this tutorial, we will analyse myeloid and erythroid cells in mouse bone marrow, as described in Paul et al., 2015. The example data is located in the PHATE Github repository and we can load it directly from the web. You can run this tutorial with your own data by downloading <https://raw.githubusercontent.com/KrishnaswamyLab/MAGIC/master/Rmagic/inst/examples/bonemarrow_tutorial.Rmd> and opening it in RStudio.

```{r load_data}
# load data
Expand All @@ -75,6 +77,8 @@ bmmsc <- bmmsc[,2:ncol(bmmsc)]
bmmsc[1:5,1:10]
```

### Filtering data

First, we need to remove lowly expressed genes and cells with small library size.

```{r}
Expand All @@ -93,6 +97,7 @@ keep_rows <- rowSums(bmmsc) > 1000
bmmsc <- bmmsc[keep_rows,]
```

### Normalizing data

We should library size normalize and transform the data prior to MAGIC. Many people use a log transform, which requires adding a "pseudocount" to avoid log(0). We square root instead, which has a similar form but doesn't suffer from instabilities at zero.

Expand All @@ -114,29 +119,31 @@ We can plot the data before and after MAGIC to visualize the results.

```{r plot_raw}
ggplot(bmmsc) +
geom_point(aes(Mpo, Klf1, colour=Ifitm1)) +
scale_colour_viridis(option="B")
geom_point(aes(Mpo, Klf1, color=Ifitm1)) +
scale_color_viridis(option="B")
ggsave('BMMSC_data_R_before_magic.png', width=5, height=5)
```

The data suffers from dropout to the point that we cannot infer anything about the gene-gene relationships.

```{r plot_magic}
ggplot(bmmsc_MAGIC) +
geom_point(aes(Mpo, Klf1, colour=Ifitm1)) +
scale_colour_viridis(option="B")
geom_point(aes(Mpo, Klf1, color=Ifitm1)) +
scale_color_viridis(option="B")
```

As you can see, the gene-gene relationships are much clearer after MAGIC. These relationships also match the biological progression we expect to see - Ifitm1 is a stem cell marker, Klf1 is an erythroid marker, and Mpo is a myeloid marker.

### Rerunning MAGIC with new parameters

The data is a little too smooth - we can decrease `t` from the automatic value to reduce the amount of diffusion. We pass the original result to the argument `init` to avoid recomputing intermediate steps.

```{r decrease_t}
bmmsc_MAGIC <- magic(bmmsc, genes=c("Mpo", "Klf1", "Ifitm1"),
t=4, init=bmmsc_MAGIC)
ggplot(bmmsc_MAGIC) +
geom_point(aes(Mpo, Klf1, colour=Ifitm1)) +
scale_colour_viridis(option="B")
geom_point(aes(Mpo, Klf1, color=Ifitm1)) +
scale_color_viridis(option="B")
ggsave('BMMSC_data_R_after_magic.png', width=5, height=5)
```

Expand Down
1,783 changes: 1,783 additions & 0 deletions Rmagic/inst/examples/bonemarrow_tutorial.html

Large diffs are not rendered by default.

287 changes: 0 additions & 287 deletions Rmagic/inst/examples/bonemarrow_tutorial.md

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit be5c9f1

Please sign in to comment.