Skip to content

Commit

Permalink
santizes integration and clustering
Browse files Browse the repository at this point in the history
  • Loading branch information
Geert van Geest committed Jun 12, 2024
1 parent ca22792 commit 04ab03b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,5 @@ output/
course_data/

.DS_Store
*.docx

10 changes: 5 additions & 5 deletions 2_quality_control.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ engine: knitr

## Quality reports

In the `course_data` directories you can find an html report named `web_summary.html` that gives information about the cellranger run.
In the `course_data` directories you can find an html report named `web_summary.html` that gives information about the spaceranger run.


::: {.callout-important}
Expand All @@ -17,9 +17,9 @@ Have a look at both reports. Could we capture the entire slice? Can you expect a
::: {.callout-tip collapse="true"}
## Answer

- For both the Antherior and Posterior parts of the slice are outside the captured region
- For both the Anterior and Posterior parts of the slice are outside the captured region
- Also not all spots are on a slice, the number of spots per slice:
- Antherior: 2695
- Anterior: 2695
- Posterior: 3355
:::

Expand Down Expand Up @@ -49,7 +49,7 @@ seu_list <- lapply(c("Anterior", "Posterior"), function(slice) {
```

After creating the list, we merge the two objects into one Seurat object, and we set the default identity (mostly for plotting purposes) to the slice identifier (i.e. Posterior or Antherior).
After creating the list, we merge the two objects into one Seurat object, and we set the default identity (mostly for plotting purposes) to the slice identifier (i.e. Posterior or Anterior).

```{r}
seu <- merge(seu_list[[1]], seu_list[[2]])
Expand All @@ -68,7 +68,7 @@ In addition to the original count table and image, the `Seurat` object can there
seurat_object <- Seurat::function(seurat_object)
```

So, the function takes an object as input and we assign it to an object with the same name. Meaning that we overwrite the object used as input. This is fine in many cases, because `Seurat` adds information to the input object, and returns is. We will use this syntax for the first time at [Normalization and scaling](3_normalization_scaling.qmd).
So, the function takes an object as input and we assign it to an object with the same name. Meaning that we overwrite the object used as input. This is fine in many cases, because `Seurat` adds information to the input object, and returns is.

In order to check out the count data that is stored in our Seurat object, we can run `GetAssayData`, in which we specify the assay and the layer from which we extract the counts. Since we have a combined object we have two layers with counts, `counts.1` corresponding to `Anterior` and `counts.2` corresponding to `Posterior`. Let's have a look at the counts from the Anterior slice:

Expand Down
11 changes: 8 additions & 3 deletions 3_integration_clustering.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ seu <- merge(seu_list[[1]], seu_list[[2]])
```

```{r}
#| output: false
VariableFeatures(seu) <- intersect(VariableFeatures(seu_list$Anterior),
VariableFeatures(seu_list$Posterior))
seu <- RunPCA(seu, assay = "SCT", npcs = 50, verbose = FALSE)
Expand All @@ -34,8 +35,10 @@ DimPlot(seu, reduction = "umap", group.by = "orig.ident") +

## Integration

```{r}
You can safely ignore the warning: `Warning: Different cells and/or features from existing assay SCT`. See [this issue](https://github.com/satijalab/seurat/issues/7145).

```{r}
#| output: false
features <- SelectIntegrationFeatures(seu_list)
seu_list <- PrepSCTIntegration(seu_list, anchor.features = features)
Expand All @@ -49,6 +52,7 @@ seu_int <- IntegrateData(anchors, normalization.method = "SCT")
```

```{r}
#| warning: false
seu_int <- FindVariableFeatures(seu_int)
seu_int <- RunPCA(seu_int, npcs = 50, verbose = FALSE)
seu_int <- RunUMAP(seu_int, reduction = "pca", dims = 1:50)
Expand Down Expand Up @@ -83,7 +87,7 @@ clustree(seu_int, prefix = "integrated_snn_res.")
```

```{r}
#| warning: false
res <- "integrated_snn_res.0.4"
nclust <- seu_int[[res]] |> unique() |> nrow()
cluster_cols <- viridis::viridis_pal(option = "H")(nclust)
Expand All @@ -93,7 +97,7 @@ DimPlot(seu_int,
shuffle = TRUE,
cols = cluster_cols)
SpatialPlot(seu_int, group.by = res) +
SpatialPlot(seu_int, group.by = res, pt.size.factor = 2) +
plot_layout(guides='collect') &
theme(legend.position = "none") &
scale_fill_viridis_d(option = "H")
Expand Down Expand Up @@ -125,6 +129,7 @@ SpatialDimPlot(seu_int,
```

```{r}
#| warning: false
seu_int <- PrepSCTFindMarkers(seu_int)
all_marks <- FindAllMarkers(seu_int, only.pos = TRUE, min.pct = 0.25, logfc.threshold = 0.25)
```
Expand Down
8 changes: 4 additions & 4 deletions renv.lock
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@
},
"Seurat": {
"Package": "Seurat",
"Version": "5.0.2",
"Version": "5.1.0",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
Expand Down Expand Up @@ -830,11 +830,11 @@
"utils",
"uwot"
],
"Hash": "3705cd617f5ae8d74cbab2538842611b"
"Hash": "aa2040fec3d03e3e598e0b406a84a104"
},
"SeuratObject": {
"Package": "SeuratObject",
"Version": "5.0.1",
"Version": "5.0.2",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
Expand All @@ -857,7 +857,7 @@
"tools",
"utils"
],
"Hash": "424c2b9e50b053c86fc38f17e09917da"
"Hash": "e9b70412b7e04571b46101f5dcbaacad"
},
"SingleCellExperiment": {
"Package": "SingleCellExperiment",
Expand Down

0 comments on commit 04ab03b

Please sign in to comment.