diff --git a/404.html b/404.html index b8ca4ad..46f42f1 100644 --- a/404.html +++ b/404.html @@ -42,6 +42,7 @@ + diff --git a/articles/MERFISH_mouseHypothalamus.html b/articles/MERFISH_mouseHypothalamus.html index 3dd6090..5074dde 100644 --- a/articles/MERFISH_mouseHypothalamus.html +++ b/articles/MERFISH_mouseHypothalamus.html @@ -42,6 +42,7 @@ + @@ -59,9 +60,9 @@

Multisample analysis

Pratibha Panwar, Boyi Guo, Haowen Zhou, Stephanie Hicks, Shila Ghazanfar

-

2024-08-27

+

2024-08-28

- + Source: vignettes/MERFISH_mouseHypothalamus.Rmd
MERFISH_mouseHypothalamus.Rmd
@@ -80,26 +81,28 @@

MERFISH mouse preopti library(ggplot2) library(patchwork)
-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
+#> spatialCoords names(2) : X Y +#> imgData names(0):
-names(colData(spe2))
+names(colData(spe))
 #> [1] "Cell_ID"    "Cell_class" "sample_id"  "samples"

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 @@

Running clustSIGNALset.seed(101) samples = "samples" cells = "Cell_ID" -res_hyp = clustSIGNAL(spe2, samples, cells, outputs = "a") +res_hyp = clustSIGNAL(spe, samples, cells, outputs = "a") #> [1] "Calculating PCA to use as reduced dimension input." -#> [1] "clustSIGNAL run started. 2024-08-27 03:10:41.872433" -#> [1] "Initial nonspatial clustering performed. Clusters = 14 2024-08-27 03:10:51.756365" -#> [1] "Nonspatial subclustering performed. Subclusters = 96 2024-08-27 03:10:56.668373" -#> [1] "Regions defined. 2024-08-27 03:11:04.495626" -#> [1] "Region domainness calculated. 2024-08-27 03:11:17.8949" -#> [1] "Smoothing performed. NN = 30 Kernel = G Spread = 0.05 2024-08-27 03:12:50.933457" -#> [1] "Nonspatial clustering performed on smoothed data. Clusters = 15 2024-08-27 03:13:01.679949" -#> [1] "clustSIGNAL run completed. 2024-08-27 03:13:01.681731" +#> [1] "clustSIGNAL run started. 2024-08-28 03:44:25.272925" +#> [1] "Initial nonspatial clustering performed. Clusters = 14 2024-08-28 03:44:32.78017" +#> [1] "Nonspatial subclustering performed. Subclusters = 84 2024-08-28 03:44:37.687324" +#> [1] "Regions defined. 2024-08-28 03:44:44.677471" +#> [1] "Region domainness calculated. 2024-08-28 03:44:57.453019" +#> [1] "Smoothing performed. NN = 30 Kernel = G Spread = 0.05 2024-08-28 03:46:22.970366" +#> [1] "Nonspatial clustering performed on smoothed data. Clusters = 13 2024-08-28 03:46:31.627266" +#> [1] "clustSIGNAL run completed. 2024-08-28 03:46:31.629056"
-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

Calculating clustering metrics

-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]
+spe$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

+#> 1 1.-0.09 0.433 0.608 0.0859 1.11 4.62 3.44 +#> 2 7.-0.09 0.439 0.623 0.135 0.420 4.57 3.42 +#> 3 7.0.16 0.546 0.679 0.110 0 4.62 3.34

Visualising clustSIGNAL outputs @@ -195,7 +198,7 @@

Entropy spread and distribution
 # 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 @@ +
@@ -59,9 +60,9 @@

Single sample analysis

Pratibha Panwar, Boyi Guo, Haowen Zhou, Stephanie Hicks, Shila Ghazanfar

-

2024-08-27

+

2024-08-28

- + Source: vignettes/seqFISH_mouseEmbryo.Rmd
seqFISH_mouseEmbryo.Rmd

@@ -80,22 +81,24 @@

SeqFISH mouse embryo data analysislibrary(ggplot2) library(patchwork)
-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
+#> spatialCoords names(2) : X Y +#> imgData names(0):
 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"

+#> [1] "clustSIGNAL run started. 2024-08-28 03:46:56.505918" +#> [1] "Initial nonspatial clustering performed. Clusters = 16 2024-08-28 03:47:02.245294" +#> [1] "Nonspatial subclustering performed. Subclusters = 80 2024-08-28 03:47:07.286679" +#> [1] "Regions defined. 2024-08-28 03:47:13.02295" +#> [1] "Region domainness calculated. 2024-08-28 03:47:23.788145" +#> [1] "Smoothing performed. NN = 30 Kernel = G Spread = 0.05 2024-08-28 03:49:39.578434" +#> [1] "Nonspatial clustering performed on smoothed data. Clusters = 24 2024-08-28 03:49:45.080824" +#> [1] "clustSIGNAL run completed. 2024-08-28 03:49:45.082649"

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 @@

Running clustSIGNAL
 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
@@ -174,8 +177,8 @@

Calculating clustering metrics= min(entropy), max_Entropy = max(entropy), mean_Entropy = mean(entropy)) -#> ARI NMI ASW min_Entropy max_Entropy mean_Entropy -#> 1 0.2790963 0.5431904 0.0260925 0 3.254097 1.324275

+#> ARI NMI ASW min_Entropy max_Entropy mean_Entropy +#> 1 0.3302441 0.58197 0.03808628 0 2.906357 1.246809

Visualising clustSIGNAL outputs diff --git a/articles/seqFISH_mouseEmbryo_files/figure-html/unnamed-chunk-11-1.png b/articles/seqFISH_mouseEmbryo_files/figure-html/unnamed-chunk-11-1.png index 997f035..5056226 100644 Binary files a/articles/seqFISH_mouseEmbryo_files/figure-html/unnamed-chunk-11-1.png and b/articles/seqFISH_mouseEmbryo_files/figure-html/unnamed-chunk-11-1.png differ diff --git a/articles/seqFISH_mouseEmbryo_files/figure-html/unnamed-chunk-12-1.png b/articles/seqFISH_mouseEmbryo_files/figure-html/unnamed-chunk-12-1.png index 807e7ae..5214bac 100644 Binary files a/articles/seqFISH_mouseEmbryo_files/figure-html/unnamed-chunk-12-1.png and b/articles/seqFISH_mouseEmbryo_files/figure-html/unnamed-chunk-12-1.png differ diff --git a/authors.html b/authors.html index 2c210fe..d3811b3 100644 --- a/authors.html +++ b/authors.html @@ -23,6 +23,7 @@

@@ -45,17 +46,17 @@

Authors

Citation

-

+

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/},
 }
diff --git a/index.html b/index.html index 1129809..3030109 100644 --- a/index.html +++ b/index.html @@ -44,6 +44,7 @@ + @@ -115,7 +116,15 @@

Running clustSIGNALres = clustSIGNAL(spe, samples = "embryo", cells = "uniqueID", dimRed = "PCA", cluster.fun = "leiden", outputs = "a") -