Skip to content

Commit cc3f411

Browse files
committed
update vignettes (part 1) and action dependencies
1 parent 76c84da commit cc3f411

File tree

4 files changed

+41
-34
lines changed

4 files changed

+41
-34
lines changed

.github/workflows/check-bioc.yml

+1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ jobs:
138138
install.packages(c("pkgdown", "sctransform"))
139139
install.packages(c("stringi", "ridge"), type="source", repos="https://cloud.r-project.org/")
140140
BiocManager::install("OmnipathR", ask=FALSE)
141+
install.packages(c("janitor", "reticulate", "Seurat", "SeuratObject"))
141142
142143
## modified from pkgdown::deploy_to_branch
143144
deploy_to_branch_mod <- function(pkg = ".", commit_message = pkgdown:::construct_commit_message(pkg),

DESCRIPTION

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Imports: assertthat, caret, deldir, digest, distances, dplyr (>= 1.1.0), fileloc
4343
furrr (>= 0.2.0), ggplot2, methods, purrr, ranger, readr (>= 2.0.0), ridge,
4444
rlang, rlist, R.utils, stats, stringr, tibble, tidyr, tidyselect (>= 1.2.0),
4545
utils, withr
46-
Suggests: BiocStyle, covr, earth, future, igraph (>= 1.2.7), iml, janitor,
47-
kernlab, knitr, MASS, rmarkdown, RSNNS, testthat (>= 3.0.0), xgboost
46+
Suggests: BiocStyle, covr, earth, future, igraph (>= 1.2.7), iml, kernlab,
47+
knitr, MASS, rmarkdown, RSNNS, testthat (>= 3.0.0), xgboost
4848
RoxygenNote: 7.3.1
4949
Config/testthat/edition: 3

vignettes/FunctionalAndStructuralPipeline.Rmd

+21-17
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
---
2-
title: "Learning functional and structural spatial relationships with MistyR"
3-
author: |
4-
| Leoni Zimmermann
5-
2+
title: "Learning functional and structural spatial relationships with MISTy"
3+
author:
4+
- name: Leoni Zimmermann
5+
affiliation:
6+
- Heidelberg University, Heidelberg, Germany
7+
- name: Jovan Tanevski
8+
affiliation:
9+
- Heidelberg University and Heidelberg University Hospital, Heidelberg, Germany
10+
- Jožef Stefan Institute, Ljubljana, Slovenia
11+
612
date: "`r Sys.Date()`"
713
package: mistyR
814
output:
@@ -11,21 +17,19 @@ output:
1117
extra_dependencies:
1218
nowidow: ["defaultlines=3", "all"]
1319
vignette: >
14-
%\VignetteIndexEntry{Learning functional and structural spatial relationships with MistyR}
20+
%\VignetteIndexEntry{Learning functional and structural spatial relationships with MISTy}
1521
%\VignetteEngine{knitr::rmarkdown}
1622
%\VignetteEncoding{UTF-8}
1723
---
1824

1925
## Introduction
2026

21-
MistyR analyzes spatial omics datasets within and between distinct spatial contexts referred to as views. This analysis can focus on functional information, for example, gene expression, and structural information, like cell-type compositions.
22-
23-
Visium is a method that captures spatial transcriptomic information from spots possibly containing multiple cells. In this vignette, we will use the gene expression information from Visium data to infer pathway and transcription factor activity and separately investigate spatial relationships between them and the cell-type composition. In addition, we will examine spatial relationships of ligands and receptors.
27+
10X Visium captures spatially resolved transcriptomic profiles in spots containing multiple cells. In this vignette, we will use the gene expression information from Visium data to infer pathway and transcription factor activity and separately investigate spatial relationships between them and the cell-type composition. In addition, we will examine spatial relationships of ligands and receptors.
2428

2529
Load the necessary R packages:
2630

2731
```{r message=FALSE, warning=FALSE}
28-
# Misty
32+
# MISTy
2933
library(mistyR)
3034
3135
# For using Python
@@ -57,7 +61,7 @@ import decoupler as dc
5761

5862
## Get and load data
5963

60-
For this showcase, we use a 10X Visium spatial slide from [Kuppe et al., 2022](https://doi.org/10.1038/s41586-022-05060-x), where they created a spatial multi-omic map of human myocardial infarction. The tissue example data comes from the human heart of patient 14, which is in a later state after myocardial infarction. The Seurat object contains, among other things, the normalized and raw gene counts. First, we have to download and extract the file:
64+
For this showcase, we use a 10X Visium spatial slide from [Kuppe et al., 2022](https://doi.org/10.1038/s41586-022-05060-x), where they created a spatial multi-omic map of human myocardial infarction. The tissue example data comes from the human heart of patient 14, which is in a chronic state following myocardial infarction. The Seurat object contains, among other things, the normalized and raw gene counts. First, we have to download and extract the file:
6165

6266
```{r}
6367
download.file("https://zenodo.org/records/6580069/files/10X_Visium_ACH005.tar.gz?download=1",
@@ -85,7 +89,7 @@ SpatialPlot(seurat, group.by = "celltype_niche")
8589

8690
## Extract cell-type composition
8791

88-
The Seurat Object of the tissue slide also contains the estimated cell type proportions from cell2location. We extract them into a separate object we will later use with Misty and visualize some of the cell types:
92+
The Seurat Object of the tissue slide also contains the estimated cell type proportions from cell2location. We extract them into a separate object we will later use with MISTy and visualize some of the cell types:
8993

9094
```{r fig.height=10, fig.width=10}
9195
# Rename to more informative names
@@ -144,9 +148,9 @@ seurat[['progeny']] <- CreateAssayObject(counts = t(est_path_act_wide))
144148
SpatialFeaturePlot(seurat, features = c("jak.stat", "hypoxia"), image.alpha = 0)
145149
```
146150

147-
### Misty Views
151+
### MISTy Views
148152

149-
For the Misty view, we will use cell type compositions per spot as the intraview and add the estimated [`PROGENy`](https://saezlab.github.io/progeny/index.html) pathway activities as juxta and paraviews. The size of the neighborhood and the kernel, as well as the kernel family, should be chosen depending on the experiment. Here both distances were chosen to enclose only a small number of neighboring spots.
153+
For the MISTy view, we will use cell type compositions per spot as the intraview and add the estimated [`PROGENy`](https://saezlab.github.io/progeny/index.html) pathway activities as juxta and paraviews. The size of the neighborhood and the kernel, as well as the kernel family, should be chosen depending on the experiment. Here both distances were chosen to enclose only a small number of neighboring spots.
150154

151155
```{r message=FALSE, warning=FALSE}
152156
# Clean names
@@ -166,7 +170,7 @@ com_path_act_views <- comp_views %>%
166170
add_views(create_view("paraview.path.200", path_act_views[["paraview.200"]]$data, "para.path.200"))
167171
```
168172

169-
Then run Misty and collect the results:
173+
Then run MISTy and collect the results:
170174

171175
```{r message=FALSE, warning=FALSE}
172176
run_misty(com_path_act_views, "result/comp_path_act")
@@ -225,7 +229,7 @@ We observe similar distributions for both.
225229

226230
## Pathway activities on cell-type composition - Linear Model
227231

228-
The default model used by Misty to model each view is the random forest. However, there are different models to choose from, like the faster and more interpretable linear model.
232+
The default model used by MISTy to model each view is the random forest. However, there are different models to choose from, like the faster and more interpretable linear model.
229233

230234
Another option we haven't used yet is `bypass.intra`. With this, we bypass training the baseline model that predicts the intraview with features from the intraview itself. We will still be able to see how the other views explain the intraview. We will use the same view composition as before:
231235

@@ -285,7 +289,7 @@ The object with the estimation contains two elements: The first are the estimate
285289
est_TF <- py$acts_tfs
286290
```
287291

288-
To speed up the following model training, we calculate the 1000 most variable genes expressed. We then extract the TF from the highly variable genes to create a Misty view.
292+
To speed up the following model training, we calculate the 1000 most variable genes expressed. We then extract the TF from the highly variable genes to create a MISTy view.
289293

290294
```{r}
291295
# Highly variable genes
@@ -403,7 +407,7 @@ misty_results_lig_recep %>%
403407
plot_interaction_heatmap("para.lig.200", clean = TRUE, cutoff = 2, trim.measure ="gain.R2", trim = 25)
404408
```
405409

406-
Please remember, that Misty does not only infer interactions between ligands and their respective receptor, but rather all possible interactions between ligands and receptors. We can visualize one of the interactions with high importance:
410+
Remember that MISTy does not only infer interactions between ligands and their respective receptor, but rather all possible interactions between ligands and receptors. We can visualize one of the interactions with high importance:
407411

408412
```{r}
409413
DefaultAssay(seurat) <- "SCT"

vignettes/FunctionalPipelinePathwayActivityLigands.Rmd

+17-15
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
---
2-
title: "MistyR functional analysis pipeline - pathway activity and ligand expression"
3-
author: |
4-
| Leoni Zimmermann
5-
2+
title: "Functional analysis with MISTy - pathway activity and ligand expression"
3+
author:
4+
- name: Leoni Zimmermann
5+
affiliation:
6+
- Heidelberg University, Heidelberg, Germany
7+
- name: Jovan Tanevski
8+
affiliation:
9+
- Heidelberg University and Heidelberg University Hospital, Heidelberg, Germany
10+
- Jožef Stefan Institute, Ljubljana, Slovenia
11+
612
date: "`r Sys.Date()`"
713
package: mistyR
814
output:
@@ -11,21 +17,17 @@ output:
1117
extra_dependencies:
1218
nowidow: ["defaultlines=3", "all"]
1319
vignette: >
14-
%\VignetteIndexEntry{MistyR functional analysis pipeline - pathway activity and ligand expression}
20+
%\VignetteIndexEntry{Functional analysis with MISTy - pathway activity and ligand expression}
1521
%\VignetteEngine{knitr::rmarkdown}
1622
%\VignetteEncoding{UTF-8}
1723
---
1824

1925
## Introduction
2026

21-
MistyR analyzes spatial omics datasets within and between distinct spatial contexts referred to as views. This analysis can focus on functional information, for example, gene expression.
22-
23-
Visium is a method that captures spatial transcriptomic information from spots possibly containing multiple cells. In this vignette, we will use the gene expression information from Visium data to infer pathway activity and investigate spatial relationships between some pathways and ligand expression.
27+
10X Visium captures spatially resolved transcriptomic profiles in spots containing multiple cells. In this vignette, we will use the gene expression information from Visium data to infer pathway activity and investigate spatial relationships between some pathways and ligand expression.
2428

2529
Load the necessary packages:
2630

27-
setwd("E:/LabRotationSaez/RCode/VisiumFunctional/")
28-
2931
```{r message=FALSE, warning=FALSE}
3032
# MISTy
3133
library(mistyR)
@@ -94,7 +96,7 @@ seurat_vs[['progeny']] <- CreateAssayObject(counts = t(progeny_scores))
9496
9597
rownames(seurat_vs@assays$progeny@data) <- seurat_vs@assays$progeny@data %>% clean_names(parsing_option = 0) %>% rownames(.)
9698
97-
# Format for running misty later
99+
# Format for running MISTy later
98100
pathway_activity <- t(as.matrix(GetAssayData(seurat_vs, "progeny")))
99101
```
100102

@@ -121,7 +123,7 @@ rownames(seurat_vs@assays$SCT@data) <- seurat_vs@assays$SCT@data %>% clean_names
121123

122124
## Visualize pathway activity
123125

124-
Before continuing with creating the Misty view, we can look at the slide itself and some of the pathway activities.
126+
Before continuing with creating the MISTy view, we can look at the slide itself and some of the pathway activities.
125127

126128
```{r}
127129
#Slide
@@ -132,9 +134,9 @@ DefaultAssay(seurat_vs) <- "progeny"
132134
SpatialFeaturePlot(seurat_vs, feature = c("mapk", "p53"), keep.scale = NULL)
133135
```
134136

135-
## Misty views
137+
## MISTy views
136138

137-
Now we need to create the Misty views of interest. We are interested in the relationship of the pathway activity in the same spot (intraview) and the ten closest spots (paraview). Therefore we choose the family \`constant\` and set l to ten, which will select the ten nearest neighbors. Depending on the goal of the analysis, different families can be applied.
139+
Now we need to create the MISTy views of interest. We are interested in the relationship of the pathway activity in the same spot (intraview) and the ten closest spots (paraview). Therefore we choose the family \`constant\` and set l to ten, which will select the ten nearest neighbors. Depending on the goal of the analysis, different families can be applied.
138140

139141
We are also intrigued about the relationship of ligand expression and pathway activity in the broader tissue. For this, we again create an intra- and paraview, this time for the expression of the ligands, but from this view, we only need the paraview. In the next step, we add it to the pathway activity views to achieve our intended view composition.
140142

@@ -150,7 +152,7 @@ combined_views <- pathway_act_view %>% add_views(create_view("paraview.ligand.10
150152
151153
```
152154

153-
Then run mistyR and collect the results:
155+
Then run MISTy and collect the results:
154156

155157
```{r message=FALSE, warning=FALSE}
156158
run_misty(combined_views, "result/functional_ligand")

0 commit comments

Comments
 (0)