diff --git a/404.html b/404.html index b8ca4ad..46f42f1 100644 --- a/404.html +++ b/404.html @@ -42,6 +42,7 @@
+vignettes/MERFISH_mouseHypothalamus.Rmd
MERFISH_mouseHypothalamus.Rmd
-data(mousePH_subset)
-spe2
+data(mHypothal)
+spe = SpatialExperiment(assays = list(logcounts = mh_expr),
+ colData = mh_data, spatialCoordsNames = c("X", "Y"))
+spe
#> class: SpatialExperiment
-#> dim: 135 17918
+#> dim: 135 15848
#> metadata(0):
#> assays(1): logcounts
#> rownames(135): Ace2 Adora2a ... Ttn Ttyh2
#> rowData names(0):
-#> colnames(17918): 8c7df84c-8a53-4aa4-86fd-26e575de9b0e
+#> colnames(15848): 8c7df84c-8a53-4aa4-86fd-26e575de9b0e
#> 3617ee7c-c0a8-4f18-b9bd-c7ca737ff665 ...
+#> 8d083684-2e8d-47aa-91f4-dc88d1621f08
#> 96bc85ce-b993-4fb1-8e0c-165f83f0cfd0
-#> a5847bc4-94d4-44c0-8974-87388b951b0c
#> colData names(4): Cell_ID Cell_class sample_id samples
#> reducedDimNames(0):
#> mainExpName: NULL
#> altExpNames(0):
-#> spatialCoords names(2) : Centroid_X Centroid_Y
-#> imgData names(1): sample_id
To run clustSIGNAL, we need the column names of sample and cell IDs in the colData dataframe of the spatial experiment object. Here, the @@ -113,57 +116,57 @@
-spe2 = res_hyp$spe_final
-spe2
+spe = res_hyp$spe_final
+spe
#> class: SpatialExperiment
-#> dim: 135 17918
+#> dim: 135 15848
#> metadata(0):
#> assays(2): logcounts smoothed
#> rownames(135): Ace2 Adora2a ... Ttn Ttyh2
#> rowData names(0):
-#> colnames(17918): 8c7df84c-8a53-4aa4-86fd-26e575de9b0e
+#> colnames(15848): 8c7df84c-8a53-4aa4-86fd-26e575de9b0e
#> 3617ee7c-c0a8-4f18-b9bd-c7ca737ff665 ...
+#> 8d083684-2e8d-47aa-91f4-dc88d1621f08
#> 96bc85ce-b993-4fb1-8e0c-165f83f0cfd0
-#> a5847bc4-94d4-44c0-8974-87388b951b0c
#> colData names(8): Cell_ID Cell_class ... entropy reCluster
#> reducedDimNames(2): PCA PCA.smooth
#> mainExpName: NULL
#> altExpNames(0):
-#> spatialCoords names(2) : Centroid_X Centroid_Y
+#> spatialCoords names(2) : X Y
#> imgData names(1): sample_id
-samplesList <- levels(spe2[[samples]])
samplesList <- levels(spe[[samples]])
# calculating silhouette width per sample
silWidthRC <- matrix(nrow = 0, ncol = 3)
for (s in samplesList) {
- speX <- spe2[, spe2[[samples]] == s]
+ speX <- spe[, spe[[samples]] == s]
clust_sub <- as.numeric(as.character(speX$reCluster))
cXg <- t(as.matrix(logcounts(speX)))
distMat <- distances(cXg)
silCluster <- as.matrix(silhouette(clust_sub, distMat))
silWidthRC <- rbind(silWidthRC, silCluster)
}
-spe2$rcSil <- silWidthRC[, 3]
# for datasets with annotated cell type information, we can also calculate
# metrics like adjusted rand index (ARI) and normalised mutual information (NMI)
-as.data.frame(colData(spe2)) %>%
+as.data.frame(colData(spe)) %>%
group_by(samples) %>%
summarise(ARI = aricode::ARI(Cell_class, reCluster),
NMI = aricode::NMI(Cell_class, reCluster),
@@ -174,9 +177,9 @@ Calculating clustering metrics#> # A tibble: 3 × 7
#> samples ARI NMI ASW min_Entropy max_Entropy mean_Entropy
#> <fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 1.-0.09 0.391 0.534 0.0681 0.561 4.57 3.55
-#> 2 7.-0.09 0.390 0.544 0.105 0.211 4.71 3.54
-#> 3 7.0.16 0.446 0.575 0.0860 1.04 4.57 3.45
# Histogram of entropy spread
-hst_ent <- as.data.frame(colData(spe2)) %>%
+hst_ent <- as.data.frame(colData(spe)) %>%
ggplot(aes(entropy)) +
geom_histogram(binwidth = 0.05) +
ggtitle("A") +
@@ -205,13 +208,13 @@ Entropy spread and distribution theme(text = element_text(size = 12))
# Spatial plot showing sample entropy distribution
-spt_ent <- as.data.frame(colData(spe2)) %>%
- ggplot(aes(x = spatialCoords(spe2)[, 1],
- y = -spatialCoords(spe2)[, 2])) +
+spt_ent <- as.data.frame(colData(spe)) %>%
+ ggplot(aes(x = spatialCoords(spe)[, 1],
+ y = -spatialCoords(spe)[, 2])) +
geom_point(size = 0.5,
aes(colour = entropy)) +
scale_colour_gradient2("Entropy", low = "grey", high = "blue") +
- scale_size_continuous(range = c(0, max(spe2$entropy))) +
+ scale_size_continuous(range = c(0, max(spe$entropy))) +
facet_wrap(vars(samples), scales = "free", nrow = 1) +
ggtitle("B") +
labs(x = "x-coordinate", y = "y-coordinate") +
@@ -229,12 +232,12 @@ Entropy spread and distributionclustSIGNAL clusters visualisation
-df_ent = as.data.frame(colData(spe2))
+df_ent = as.data.frame(colData(spe))
# spatial plot
spt_clust <- df_ent %>%
- ggplot(aes(x = spatialCoords(spe2)[, 1],
- y = -spatialCoords(spe2)[, 2])) +
+ ggplot(aes(x = spatialCoords(spe)[, 1],
+ y = -spatialCoords(spe)[, 2])) +
geom_point(size = 0.5, aes(colour = reCluster)) +
scale_color_manual(values = colors) +
facet_wrap(vars(samples), scales = "free", nrow = 1) +
@@ -247,7 +250,7 @@ clustSIGNAL clusters visualisation
box_clust = list()
for (s in samplesList) {
- df_ent_sub = as.data.frame(colData(spe2)[spe2[[samples]] == s, ])
+ df_ent_sub = as.data.frame(colData(spe)[spe[[samples]] == s, ])
# calculating median entropy of each cluster in a sample
celltype_ent = df_ent_sub %>%
group_by(as.character(reCluster)) %>%
diff --git a/articles/MERFISH_mouseHypothalamus_files/figure-html/unnamed-chunk-11-1.png b/articles/MERFISH_mouseHypothalamus_files/figure-html/unnamed-chunk-11-1.png
index 4599f47..d2ac758 100644
Binary files a/articles/MERFISH_mouseHypothalamus_files/figure-html/unnamed-chunk-11-1.png and b/articles/MERFISH_mouseHypothalamus_files/figure-html/unnamed-chunk-11-1.png differ
diff --git a/articles/MERFISH_mouseHypothalamus_files/figure-html/unnamed-chunk-12-1.png b/articles/MERFISH_mouseHypothalamus_files/figure-html/unnamed-chunk-12-1.png
index a937c89..507afad 100644
Binary files a/articles/MERFISH_mouseHypothalamus_files/figure-html/unnamed-chunk-12-1.png and b/articles/MERFISH_mouseHypothalamus_files/figure-html/unnamed-chunk-12-1.png differ
diff --git a/articles/index.html b/articles/index.html
index b0e8e7f..91e20ca 100644
--- a/articles/index.html
+++ b/articles/index.html
@@ -23,6 +23,7 @@
diff --git a/articles/seqFISH_mouseEmbryo.html b/articles/seqFISH_mouseEmbryo.html
index c587a40..9fe11da 100644
--- a/articles/seqFISH_mouseEmbryo.html
+++ b/articles/seqFISH_mouseEmbryo.html
@@ -42,6 +42,7 @@
+
vignettes/seqFISH_mouseEmbryo.Rmd
seqFISH_mouseEmbryo.Rmd
-data(mouseEmbryo2)
+data(mEmbryo2)
+spe = SpatialExperiment(assays = list(logcounts = me_expr),
+ colData = me_data, spatialCoordsNames = c("X", "Y"))
spe
#> class: SpatialExperiment
-#> dim: 351 14891
+#> dim: 351 14185
#> metadata(0):
#> assays(1): logcounts
#> rownames(351): Abcc4 Acp5 ... Zfp57 Zic3
#> rowData names(0):
-#> colnames(14891): embryo2_Pos29_cell10_z2 embryo2_Pos29_cell10_z5 ...
+#> colnames(14185): embryo2_Pos29_cell10_z2 embryo2_Pos29_cell10_z5 ...
#> embryo2_Pos50_cell99_z2 embryo2_Pos50_cell99_z5
#> colData names(7): uniqueID pos ... nsCluster nsSubcluster
#> reducedDimNames(0):
#> mainExpName: NULL
#> altExpNames(0):
-#> spatialCoords names(2) : x_global_affine y_global_affine
-#> imgData names(1): sample_id
names(colData(spe))
#> [1] "uniqueID" "pos"
@@ -116,14 +119,14 @@ Running clustSIGNALcells = "uniqueID"
res_emb = clustSIGNAL(spe, samples, cells, outputs = "a")
#> [1] "Calculating PCA to use as reduced dimension input."
-#> [1] "clustSIGNAL run started. 2024-08-27 03:13:27.114023"
-#> [1] "Initial nonspatial clustering performed. Clusters = 16 2024-08-27 03:13:33.999496"
-#> [1] "Nonspatial subclustering performed. Subclusters = 84 2024-08-27 03:13:38.839607"
-#> [1] "Regions defined. 2024-08-27 03:13:45.424239"
-#> [1] "Region domainness calculated. 2024-08-27 03:13:56.762872"
-#> [1] "Smoothing performed. NN = 30 Kernel = G Spread = 0.05 2024-08-27 03:16:34.701779"
-#> [1] "Nonspatial clustering performed on smoothed data. Clusters = 25 2024-08-27 03:16:40.774963"
-#> [1] "clustSIGNAL run completed. 2024-08-27 03:16:40.776829"
The output variable is a list that can contain dataframe of cluster names, matrix of NN neighbours of each cell, final spe object, or a combination of these, depending on the choice of ‘outputs’ selected.
@@ -133,25 +136,25 @@
head(res_emb$clusters, n = 3)
#> Cells Clusters
-#> 1 embryo2_Pos29_cell10_z2 23
-#> 2 embryo2_Pos29_cell10_z5 23
-#> 3 embryo2_Pos29_cell100_z2 23
+#> 1 embryo2_Pos29_cell10_z2 19
+#> 2 embryo2_Pos29_cell10_z5 19
+#> 3 embryo2_Pos29_cell100_z2 19
spe = res_emb$spe_final
spe
#> class: SpatialExperiment
-#> dim: 351 14891
+#> dim: 351 14185
#> metadata(0):
#> assays(2): logcounts smoothed
#> rownames(351): Abcc4 Acp5 ... Zfp57 Zic3
#> rowData names(0):
-#> colnames(14891): embryo2_Pos29_cell10_z2 embryo2_Pos29_cell10_z5 ...
+#> colnames(14185): embryo2_Pos29_cell10_z2 embryo2_Pos29_cell10_z5 ...
#> embryo2_Pos50_cell99_z2 embryo2_Pos50_cell99_z5
#> colData names(8): uniqueID pos ... nsSubcluster reCluster
#> reducedDimNames(2): PCA PCA.smooth
#> mainExpName: NULL
#> altExpNames(0):
-#> spatialCoords names(2) : x_global_affine y_global_affine
+#> spatialCoords names(2) : X Y
#> imgData names(1): sample_id
Source: DESCRIPTION
c), person), person), person), person) (2024). clustSIGNAL: clustSIGNAL: a spatial clustering method. -R package version 0.1.0, https://sydneybiox.github.io/clustSIGNAL/. +R package version 0.1.0, https://sydneybiox.github.io/clustSIGNAL/, https://sydneybiox.github.io/clustSIGNAL/.
@Manual{, title = {clustSIGNAL: clustSIGNAL: a spatial clustering method}, author = {{c)} and {person)} and {person)} and {person)} and {person)}}, year = {2024}, - note = {R package version 0.1.0}, + note = {R package version 0.1.0, https://sydneybiox.github.io/clustSIGNAL/}, url = {https://sydneybiox.github.io/clustSIGNAL/}, }