Skip to content

Commit

Permalink
upload
Browse files Browse the repository at this point in the history
  • Loading branch information
multitalk committed Apr 6, 2022
1 parent b441a3a commit 1623100
Show file tree
Hide file tree
Showing 9 changed files with 542 additions and 81 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ Imports:
pheatmap,
corrplot,
circlize,
ggalluvial,
ggraph,
ggrepel,
igraph
Expand Down
4 changes: 2 additions & 2 deletions R/demo.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ demo_pathways <- function() {
dest <- c("CDK2", "CDK4", "TP53", "Atf2")
pathway <- c("p53 signaling pathway", "p53 signaling pathway", "p53 signaling pathway",
"PI3K-Akt signaling pathway")
sourcename <- c("Process(activation)", "Process(activation)", "Process(binding)",
type <- c("Process(activation)", "Process(activation)", "Process(binding)",
"Process(association)")
type <- rep("KEGG", 4)
sourcename <- rep("KEGG", 4)
src_tf <- c("NO", "NO", "NO", "NO")
dest_tf <- c("NO", "NO", "YES", "YES")
species <- c("Human", "Human", "Human", "Mouse")
Expand Down
1 change: 0 additions & 1 deletion R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ plot_st_celltype_all <- function(object, size = 1, color = NULL) {
#' @param color_low Color for the lowest value.
#' @param color_mid Color for the middle value for using \code{scale_color_gradient2}. Default is \code{NULL}.
#' @param color_high Color for the highest value.
#' @param if_use_newmeta Whether to use newmeta o plot the spatial distribution of gene after \code{\link{dec_celltype}} for spot-based data. Default is \code{FALSE}.
#' @param scale Character indicating if the values should be centered and scaled in either the row direction or the column direction, or none. Corresponding values are 'row', 'column' and 'none'.
#' @param if_show_top Whether to plot a symbol to the highest value across rows or columns. Default is \code{TRUE}.
#' @param top_direction Direction to identify the highest value, select \code{'row'} or \code{'column'}.
Expand Down
1 change: 1 addition & 0 deletions inst/CITATION
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ citEntry(
as.person("Xiao Xu"),
as.person("Xiaohui Fan")
),
journal = "Under submission",
year = "2022",
textVersion = paste("Shao et al. Knowledge-graph-based cell-cell communication inference for spatially resolved transcriptomic data with SpaTalk. 2022."
)
Expand Down
2 changes: 0 additions & 2 deletions man/plot_st_cor_heatmap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 26 additions & 21 deletions vignettes/sc_tutorial.Rmd
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
title: "SpaTalk tutorial (spot-based ST data)"
title: "SpaTalk tutorial (single-cell ST data)"
author: "Xin Shao"
date: "`r Sys.Date()`"
output:
prettydoc::html_pretty:
theme: cayman
highlight: github
vignette: >
%\VignetteIndexEntry{SpaTalk tutorial (spot-based ST data)}
%\VignetteIndexEntry{SpaTalk tutorial (single-cell ST data)}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
Expand Down Expand Up @@ -46,23 +46,23 @@ obj <- dec_celltype(object = obj,

### Use `plot_st_celltype_percent()` to view cell-type percent

```{r plot_st_celltype_percent, fig.width=6, fig.height=6, fig.align='center', echo=TRUE}
```{r plot_st_celltype_percent, fig.width=5, fig.height=6, fig.align='center', echo=TRUE}
# plot cell-type percent across spatial cells
plot_st_celltype_percent(object = obj, celltype = 'eL2_3',size = 3)
plot_st_celltype_percent(object = obj, celltype = 'Oligo',size = 2)
```

### Use `plot_st_gene()` to view gene expression

```{r plot_st_gene, fig.width=6, fig.height=6, fig.align='center', echo=TRUE}
```{r plot_st_gene, fig.width=5, fig.height=6, fig.align='center', echo=TRUE}
# plot marker gene expression across spatial cells
plot_st_gene(object = obj, gene = 'Lamp5',size = 3, if_use_newmeta = F)
plot_st_gene(object = obj, gene = 'Plp1',size = 2, if_use_newmeta = F)
```

### Use `plot_st_cor_heatmap()` to view correlation heatmap

```{r plot_st_cor_heatmap, fig.width=7, fig.height=6, fig.align='center', echo=TRUE}
```{r plot_st_cor_heatmap, fig.width=4, fig.height=3, fig.align='center', echo=TRUE}
# correlation between marker gene expression and cell type percent across spatial cells
plot_st_cor_heatmap(object = obj,
marker_genes = c("Plp1","Vip","Sst","Lamp5","Pcp4","Mfge8","Pvalb"),
Expand All @@ -76,42 +76,42 @@ plot_st_cor_heatmap(object = obj,
## **ST at single-cell resolution**
### Use `plot_st_celltype()` to view cell type in space

```{r plot_st_celltype, fig.width=6, fig.height=6, fig.align='center', echo=TRUE}
```{r plot_st_celltype, fig.width=5, fig.height=6, fig.align='center', echo=TRUE}
# plot cell type in reconstructed ST atlas
plot_st_celltype(object = obj, celltype = 'eL2_3')
plot_st_celltype(object = obj, celltype = 'Oligo', size = 2)
```

### Use `plot_st_gene()` to view gene expression in space

```{r plot_st_gene2, fig.width=6, fig.height=6, fig.align='center', echo=TRUE}
```{r plot_st_gene2, fig.width=5, fig.height=6, fig.align='center', echo=TRUE}
# plot marker gene expression in single-cell ST data
plot_st_gene(object = obj,gene = 'Lamp5', if_use_newmeta = T)
plot_st_gene(object = obj,gene = 'Plp1', if_use_newmeta = T, size = 2)
```

### Use `plot_st_celltype_density()` to view cell-type density in space

```{r plot_st_celltype_density, fig.width=6, fig.height=6, fig.align='center', echo=TRUE}
```{r plot_st_celltype_density, fig.width=5, fig.height=6, fig.align='center', echo=TRUE}
# plot cell-type density in single-cell ST data
plot_st_celltype_density(object = obj,
celltype = 'eL2_3',
celltype = 'Oligo',
type = 'raster',
color_low = 'purple',
color_high = 'yellow')
plot_st_celltype_density(object = obj,
celltype = 'eL2_3',
celltype = 'Oligo',
type = 'contour',
color_low = 'purple',
color_high = 'yellow')
```

### Use `plot_st_celltype_all()` to view all cell types in space

```{r plot_st_celltype_all, fig.width=6, fig.height=6, fig.align='center', echo=TRUE}
```{r plot_st_celltype_all, fig.width=5, fig.height=6, fig.align='center', echo=TRUE}
# plot all cell types in single-cell ST data
plot_st_celltype_all(object = obj,size = 2)
plot_st_celltype_all(object = obj, size = 2)
```

Expand Down Expand Up @@ -143,7 +143,11 @@ obj_lr_path$path_pvalue

```{r plot_ccdist, fig.width=6, fig.height=6, fig.align='center', echo=TRUE}
# Point plot with spatial distribution of celltype_sender and celltype_receiver
plot_ccdist(object = obj, celltype_sender = 'eL5', celltype_receiver = 'Astro')
plot_ccdist(object = obj,
celltype_sender = 'eL5',
celltype_receiver = 'Astro',
size = 2,
arrow_length = 0.1)
```

Expand All @@ -157,14 +161,16 @@ plot_cci_lrpairs(object = obj, celltype_sender = 'eL5', celltype_receiver = 'Ast

### Use `plot_lrpair()` to view the specific LRI

```{r plot_lrpair, fig.width=6, fig.height=6, fig.align='center', echo=TRUE}
```{r plot_lrpair, fig.width=5, fig.height=6, fig.align='center', echo=TRUE}
# Point plot with LR pair from celltype_sender to celltype_receiver
plot_lrpair(object = obj,
celltype_sender = 'eL5',
ligand = 'Cort',
celltype_receiver = 'Astro',
receptor = 'Sstr2',
if_plot_density = F)
if_plot_density = F,
size = 2,
arrow_length = 0.1)
```

Expand Down Expand Up @@ -196,7 +202,6 @@ plot_lr_path(object = obj,

```{r plot_path2gene, fig.width=8, fig.height=6, fig.align='center', echo=TRUE}
# River plot of significantly activated pathways and related downstream genes of receptors
library(ggalluvial)
plot_path2gene(object = obj,
celltype_sender = 'eL5',
ligand = 'Cort',
Expand All @@ -210,7 +215,7 @@ plot_path2gene(object = obj,
To infer all paired cell-cell communications, use `dec_cci_all()` instead of `dec_cci()`

```{r dec_cci_all, echo=TRUE}
# Infer cell-cell communications from SST to PVALB neurons
# Infer all cell-cell communications
# obj <- dec_cci_all(object = obj)
```

Expand Down
67 changes: 35 additions & 32 deletions vignettes/sc_tutorial.html

Large diffs are not rendered by default.

50 changes: 28 additions & 22 deletions vignettes/spot_tutorial.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ obj <- createSpaTalk(st_data = as.matrix(st_data),

### Use `plot_st_pie_generate()` to view the cell-type composition

```{r plot_st_pie_generate, echo=TRUE}
```{r plot_st_pie_generate, fig.width=5, fig.height=6, fig.align='center', echo=TRUE}
plot_st_pie_generate(st_meta = st_meta, pie_scale = 1.3, xy_ratio = 1.8)
```
Expand All @@ -65,31 +65,31 @@ obj <- dec_celltype(object = obj,

### Use `plot_st_pie()` to view predicted cell-type composition

```{r plot_st_pie, echo=TRUE}
```{r plot_st_pie, fig.width=5, fig.height=6, fig.align='center', echo=TRUE}
# Scatter pie plot for each spot
plot_st_pie(object = obj, pie_scale = 1.3, xy_ratio = 1.8)
```

### Use `plot_st_celltype_percent()` to view cell-type percent

```{r plot_st_celltype_percent, echo=TRUE}
```{r plot_st_celltype_percent, fig.width=5, fig.height=6, fig.align='center', echo=TRUE}
# plot cell-type percent across spatial spots
plot_st_celltype_percent(object = obj, celltype = 'Oligo',size = 3)
plot_st_celltype_percent(object = obj, celltype = 'Oligo',size = 4)
```

### Use `plot_st_gene()` to view gene expression

```{r plot_st_gene, echo=TRUE}
```{r plot_st_gene, fig.width=5, fig.height=6, fig.align='center', echo=TRUE}
# plot marker gene expression across spatial spots
plot_st_gene(object = obj, gene = 'Plp1',size = 3, if_use_newmeta = F)
plot_st_gene(object = obj, gene = 'Plp1',size = 4, if_use_newmeta = F)
```

### Use `plot_st_cor_heatmap()` to view correlation heatmap

```{r plot_st_cor_heatmap, echo=TRUE}
```{r plot_st_cor_heatmap, fig.width=4, fig.height=3, fig.align='center', echo=TRUE}
# correlation between marker gene expression and cell type percent across spatial spots
plot_st_cor_heatmap(object = obj,
marker_genes = c("Plp1","Vip","Sst","Lamp5","Pcp4","Mfge8","Pvalb"),
Expand All @@ -103,23 +103,23 @@ plot_st_cor_heatmap(object = obj,
## **ST at single-cell resolution**
### Use `plot_st_celltype()` to view cell type in space

```{r plot_st_celltype, echo=TRUE}
```{r plot_st_celltype, fig.width=5, fig.height=6, fig.align='center', echo=TRUE}
# plot cell type in reconstructed ST atlas
plot_st_celltype(object = obj, celltype = 'Oligo')
plot_st_celltype(object = obj, celltype = 'Oligo', size = 2)
```

### Use `plot_st_gene()` to view gene expression in space

```{r plot_st_gene2, echo=TRUE}
```{r plot_st_gene2, fig.width=5, fig.height=6, fig.align='center', echo=TRUE}
# plot marker gene expression in reconstructed ST atlas
plot_st_gene(object = obj,gene = 'Plp1', if_use_newmeta = T)
plot_st_gene(object = obj,gene = 'Plp1', if_use_newmeta = T, size = 2)
```

### Use `plot_st_celltype_density()` to view cell-type density in space

```{r plot_st_celltype_density, echo=TRUE}
```{r plot_st_celltype_density, fig.width=5, fig.height=6, fig.align='center', echo=TRUE}
# plot cell-type density in reconstructed ST atlas
plot_st_celltype_density(object = obj,
celltype = 'Oligo',
Expand All @@ -136,9 +136,9 @@ plot_st_celltype_density(object = obj,

### Use `plot_st_celltype_all()` to view all cell types in space

```{r plot_st_celltype_all, echo=TRUE}
```{r plot_st_celltype_all, fig.width=5, fig.height=6, fig.align='center', echo=TRUE}
# plot all cell types in reconstructed ST atlas
plot_st_celltype_all(object = obj)
plot_st_celltype_all(object = obj, size = 2)
```

Expand Down Expand Up @@ -167,9 +167,13 @@ obj_lr_path$path_pvalue

### Use `plot_ccdist()` to view distribution of senders and receivers

```{r plot_ccdist, echo=TRUE}
```{r plot_ccdist, fig.width=6, fig.height=6, fig.align='center', echo=TRUE}
# Point plot with spatial distribution of celltype_sender and celltype_receiver
plot_ccdist(object = obj, celltype_sender = 'SST', celltype_receiver = 'PVALB')
plot_ccdist(object = obj,
celltype_sender = 'SST',
celltype_receiver = 'PVALB',
size = 2,
arrow_length = 0.1)
```

Expand All @@ -185,20 +189,22 @@ Given the limited LR pairs, we do not show the result here

### Use `plot_lrpair()` to view the specific LRI

```{r plot_lrpair, echo=TRUE}
```{r plot_lrpair, fig.width=5, fig.height=6, fig.align='center', echo=TRUE}
# Point plot with LR pair from celltype_sender to celltype_receiver
plot_lrpair(object = obj,
celltype_sender = 'SST',
ligand = 'Sst',
celltype_receiver = 'PVALB',
receptor = 'Sstr2',
if_plot_density = F)
if_plot_density = F,
size = 2,
arrow_length = 0.1)
```

### Use `plot_lrpair_vln()` to view violin plot with spatial distance of LRI

```{r plot_lrpair_vln, echo=TRUE}
```{r plot_lrpair_vln, fig.width=8, fig.height=6, fig.align='center', echo=TRUE}
# Violin plot with spatial distance of LR pair between senders and receivers and between all cell-cell pairs
plot_lrpair_vln(object = obj,
celltype_sender = 'SST',
Expand All @@ -210,7 +216,7 @@ plot_lrpair_vln(object = obj,

### Use `plot_lr_path()` to view network with LR and downstream pathways

```{r plot_lr_path, echo=TRUE}
```{r plot_lr_path, fig.width=6, fig.height=6, fig.align='center', echo=TRUE}
# Plot network with LR and downstream pathways
plot_lr_path(object = obj,
celltype_sender = 'SST',
Expand All @@ -222,7 +228,7 @@ plot_lr_path(object = obj,

### Use `plot_path2gene()` to view river plot of significantly activated pathways

```{r plot_path2gene, echo=TRUE}
```{r plot_path2gene, fig.width=8, fig.height=6, fig.align='center', echo=TRUE}
# River plot of significantly activated pathways and related downstream genes of receptors
plot_path2gene(object = obj,
celltype_sender = 'SST',
Expand All @@ -237,7 +243,7 @@ plot_path2gene(object = obj,
To infer all paired cell-cell communications, use `dec_cci_all()` instead of `dec_cci()`

```{r dec_cci_all, echo=TRUE}
# Infer cell-cell communications from SST to PVALB neurons
# Infer all cell-cell communications
# obj <- dec_cci_all(object = obj)
```

Expand Down
Loading

0 comments on commit 1623100

Please sign in to comment.