Skip to content

Commit

Permalink
picked marker gene clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
Geert van Geest committed Jun 13, 2024
1 parent 04ab03b commit 61b42a3
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 45 deletions.
8 changes: 4 additions & 4 deletions 2_quality_control.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ SpatialPlot(seu, alpha = 0) +
And we can plot any feature as an overlay, for example, here we have the number of UMI per spot:

```{r}
SpatialPlot(seu, features = "nCount_Spatial", alpha = 0.5) +
SpatialPlot(seu, features = "nCount_Spatial", pt.size.factor = 2.5) +
plot_layout(guides='collect') & theme(legend.position = "right")
```

Expand Down Expand Up @@ -194,7 +194,7 @@ FeatureScatter(seu,
Now we have to decide whether we want to filter away spots with high mitochondrial counts, and if so, at what threshold. In order to make a decision, it makes sense to plot the mitochondrial counts in a spatial context, so we can check whether it correpsonds to spatial features:

```{r}
SpatialPlot(seu, features = "percent_mt", alpha = 0.7) +
SpatialPlot(seu, features = "percent_mt", pt.size.factor = 2.5) +
plot_layout(guides='collect') & theme(legend.position = "right")
```

Expand Down Expand Up @@ -319,8 +319,8 @@ Showing us that an assay called `SCT` has appeared.
Now that we have done the transformation it is also possible to plot gene experssion information in a spatial context, e.g. `Ttr`:

```{r}
SpatialPlot(seu_list$Anterior, features = "Ttr") +
SpatialPlot(seu_list$Posterior, features = "Ttr") +
SpatialPlot(seu_list$Anterior, features = "Ttr", pt.size.factor = 2.5) +
SpatialPlot(seu_list$Posterior, features = "Ttr", pt.size.factor = 2.5) +
plot_layout(guides='collect') & theme(legend.position = "right")
```
After quality control and transformation, we can save the output as an rds files:
Expand Down
88 changes: 47 additions & 41 deletions 3_integration_clustering.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -105,66 +105,72 @@ SpatialPlot(seu_int, group.by = res, pt.size.factor = 2) +

```{r}
Idents(seu_int) <- "integrated_snn_res.0.4"
SpatialDimPlot(seu_int,
alpha = 0.6,
cells.highlight = CellsByIdentities(object = seu_int,
idents = 7)) +
plot_layout(guides='collect') &
theme(legend.position = "none")
SpatialDimPlot(seu_int,
alpha = 0.6,
cells.highlight = CellsByIdentities(object = seu_int,
idents = 4)) +
plot_layout(guides='collect') &
theme(legend.position = "none")
SpatialDimPlot(seu_int,
alpha = 0.6,
cells.highlight = CellsByIdentities(object = seu_int,
idents = 0)) +
plot_layout(guides='collect') &
theme(legend.position = "none")
```

```{r}
#| warning: false
DefaultAssay(seu_int) <- "SCT"
seu_int <- PrepSCTFindMarkers(seu_int)
all_marks <- FindAllMarkers(seu_int, only.pos = TRUE, min.pct = 0.25, logfc.threshold = 0.25)
```

```{r}
SpatialPlot(seu_int, features = "Fth1")
# oligodendrocytes, myenilated neurons
```


```{r}
#| fig-width: 9
top_specific_markers <- all_marks |>
top_markers <- all_marks |>
mutate(order_value = avg_log2FC * -log10(p_val_adj + 1e-323)) |>
arrange(cluster, desc(order_value)) |>
group_by(cluster) |>
top_n(3, avg_log2FC)
top_n(3)
DotPlot(seu_int, features = top_specific_markers$gene) +
# DefaultAssay(seu_int) <- "integrated"
DotPlot(seu_int, features = top_markers$gene) +
scale_x_discrete(guide = guide_axis(angle = 45))
```


```{r}
DefaultAssay(seu_list$Anterior) <- "SCT"
SpatialDimPlot(seu_int,
cells.highlight = CellsByIdentities(object = seu_int,
idents = 3)) +
plot_layout(guides='collect') &
theme(legend.position = "none")
seu_list$Anterior <-
FindSpatiallyVariableFeatures(
seu_list$Anterior,
features = rownames(seu_int),
selection.method = "moransi"
)
SpatialPlot(seu_int,
features = top_markers$gene[top_markers$cluster == 3][1],
pt.size.factor = 2)
```

spatialFeatures <-
SVFInfo(seu_list$Anterior, method = "moransi", status = TRUE)
spatialFeatures <-
spatialFeatures |> arrange(rank)

SpatialPlot(seu_list$Anterior, features = rownames(spatialFeatures)[1:6], ncol = 3, alpha = c(0.1, 1))
```{r}
SpatialDimPlot(seu_int,
cells.highlight = CellsByIdentities(object = seu_int,
idents = 0)) +
plot_layout(guides='collect') &
theme(legend.position = "none")
SpatialPlot(seu_int,
features = top_markers$gene[top_markers$cluster == 0][1],
pt.size.factor = 2)
```


<!-- ```{r} -->
<!-- DefaultAssay(seu_list$Anterior) <- "SCT" -->

<!-- seu_list$Anterior <- -->
<!-- FindSpatiallyVariableFeatures( -->
<!-- seu_list$Anterior, -->
<!-- features = rownames(seu_int), -->
<!-- selection.method = "moransi" -->
<!-- ) -->

<!-- spatialFeatures <- -->
<!-- SVFInfo(seu_list$Anterior, method = "moransi", status = TRUE) -->
<!-- spatialFeatures <- -->
<!-- spatialFeatures |> arrange(rank) -->

<!-- SpatialPlot(seu_list$Anterior, features = rownames(spatialFeatures)[1:6], ncol = 3, alpha = c(0.1, 1)) -->
<!-- ``` -->

0 comments on commit 61b42a3

Please sign in to comment.