diff --git a/articles/wSIR_vignette.html b/articles/wSIR_vignette.html index b1b7267..c625c33 100644 --- a/articles/wSIR_vignette.html +++ b/articles/wSIR_vignette.html @@ -255,27 +255,27 @@

Parameter Study alpha_vals = c(0,.5, 1,2,4,8), slice_vals = c(5,10,15), nrep = 20, metric = "CD") -
## Time difference of 3.839898 secs
-## Time difference of 4.321839 secs
-## Time difference of 4.727568 secs
-## Time difference of 3.141339 secs
-## Time difference of 4.100014 secs
-## Time difference of 4.466855 secs
-## Time difference of 3.018357 secs
-## Time difference of 3.815955 secs
-## Time difference of 4.298049 secs
-## Time difference of 2.995081 secs
-## Time difference of 3.463944 secs
-## Time difference of 3.742181 secs
-## Time difference of 2.929425 secs
-## Time difference of 3.371804 secs
-## Time difference of 3.656927 secs
-## Time difference of 3.087192 secs
-## Time difference of 3.340532 secs
-## Time difference of 3.520769 secs
+
## Time difference of 3.932933 secs
+## Time difference of 4.387144 secs
+## Time difference of 4.493731 secs
+## Time difference of 3.365411 secs
+## Time difference of 4.19184 secs
+## Time difference of 4.502382 secs
+## Time difference of 3.462631 secs
+## Time difference of 4.207857 secs
+## Time difference of 4.237237 secs
+## Time difference of 2.842625 secs
+## Time difference of 3.465169 secs
+## Time difference of 3.73744 secs
+## Time difference of 2.925163 secs
+## Time difference of 3.187351 secs
+## Time difference of 3.667856 secs
+## Time difference of 2.88185 secs
+## Time difference of 3.170469 secs
+## Time difference of 3.585481 secs
 Sys.time()-a
-
## Time difference of 1.106125 mins
+
## Time difference of 1.113478 mins
 optim_obj$plot

@@ -539,23 +539,24 @@

Multi-sa ## [7] parallel_4.4.1 tibble_3.2.1 fansi_1.0.6 ## [10] highr_0.11 pkgconfig_2.0.3 Matrix_1.7-0 ## [13] desc_1.4.3 lifecycle_1.0.4 farver_2.1.2 -## [16] compiler_4.4.1 textshaping_0.4.0 microbenchmark_1.5.0 -## [19] munsell_0.5.1 codetools_0.2-20 htmltools_0.5.8.1 -## [22] sass_0.4.9 yaml_2.3.10 pillar_1.9.0 -## [25] pkgdown_2.1.0 jquerylib_0.1.4 tidyr_1.3.1 -## [28] MASS_7.3-60.2 openssl_2.2.1 BiocParallel_1.38.0 -## [31] cachem_1.1.0 boot_1.3-30 RSpectra_0.16-2 -## [34] Deriv_4.1.6 tidyselect_1.2.1 digest_0.6.37 -## [37] dplyr_1.1.4 purrr_1.0.2 bookdown_0.40 -## [40] labeling_0.4.3 distances_0.1.11 cowplot_1.1.3 -## [43] fastmap_1.2.0 grid_4.4.1 colorspace_2.1-1 -## [46] cli_3.6.3 utf8_1.2.4 broom_1.0.6 -## [49] withr_3.0.1 scales_1.3.0 backports_1.5.0 -## [52] rmarkdown_2.28 modelr_0.1.11 reticulate_1.39.0 -## [55] askpass_1.2.0 ragg_1.3.3 png_0.1-8 -## [58] evaluate_0.24.0 knitr_1.48 rlang_1.1.4 -## [61] glue_1.7.0 BiocManager_1.30.25 jsonlite_1.8.8 -## [64] R6_2.5.1 systemfonts_1.1.0 fs_1.6.4 +## [16] compiler_4.4.1 stringr_1.5.1 textshaping_0.4.0 +## [19] microbenchmark_1.5.0 munsell_0.5.1 codetools_0.2-20 +## [22] htmltools_0.5.8.1 sass_0.4.9 yaml_2.3.10 +## [25] pillar_1.9.0 pkgdown_2.1.0 jquerylib_0.1.4 +## [28] tidyr_1.3.1 MASS_7.3-60.2 openssl_2.2.1 +## [31] BiocParallel_1.38.0 cachem_1.1.0 boot_1.3-30 +## [34] RSpectra_0.16-2 Deriv_4.1.6 tidyselect_1.2.1 +## [37] digest_0.6.37 stringi_1.8.4 dplyr_1.1.4 +## [40] purrr_1.0.2 bookdown_0.40 labeling_0.4.3 +## [43] distances_0.1.11 cowplot_1.1.3 fastmap_1.2.0 +## [46] grid_4.4.1 colorspace_2.1-1 cli_3.6.3 +## [49] utf8_1.2.4 broom_1.0.6 withr_3.0.1 +## [52] scales_1.3.0 backports_1.5.0 rmarkdown_2.28 +## [55] modelr_0.1.11 reticulate_1.39.0 askpass_1.2.0 +## [58] ragg_1.3.3 png_0.1-8 evaluate_0.24.0 +## [61] knitr_1.48 rlang_1.1.4 glue_1.7.0 +## [64] BiocManager_1.30.25 jsonlite_1.8.8 R6_2.5.1 +## [67] systemfonts_1.1.0 fs_1.6.4 diff --git a/index.html b/index.html index 272b5df..6369574 100644 --- a/index.html +++ b/index.html @@ -11,8 +11,8 @@ - - + + Skip to contents diff --git a/pkgdown.yml b/pkgdown.yml index 3f88bf0..f390c53 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -3,7 +3,7 @@ pkgdown: 2.1.0 pkgdown_sha: ~ articles: wSIR_vignette: wSIR_vignette.html -last_built: 2024-09-17T06:31Z +last_built: 2024-09-17T06:55Z urls: reference: https://sydneybiox.github.io/wSIR/reference article: https://sydneybiox.github.io/wSIR/articles diff --git a/reference/exploreWSIRParams.html b/reference/exploreWSIRParams.html index 22b72aa..47b79b2 100644 --- a/reference/exploreWSIRParams.html +++ b/reference/exploreWSIRParams.html @@ -142,18 +142,18 @@

Examples coords = sample1_coords, alpha_vals = c(0,2,4,8), slice_vals = c(3,6,10)) -#> Time difference of 1.385958 secs -#> Time difference of 0.8637142 secs -#> Time difference of 1.163008 secs -#> Time difference of 0.8637171 secs -#> Time difference of 0.8029561 secs -#> Time difference of 1.036409 secs -#> Time difference of 0.6865509 secs -#> Time difference of 0.7658222 secs -#> Time difference of 0.9777613 secs -#> Time difference of 0.6980515 secs -#> Time difference of 0.7671394 secs -#> Time difference of 0.9868422 secs +#> Time difference of 1.545631 secs +#> Time difference of 0.8617067 secs +#> Time difference of 1.213241 secs +#> Time difference of 0.7298954 secs +#> Time difference of 0.9463546 secs +#> Time difference of 1.045403 secs +#> Time difference of 0.6928875 secs +#> Time difference of 0.7717257 secs +#> Time difference of 1.010319 secs +#> Time difference of 0.6815271 secs +#> Time difference of 0.7364004 secs +#> Time difference of 0.8060591 secs explore_params$plot explore_params$message diff --git a/reference/wSIR.html b/reference/wSIR.html index 72c52ba..516bf1e 100644 --- a/reference/wSIR.html +++ b/reference/wSIR.html @@ -156,15 +156,15 @@

Examples slice_vals = c(3,6,10), metric = "CD", nrep = 1) # create wsir object -#> Time difference of 0.1331813 secs -#> Time difference of 0.1904442 secs -#> Time difference of 0.2245536 secs -#> Time difference of 0.1569602 secs -#> Time difference of 0.183991 secs -#> Time difference of 0.1858559 secs -#> Time difference of 0.1477439 secs -#> Time difference of 0.1676126 secs -#> Time difference of 0.1930985 secs +#> Time difference of 0.1336157 secs +#> Time difference of 0.1825285 secs +#> Time difference of 0.2045898 secs +#> Time difference of 0.1377778 secs +#> Time difference of 0.1938689 secs +#> Time difference of 0.1801209 secs +#> Time difference of 0.3262882 secs +#> Time difference of 0.1554558 secs +#> Time difference of 0.1658032 secs diff --git a/search.json b/search.json index 903ad2c..c66b632 100644 --- a/search.json +++ b/search.json @@ -1 +1 @@ -[{"path":"https://sydneybiox.github.io/wSIR/articles/wSIR_vignette.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Weighted Sliced Inverse Regression (WSIR)","text":"Weighted Sliced Inverse Regression (wSIR) supervised dimension reduction technique spatial transcriptomics data. method uses cell’s gene expression values covariates spatial position response. allows us create low-dimensional representation gene expression data retains information spatial patterns present gene expression data. resulting mapping gene expression data spatially aware low-dimensional embedding can used project new single-cell gene expression data low-dimensional space preserves ability predict cell’s spatial location low-dimensional embedding.","code":""},{"path":"https://sydneybiox.github.io/wSIR/articles/wSIR_vignette.html","id":"method-overview","dir":"Articles","previous_headings":"Introduction","what":"Method Overview","title":"Weighted Sliced Inverse Regression (WSIR)","text":"wSIR extension supervised dimension reduction technique Sliced Inverse Regression (SIR). SIR existing supervised dimension reduction method works grouping together observations similar values response. spatial transcriptomics data, means grouping cells certain number tiles based spatial position. example, use 4 tiles, cells top right quadrant image/tissue go one group, top left another, . groups summarised averaging expression level cells group genes. , eigendecomposition performed resulting matrix tile-gene means, returning SIR directions SIR scores. motivation behind wSIR SIR uses cell’s spatial position separating cells given number groups/tiles. groups created, lose fact groups may spatially related (come adjacent tiles) groups (come opposite sides tissue). wSIR uses weight matrix incorporate spatial correlation pairs cells SIR algorithm. matrix dimension H*H, H number tiles, (,j)th entry represents distance tiles j. matrix incorporated eigendeomposition step. wSIR output structure SIR output.","code":""},{"path":"https://sydneybiox.github.io/wSIR/articles/wSIR_vignette.html","id":"vignette-overview","dir":"Articles","previous_headings":"Introduction","what":"Vignette Overview","title":"Weighted Sliced Inverse Regression (WSIR)","text":"vignette, demonstrate use WSIR obtain low-dimensional embedding gene expression data. explore embedding using package’s built-functions. However, low-dimensional matrix importantly used downstream tasks benefit lower-dimensional representation gene expression data preserves information cell’s spatial location. perform basic downstream analysis demonstrate practicality wSIR.","code":""},{"path":"https://sydneybiox.github.io/wSIR/articles/wSIR_vignette.html","id":"data","dir":"Articles","previous_headings":"","what":"Data","title":"Weighted Sliced Inverse Regression (WSIR)","text":"use data Lohoff et al, 2021. code allow download mouse data using MouseGastrulationData scran R packages. randomly sample 20% cells three biological replicate samples. vignette examples function wSIR, simply load data already saved data/MouseData.rda.","code":"# Packages needed to download data #library(scran) # for logNormCounts #library(MouseGastrulationData) # to download the data for this vignette set.seed(2024) seqfish_data_sample1 <- LohoffSeqFISHData(samples = c(1,2)) seqfish_data_sample1 = logNormCounts(seqfish_data_sample1) # log transform variance stabilising rownames(seqfish_data_sample1) <- rowData(seqfish_data_sample1)[,\"SYMBOL\"] # change rownames to gene symbols that are consistent sample1_exprs = t(assay(seqfish_data_sample1, \"logcounts\")) # extract matrix of gene expressions sample1_coords = spatialCoords(seqfish_data_sample1)[,1:2] %>% as.data.frame() colnames(sample1_coords) = c(\"x\", \"y\") seqfish_data_sample2 <- LohoffSeqFISHData(samples = c(3,4)) seqfish_data_sample2 = logNormCounts(seqfish_data_sample2) rownames(seqfish_data_sample2) <- rowData(seqfish_data_sample2)[,\"SYMBOL\"] sample2_exprs = t(assay(seqfish_data_sample2, \"logcounts\")) sample2_coords = spatialCoords(seqfish_data_sample2)[,1:2] %>% as.data.frame() colnames(sample2_coords) = c(\"x\", \"y\") seqfish_data_sample3 <- LohoffSeqFISHData(samples = c(5,6)) seqfish_data_sample3 = logNormCounts(seqfish_data_sample3) rownames(seqfish_data_sample3) <- rowData(seqfish_data_sample3)[,\"SYMBOL\"] sample3_exprs = t(assay(seqfish_data_sample3, \"logcounts\")) sample3_coords = spatialCoords(seqfish_data_sample3)[,1:2] %>% as.data.frame() colnames(sample3_coords) = c(\"x\", \"y\") keep1 = sample(c(TRUE, FALSE), nrow(sample1_exprs), replace = TRUE, prob = c(0.2, 0.8)) keep2 = sample(c(TRUE, FALSE), nrow(sample2_exprs), replace = TRUE, prob = c(0.2, 0.8)) keep3 = sample(c(TRUE, FALSE), nrow(sample3_exprs), replace = TRUE, prob = c(0.2, 0.8)) sample1_exprs = sample1_exprs[keep1,] sample1_coords = sample1_coords[keep1,] sample2_exprs = sample2_exprs[keep2,] sample2_coords = sample2_coords[keep2,] sample3_exprs = sample3_exprs[keep3,] sample3_coords = sample3_coords[keep3,] sample1_cell_types = seqfish_data_sample1$celltype[keep1] sample2_cell_types = seqfish_data_sample2$celltype[keep2] sample3_cell_types = seqfish_data_sample3$celltype[keep3] save(sample1_exprs, sample1_coords, sample1_cell_types, sample2_exprs, sample2_coords, sample2_cell_types, sample3_exprs, sample3_coords, sample3_cell_types, file = \"../data/MouseData.rda\", compress = \"xz\") data(MouseData)"},{"path":[]},{"path":"https://sydneybiox.github.io/wSIR/articles/wSIR_vignette.html","id":"parameter-study","dir":"Articles","previous_headings":"Supervised dimension reduction with wSIR","what":"Parameter Study","title":"Weighted Sliced Inverse Regression (WSIR)","text":"wSIR contains two parameters, alpha slices. Parameter slices number groups along spatial axis split observations wSIR algorithm. slices means pick spatial information gene expression data, risk overfitting training set. Parameter alpha modifies strength weight matrix. alpha = 0 equivalent spatial weighting, meaning weight matrix becomes identity matrix. equivalent SIR. Larger alpha values means weight given spatial correlation rather gene expression differences alone computation wSIR directions. function exploreWSIRParams performs wSIR many choices alpha slices identify appropriate parameters moving forward. , use sample 1 . parameters tuned reasonable values. function exploreWSIRParams computes visualises performance wSIR given combinations slices alpha. performance computed following procedure: 1) combination slices alpha, split data 50% train 50% test (train test halves include gene expression data cell coordinates). 2) Perform wSIR training set using current combination slices alpha. 3) Project gene expression data testing set low-dimensional space using wSIR results step 2. 4) Evaluate wSIR’s performance computing either distance correlation (“DC”, default), correlation distances (“CD”) projected gene expression data test set test coordinates, according parameter metric. 5) Repeat steps 2-4 done nrep times (nrep parameter whose default 5). Calculate average metric value nrep iterations combination slices alpha. 6) Repeat steps 1-5 combinations slices alpha obtain average metric value combination. 7) Return combination slices alpha highest average metric value display plot showing performance every combination parameters. Note: key advantage wSIR SIR parameter robustness. , can see SIR’sperformance deteriorates use larger values slices. However, wSIR’s performance relatively stable vary slices alpha across reasonable values (e.g. among default values optimise ). following plot, metric value becomes smaller increase number slices α=0\\alpha = 0 (corresponds SIR). Performance stable non-zero alpha slice combinations (correspond wSIR).","code":"a <- Sys.time() optim_obj = exploreWSIRParams(exprs = sample1_exprs, coords = sample1_coords, alpha_vals = c(0,.5, 1,2,4,8), slice_vals = c(5,10,15), nrep = 20, metric = \"CD\") ## Time difference of 3.839898 secs ## Time difference of 4.321839 secs ## Time difference of 4.727568 secs ## Time difference of 3.141339 secs ## Time difference of 4.100014 secs ## Time difference of 4.466855 secs ## Time difference of 3.018357 secs ## Time difference of 3.815955 secs ## Time difference of 4.298049 secs ## Time difference of 2.995081 secs ## Time difference of 3.463944 secs ## Time difference of 3.742181 secs ## Time difference of 2.929425 secs ## Time difference of 3.371804 secs ## Time difference of 3.656927 secs ## Time difference of 3.087192 secs ## Time difference of 3.340532 secs ## Time difference of 3.520769 secs Sys.time()-a ## Time difference of 1.106125 mins optim_obj$plot"},{"path":"https://sydneybiox.github.io/wSIR/articles/wSIR_vignette.html","id":"wsir-computation","dir":"Articles","previous_headings":"Supervised dimension reduction with wSIR","what":"wSIR Computation","title":"Weighted Sliced Inverse Regression (WSIR)","text":"next perform wSIR using optimal parameter combination found previous section. use gene expression matrix spatial coordinates sample 1 . returns list results 5 (named) slots, whose details can found ?wSIR::wSIR.","code":"wsir_obj = wSIR(X = sample1_exprs, coords = sample1_coords, slices = optim_obj$best_slices, alpha = optim_obj$best_alpha, optim_params = FALSE) names(wsir_obj) ## [1] \"scores\" \"directions\" \"estd\" \"W\" \"evalues\""},{"path":"https://sydneybiox.github.io/wSIR/articles/wSIR_vignette.html","id":"wsir-results-analysis","dir":"Articles","previous_headings":"","what":"wSIR Results Analysis","title":"Weighted Sliced Inverse Regression (WSIR)","text":"section, demonstrate use built-analysis functions better understand wSIR creates spatially-informed low-dimensional embedding. functions use wSIR result input. , use output previous section, meaning studying result performing wSIR sample 1 .","code":""},{"path":"https://sydneybiox.github.io/wSIR/articles/wSIR_vignette.html","id":"wsir-top-genes","dir":"Articles","previous_headings":"wSIR Results Analysis","what":"wSIR Top Genes","title":"Weighted Sliced Inverse Regression (WSIR)","text":"findTopGenes function finds plots genes highest loading specified wSIR directions (default direction 1). gene high loading (terms magnitude), important wSIR direction. Since wSIR directions designed retain information cell’s spatial position, genes high loading spatially-related genes. plot , can see genes highest loading wSIR direction 1. useful gives us intuition wSIR creates low-dimensional embedding. can see genes known spatial genes (e.g. Cdx2, Hox-), expect see. can simultaneously plot top genes multiple directions, utilise ","code":"top_genes_obj = findTopGenes(WSIR = wsir_obj, highest = 8) # create top genes object top_genes_plot = top_genes_obj$plot # select plot top_genes_plot # print plot top_genes_obj = findTopGenes(WSIR = wsir_obj, highest = 8, dirs = 2:4) top_genes_plot = top_genes_obj$plot top_genes_plot"},{"path":"https://sydneybiox.github.io/wSIR/articles/wSIR_vignette.html","id":"visualising-wsir-scores","dir":"Articles","previous_headings":"wSIR Results Analysis","what":"Visualising wSIR Scores","title":"Weighted Sliced Inverse Regression (WSIR)","text":"visualiseWSIRDirections function plots cell spatial position, coloured value specified wSIR columns. gives us understanding column low-dimensional embedding represents. , visualise cells spatial positions, coloured 5 wSIR directions top left plot illustrates , example, wSIR direction 1 captures information “y” spatial axis, since cells higher “y” coordinate low wSIR1 value, cells lower “y” coordinate higher wSIR1 value. wSIR2 shown next plot (one titled “2”), can see wSIR column two appears capture information “x” spatial coordinate. remaining three wSIR columns contain information cell types, can tell regions high low wSIR column values spread across tissue.","code":"vis_obj = visualiseWSIRDirections(coords = sample1_coords, WSIR = wsir_obj, dirs = 8) # create visualisations vis_obj"},{"path":"https://sydneybiox.github.io/wSIR/articles/wSIR_vignette.html","id":"umap-on-low-dimensional-embedding","dir":"Articles","previous_headings":"wSIR Results Analysis","what":"UMAP on low-dimensional embedding","title":"Weighted Sliced Inverse Regression (WSIR)","text":"two functions generateUmapFromWSIR plotUmapFromWSIR create display UMAP dimension reduction calculated wSIR low-dimensional embedding. can colour UMAP plot (point represents cell) value various genes interest. visualises structure wSIR dimension reduction space, useful gain intuition space represents. Specifically, can see wSIR space contains neighbourhoods high expression specific genes, thus better understanding space made. specify genes like include, can use output findTopGenes function , finds spatially-related genes ranking highest loading relevant wSIR directions. output value highest_genes parameter. Otherwise, also specify genes interest specific genes like visualise. example, wanted visualise expression distribution Cdx2 Hoxb4, use genes = c(\"Cdx2\", \"Hoxb4\") argument plotUmapFromWSIR (leave highest_genes blank). , use UMAP function visualise wSIR space computed gene expression data sample 1. colour cell values 6 genes highest value wSIR direction 1 (found findTopGenes function previously). can see genes, specific regions high expression UMAP plots, suggesting wSIR space separates cells based expression genes.","code":"umap_coords = generateUmapFromWSIR(WSIR = wsir_obj) umap_plots = plotUmapFromWSIR(exprs = sample1_exprs, umap_coords = umap_coords, highest_genes = top_genes_obj, n_genes = 6) umap_plots"},{"path":"https://sydneybiox.github.io/wSIR/articles/wSIR_vignette.html","id":"projection-of-new-data-with-wsir","dir":"Articles","previous_headings":"","what":"Projection of new data with wSIR","title":"Weighted Sliced Inverse Regression (WSIR)","text":"key functionality wSIR package ability project new single-cell data wSIR low-dimensional space. allow low-dimensional representation gene expression data contains information cell’s spatial position even though access spatial coordinates new data. low-dimensional wSIR embedding especially useful downstream applications, like spatial alignment spatial clustering (don’t spatial coordinates). , demonstrate steps , well specific application. projection example, perform wSIR spatial transcriptomics dataset includes gene expression data spatial coordinates. project “single-cell” dataset, contains gene expression matrix, wSIR low-dimensional space.","code":""},{"path":"https://sydneybiox.github.io/wSIR/articles/wSIR_vignette.html","id":"single-sample-spatial-dataset-single-sample-single-cell-dataset","dir":"Articles","previous_headings":"Projection of new data with wSIR","what":"Single-sample spatial dataset, single-sample single-cell dataset","title":"Weighted Sliced Inverse Regression (WSIR)","text":", demonstrate steps project new sample single-cell dataset wSIR low-dimensional space already performed wSIR spatial transcriptomics dataset first sample. already performed wSIR sample 1, project sample 2’s gene expression matrix wSIR low-dimensional space, therefore ability predict sample 2’s (unknown stage) spatial locations. Check dimension sample 2’s low-dimensional gene expression data: Observe sample 2’s low-dimensional gene expression data: low-dimensional gene expression data can used later tasks benefit low-dimensional embedding gene expression data samples, rather just gene expression data.","code":"sample2_low_dim_exprs = projectWSIR(wsir = wsir_obj, newdata = sample2_exprs) dim(sample2_low_dim_exprs) ## [1] 2986 9 head(sample2_low_dim_exprs) ## [,1] [,2] [,3] [,4] [,5] [,6] ## [1,] 1.2044363 -0.3790739 -1.72818610 -1.797653672 -0.8684785 -0.74469382 ## [2,] 0.5738578 0.4719606 0.26341538 -0.341280096 -0.4274574 0.34500227 ## [3,] 1.2749872 -0.8741444 -1.34429322 0.009172746 0.4562988 0.42206043 ## [4,] 1.7326508 -0.3322124 -0.55148621 0.732668048 -0.2272738 0.30675261 ## [5,] 2.1501634 -0.8665235 0.04544417 0.779635209 -0.4277316 0.17938548 ## [6,] 1.2074795 -1.1035173 0.51632770 1.048309253 -1.0852001 -0.01835717 ## [,7] [,8] [,9] ## [1,] 3.437305 0.5718475 -0.4848100 ## [2,] 1.304516 1.7813543 0.6194540 ## [3,] 2.313171 0.0540894 -0.3177639 ## [4,] 2.269962 0.5799911 -1.2385839 ## [5,] 0.899609 1.5397581 0.1789930 ## [6,] 1.244870 0.5720243 0.4845666"},{"path":"https://sydneybiox.github.io/wSIR/articles/wSIR_vignette.html","id":"multi-sample-spatial-dataset-single-sample-single-cell-dataset","dir":"Articles","previous_headings":"Projection of new data with wSIR","what":"Multi-sample spatial dataset, single-sample single-cell dataset","title":"Weighted Sliced Inverse Regression (WSIR)","text":", perform wSIR samples 1 2 together. requires gene expression matrices samples joined together one matrix, coords dataframes joined one dataframe. concatenation using rbind. specify sample IDs row joined expression matrix coordinates dataframe using samples argument. vector “1” row sample 1 “2” row sample 2. use resulting wSIR output project gene expression data sample 3 low-dimensional space. check dimension resulting matrix. low-dimensional matrix can used downstream tasks benefit low-dimensional embedding sample 3’s gene expression matrix contains information cell’s location. Examples downstream use include spatial alignment single-cell spatial gene expression data via Tangram, using wSIR scores input rather (unreduced) gene expression matrix. example simple application using wSIR scores input KNN cell type classification algorithm. demonstrated , using ‘knn’ function ‘class’ package. code, use wSIR scores input simple KNN-based cell type classification tool. print tail prediction vector, demonstrating can use wSIR-based low-dimensional gene expression data new sample step realistic analysis pipeline.","code":"wsir_obj_samples12 <- wSIR(X = rbind(sample1_exprs, sample2_exprs), coords = rbind(sample1_coords, sample2_coords), samples = c(rep(1, nrow(sample1_coords)), rep(2, nrow(sample2_coords))), slices = optim_obj$best_slices, alpha = optim_obj$best_alpha, optim_params = FALSE) sample3_low_dim_exprs <- projectWSIR(wsir = wsir_obj_samples12, newdata = sample3_exprs) dim(sample3_low_dim_exprs) ## [1] 4607 7 samples12_cell_types = append(sample1_cell_types, sample2_cell_types) knn_classification_object = knn(train = wsir_obj_samples12$scores, test = sample3_low_dim_exprs, cl = samples12_cell_types, k = 10) tail(knn_classification_object) ## [1] Presomitic mesoderm Dermomyotome Presomitic mesoderm ## [4] Spinal cord Spinal cord Low quality ## 24 Levels: Allantois Anterior somitic tissues ... Surface ectoderm sessionInfo() ## R version 4.4.1 (2024-06-14) ## Platform: x86_64-pc-linux-gnu ## Running under: Ubuntu 22.04.4 LTS ## ## Matrix products: default ## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 ## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0 ## ## locale: ## [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 ## [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8 ## [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C ## [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C ## ## time zone: UTC ## tzcode source: system (glibc) ## ## attached base packages: ## [1] stats graphics grDevices utils datasets methods base ## ## other attached packages: ## [1] class_7.3-22 umap_0.2.10.0 vctrs_0.6.5 doBy_4.6.22 ## [5] Rfast_2.1.0 RcppParallel_5.1.9 RcppZiggurat_0.1.6 Rcpp_1.0.13 ## [9] ggplot2_3.5.1 magrittr_2.0.3 wSIR_0.1.2 BiocStyle_2.32.1 ## ## loaded via a namespace (and not attached): ## [1] gtable_0.3.5 xfun_0.47 bslib_0.8.0 ## [4] lattice_0.22-6 tools_4.4.1 generics_0.1.3 ## [7] parallel_4.4.1 tibble_3.2.1 fansi_1.0.6 ## [10] highr_0.11 pkgconfig_2.0.3 Matrix_1.7-0 ## [13] desc_1.4.3 lifecycle_1.0.4 farver_2.1.2 ## [16] compiler_4.4.1 textshaping_0.4.0 microbenchmark_1.5.0 ## [19] munsell_0.5.1 codetools_0.2-20 htmltools_0.5.8.1 ## [22] sass_0.4.9 yaml_2.3.10 pillar_1.9.0 ## [25] pkgdown_2.1.0 jquerylib_0.1.4 tidyr_1.3.1 ## [28] MASS_7.3-60.2 openssl_2.2.1 BiocParallel_1.38.0 ## [31] cachem_1.1.0 boot_1.3-30 RSpectra_0.16-2 ## [34] Deriv_4.1.6 tidyselect_1.2.1 digest_0.6.37 ## [37] dplyr_1.1.4 purrr_1.0.2 bookdown_0.40 ## [40] labeling_0.4.3 distances_0.1.11 cowplot_1.1.3 ## [43] fastmap_1.2.0 grid_4.4.1 colorspace_2.1-1 ## [46] cli_3.6.3 utf8_1.2.4 broom_1.0.6 ## [49] withr_3.0.1 scales_1.3.0 backports_1.5.0 ## [52] rmarkdown_2.28 modelr_0.1.11 reticulate_1.39.0 ## [55] askpass_1.2.0 ragg_1.3.3 png_0.1-8 ## [58] evaluate_0.24.0 knitr_1.48 rlang_1.1.4 ## [61] glue_1.7.0 BiocManager_1.30.25 jsonlite_1.8.8 ## [64] R6_2.5.1 systemfonts_1.1.0 fs_1.6.4"},{"path":"https://sydneybiox.github.io/wSIR/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Max Woollard. Author, maintainer, contributor. Pratibha Panwar. Contributor. Linh Nghiem. Author, contributor. Shila Ghazanfar. Author, contributor.","code":""},{"path":"https://sydneybiox.github.io/wSIR/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Woollard M, Nghiem L, Ghazanfar S (2024). wSIR: Weighted Sliced Inverse Regression (WSIR) supervised dimension reduction spatial transcriptomics single cell gene expression data. R package version 0.1.2, https://sydneybiox.github.io/wSIR/, https://sydneybiox.github.io/wSIR.","code":"@Manual{, title = {wSIR: Weighted Sliced Inverse Regression (WSIR) for supervised dimension reduction of spatial transcriptomics and single cell gene expression data}, author = {Max Woollard and Linh Nghiem and Shila Ghazanfar}, year = {2024}, note = {R package version 0.1.2, https://sydneybiox.github.io/wSIR/}, url = {https://sydneybiox.github.io/wSIR}, }"},{"path":"https://sydneybiox.github.io/wSIR/index.html","id":"wsir","dir":"","previous_headings":"","what":"Weighted Sliced Inverse Regression (WSIR) for supervised dimension reduction of spatial transcriptomics and single cell gene expression data","title":"Weighted Sliced Inverse Regression (WSIR) for supervised dimension reduction of spatial transcriptomics and single cell gene expression data","text":"wSIR: Weighted Sliced Inverse Regression supervised dimension reduction spatial transcriptomics single cell gene expression data R package computation wSIR low-dimensional embedding gene expression data, using spatial coordinates. includes functions analyse resulting low-dimensional space, well mapping high-dimensional gene expression data low-dimensional space. function project new gene expression data (spatial coordinates unknown) low-dimensional space ability predict cell’s spatial location. overview method examples, see vignette website.","code":""},{"path":"https://sydneybiox.github.io/wSIR/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Weighted Sliced Inverse Regression (WSIR) for supervised dimension reduction of spatial transcriptomics and single cell gene expression data","text":"{r} library(devtools) install_github(\"SydneyBioX/wSIR\")","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/MouseData.html","id":null,"dir":"Reference","previous_headings":"","what":"MouseGastrulationData — MouseData","title":"MouseGastrulationData — MouseData","text":"Data set consists spatial transcriptomics data mouse embryo. three samples, gene expression data (351 genes), spatial coordinates two-dimensional spatial plane, cell type labels. Sample 1 contains 19451 cells, sample 2 contains 14891 cells sample 3 contains 23194 cells. randomly sampled 20% cells datasets vignette examples stop data large. random sampling, 3848 cells sample 1, 2986 cells sample 2 4607 cells sample 3.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/MouseData.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"MouseGastrulationData — MouseData","text":"sample1_exprs row cell sample 1 column expression level gene. sample1_coords row cell sample 1 column position two spatial axes. sample1_cell_types vector whose 'th entry contains cell type 'th cell sample 1. sample2_exprs row cell sample 2 column expression level gene. sample2_coords row cell sample 2 column position two spatial axes. sample2_cell_types vector whose 'th entry contains cell type 'th cell sample 2. sample3_exprs row cell sample 3 column expression level gene. sample3_coords row cell sample 3 column position two spatial axes. sample3_cell_types vector, whose 'th entry contains cell type 'th cell sample 3.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/MouseData.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"MouseGastrulationData — MouseData","text":"Integration spatial single-cell transcriptomic data elucidates mouse organogenesis, Nature Biotechnology, 2022. Webpage: https://www.nature.com/articles/s41587-021-01006-2","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/createWeightMatrix.html","id":null,"dir":"Reference","previous_headings":"","what":"createWeightMatrix — createWeightMatrix","title":"createWeightMatrix — createWeightMatrix","text":"function create weight matrix given location cells, tile allocations desired spatial weighting strength. Weight matrix entries represent level spatial correlation pairs tiles.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/createWeightMatrix.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"createWeightMatrix — createWeightMatrix","text":"","code":"createWeightMatrix(coords, labels, alpha = 4)"},{"path":"https://sydneybiox.github.io/wSIR/reference/createWeightMatrix.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"createWeightMatrix — createWeightMatrix","text":"coords dataframe dimension n * 2. Column names c(\"x\", \"y\"). Spatial position cell. labels dataframe dimension n * 1, column name c(\"coordinate\"). Tile allocation cell. automatically created wSIR function. alpha numeric value giving strength spatial weighting matrix. alpha = 0 returns identity matrix equals SIR. Large alpha values tend entries towards 1. Default 4.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/createWeightMatrix.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"createWeightMatrix — createWeightMatrix","text":"matrix containing weight value pairs tiles. value 0 1, 1 always diagonal.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/exploreWSIRParams.html","id":null,"dir":"Reference","previous_headings":"","what":"exploreWSIRParams function — exploreWSIRParams","title":"exploreWSIRParams function — exploreWSIRParams","text":"function used select optimal values parameters slices alpha weighted sliced inverse regression based provided gene expression data corresponding spatial coordinates. given evaluation metric, visualise performance WSIR varying function parameters based data, return optimal pair. pair slices alpha can used downstream tasks.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/exploreWSIRParams.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"exploreWSIRParams function — exploreWSIRParams","text":"","code":"exploreWSIRParams( exprs, coords, samples = rep(1, nrow(coords)), alpha_vals = c(0, 2, 4, 10), slice_vals = c(5, 10, 15, 20), varThreshold = 0.95, maxDirections = 50, metric = \"DC\", nrep = 5, param = MulticoreParam(workers = 1) )"},{"path":"https://sydneybiox.github.io/wSIR/reference/exploreWSIRParams.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"exploreWSIRParams function — exploreWSIRParams","text":"exprs matrix containing normalised gene expression data including n cells p genes, dimension n * p. coords dataframe containing spatial positions n cells 2D space. Dimension n * 2. Column names must c(\"x\", \"y\"). samples sample ID cell. total, must length equal number cells. example, dataset 10000 cells, first 5000 sample 1 remaining 5000 sample 2, write samples = c(rep(1, 5000), rep(2, 5000)) specify first 5000 cells sample 1 remaining sample 2. Default cells sample 1. Sample IDs can format: previous example, write samples = c(rep(\"sample 1\", 5000), rep(\"sample 2\", 5000)), result . alpha_vals vector numbers values parameter alpha use WSIR. 0 gives Sliced Inverse Regression (SIR) implementation, larger values represent stronger spatial correlation. Suggest use integers interpretability, can use non-integers. Values must non-negative. slice_vals vector integers values parameter slices use WSIR. Suggest maximum value vector around \\(\\sqrt{n/20}\\), upper bound ensures average least 10 cells per tile training set. varThreshold numeric proportion variance t(X_H) %*% W %*% X_H retain. Must 0 1. Default 0.95. Select higher threshold include dimensions, lower threshold include less dimensions. maxDirections integer maximum number directions include low-dimensional embedding. Default 50. metric evaluation metric use parameter tuning select optimal parameter combination. String, use \"DC\" use distance correlation, \"CD\" use correlation distances, \"ncol\" number dimensions low-dimensional embedding. Default \"DC\". nrep integer number train/test splits data perform. param parallel computing setup bplapply BiocParallel package. Default use single core, hence default value MulticoreParam(workers = 1)","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/exploreWSIRParams.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"exploreWSIRParams function — exploreWSIRParams","text":"List five slots, named \"plot\", \"message\", \"best_alpha\", \"best_slices\" \"results_dataframe\". \"plot\" shows average metric value across nrep iterations every combination parameters slices alpha. Larger circles slices/alpha combination indicates better performance pair values. one panel per evaluation metric selected \"metrics\" argument. \"message\" tells parameter combination highest metric value according selected metric. \"best_alpha\" returns integer best alpha values among values tested according selected metric. \"best_slices\" returns integer best slices value among values tested according selected metric. \"results_dataframe\" returns results dataframe used create \"plot\". dataframe length(alpha_vals)*length(slice_vals) rows, one combination parameters slices alpha. one column \"alpha\", one \"slices\" one evaluation metrics selected \"metrics\" argument. Column \"alpha\" includes value parameter alpha, column \"slices\" includes value parameter slices, metric column includes value specified metric, either Distance Correlation (\"DC\"), Correlation Distances (\"CD\"), number columns low-dimensional embedding (\"ncol\").","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/exploreWSIRParams.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"exploreWSIRParams function — exploreWSIRParams","text":"","code":"data(MouseData) explore_params = exploreWSIRParams(exprs = sample1_exprs, coords = sample1_coords, alpha_vals = c(0,2,4,8), slice_vals = c(3,6,10)) #> Time difference of 1.385958 secs #> Time difference of 0.8637142 secs #> Time difference of 1.163008 secs #> Time difference of 0.8637171 secs #> Time difference of 0.8029561 secs #> Time difference of 1.036409 secs #> Time difference of 0.6865509 secs #> Time difference of 0.7658222 secs #> Time difference of 0.9777613 secs #> Time difference of 0.6980515 secs #> Time difference of 0.7671394 secs #> Time difference of 0.9868422 secs explore_params$plot explore_params$message #> [1] \"Optimal (alpha, slices) pair: (8, 3)\" best_alpha = explore_params$best_alpha best_slices = explore_params$best_slices wsir_obj = wSIR(X = sample1_exprs, coords = sample1_coords, optim_params = FALSE, alpha = best_alpha, slices = best_slices)"},{"path":"https://sydneybiox.github.io/wSIR/reference/findTopGenes.html","id":null,"dir":"Reference","previous_headings":"","what":"findTopGenes — findTopGenes","title":"findTopGenes — findTopGenes","text":"function find visualise genes highest (absolute value) loading WSIR1. genes contribute first low-dimensional direction.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/findTopGenes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"findTopGenes — findTopGenes","text":"","code":"findTopGenes(WSIR, highest = 10, dirs = 1)"},{"path":"https://sydneybiox.github.io/wSIR/reference/findTopGenes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"findTopGenes — findTopGenes","text":"WSIR wsir object output wSIR function. analyse different DR method, ensure slot named 'directions' contains loadings matrix gene names rownames. highest integer many top genes like see. Recommend 20 ease visualisation. Default 10. dirs integer vector direction / directions want show/find top genes .","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/findTopGenes.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"findTopGenes — findTopGenes","text":"List containing two slots. First named \"plot\" shows barplot top genes corresponding loadings. Second named \"genes\" vector genes highest (absolute value) loading low-dimensional direction 1. Length parameter highest.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/findTopGenes.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"findTopGenes — findTopGenes","text":"","code":"data(MouseData) wsir_obj = wSIR(X = sample1_exprs, coords = sample1_coords, optim_params = FALSE, alpha = 4, slices = 6) # create wsir object top_genes_obj = findTopGenes(WSIR = wsir_obj, highest = 8) # create top genes object top_genes_plot = top_genes_obj$plot # select plot top_genes_plot # print plot"},{"path":"https://sydneybiox.github.io/wSIR/reference/generateUmapFromWSIR.html","id":null,"dir":"Reference","previous_headings":"","what":"generateUmapfromWSIR — generateUmapFromWSIR","title":"generateUmapfromWSIR — generateUmapFromWSIR","text":"function generate UMAP coordinates low-dimensional embedding gene expression data. coordinates can later plotted plotUmapFromWSIR function. two functions separate can generate UMAP points using function (may take long time), modify resulting plot much desired plotUmapFromWSIR function.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/generateUmapFromWSIR.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"generateUmapfromWSIR — generateUmapFromWSIR","text":"","code":"generateUmapFromWSIR(WSIR)"},{"path":"https://sydneybiox.github.io/wSIR/reference/generateUmapFromWSIR.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"generateUmapfromWSIR — generateUmapFromWSIR","text":"WSIR wsir object output wSIR function. wish generate UMAP plots based DR methods, ensure slot named \"scores\" WSIR parameter contains low-dimensional representation exprs.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/generateUmapFromWSIR.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"generateUmapfromWSIR — generateUmapFromWSIR","text":"matrix UMAP coordinates dimension nrow(coords) * 2. Output function can directly used input plot_umap function.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/generateUmapFromWSIR.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"generateUmapfromWSIR — generateUmapFromWSIR","text":"","code":"data(MouseData) wsir_obj = wSIR(X = sample1_exprs, coords = sample1_coords, optim_params = FALSE, alpha = 4, slices = 6) # create wsir object umap_coords = generateUmapFromWSIR(WSIR = wsir_obj) top_genes_obj = findTopGenes(WSIR = wsir_obj, highest = 4) # create top genes object umap_plot = plotUmapFromWSIR(umap_coords = umap_coords, exprs = sample1_exprs, highest_genes = top_genes_obj, n_genes = 4) umap_plot"},{"path":"https://sydneybiox.github.io/wSIR/reference/plotUmapFromWSIR.html","id":null,"dir":"Reference","previous_headings":"","what":"plotUmapFromWSIR — plotUmapFromWSIR","title":"plotUmapFromWSIR — plotUmapFromWSIR","text":"function plot UMAP generated low-dimensional embedding gene expression data. points coloured value genes highest (absolute value) loading selected WSIR direction, default WSIR1.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/plotUmapFromWSIR.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"plotUmapFromWSIR — plotUmapFromWSIR","text":"","code":"plotUmapFromWSIR( exprs, umap_coords, highest_genes = NULL, genes = NULL, n_genes, ... )"},{"path":"https://sydneybiox.github.io/wSIR/reference/plotUmapFromWSIR.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"plotUmapFromWSIR — plotUmapFromWSIR","text":"exprs matrix containing normalised gene expression data including n cells p genes, dimension n * p. umap_coords UMAP coordinates cell output generateUmapFromWSIR function. UMAP coordinates can based dimension reduction method, e.g UMAP coordinates computed WSIR dimension reduction gene expression data, PCs (principal components), low-dimensional matrix. Must matrix dimension nrow(exprs) * 2. highest_genes output findTopGenes function. Default NULL error message can easily thrown genes highest_genes provided. genes vector gene names (must colnames(exprs)) wish show UMAP plot. cells plots coloured expression values genes provide . Must provide either genes highest_genes parameter (): provide genes want visualise specific genes, provide highest_genes want visualise genes found important WSIR directions. Default NULL error message can easily thrown genes highest_genes provided. n_genes integer number genes like show. Default number unique genes highest_genes parameter number genes (vector) parameter genes. Use parameter want show important genes (e.g select top 4 n_genes = 4). ... additional parameters ggplot functions, e.g size (size points).","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/plotUmapFromWSIR.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"plotUmapFromWSIR — plotUmapFromWSIR","text":"Grid umap plots n_genes number plots. shows cells UMAP generated low-dimensional gene expression data, coloured value genes found top_genes.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/plotUmapFromWSIR.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"plotUmapFromWSIR — plotUmapFromWSIR","text":"","code":"data(MouseData) wsir_obj = wSIR(X = sample1_exprs, coords = sample1_coords, optim_params = FALSE, alpha = 4, slices = 6) # create wsir object umap_coords = generateUmapFromWSIR(WSIR = wsir_obj) top_genes_obj = findTopGenes(WSIR = wsir_obj, highest = 4) # create top genes object umap_plot = plotUmapFromWSIR(umap_coords = umap_coords, exprs = sample1_exprs, highest_genes = top_genes_obj, n_genes = 4) umap_plot"},{"path":"https://sydneybiox.github.io/wSIR/reference/projectWSIR.html","id":null,"dir":"Reference","previous_headings":"","what":"projectWSIR — projectWSIR","title":"projectWSIR — projectWSIR","text":"function project new gene expression data low-dimensional space","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/projectWSIR.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"projectWSIR — projectWSIR","text":"","code":"projectWSIR(wsir, newdata)"},{"path":"https://sydneybiox.github.io/wSIR/reference/projectWSIR.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"projectWSIR — projectWSIR","text":"wsir wsir object usually output wSIR function. want project new data low-dim space following different DR method, param wsir use list matrix loadings slot 2 (e.g PCA loadings) dimension p * d newdata matrix new gene expression data project low-dimensional space. Must p columns columns X argument used generate wsir.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/projectWSIR.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"projectWSIR — projectWSIR","text":"matrix low-dimensional representation newdata gene expression data","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/projectWSIR.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"projectWSIR — projectWSIR","text":"","code":"data(MouseData) wsir_obj = wSIR(X = sample1_exprs, coords = sample1_coords, optim_params = FALSE, alpha = 4, slices = 6) sample2_low_dim_exprs = projectWSIR(wsir = wsir_obj, newdata = sample2_exprs)"},{"path":"https://sydneybiox.github.io/wSIR/reference/sirCategorical.html","id":null,"dir":"Reference","previous_headings":"","what":"sirCategorical — sirCategorical","title":"sirCategorical — sirCategorical","text":"function performs WSIR based provided gene expression data, tile allocations, weight matrix.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/sirCategorical.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"sirCategorical — sirCategorical","text":"","code":"sirCategorical(X, Y, directions = 50, W = NULL, varThreshold = 0.95)"},{"path":"https://sydneybiox.github.io/wSIR/reference/sirCategorical.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"sirCategorical — sirCategorical","text":"X matrix normalised gene expression data n genes across p cells. Y dataframe 1 column named \"coordinate\" tile allocation cell. slices^2 unique tile IDs column. directions Integer specify maximum number directions retain thee low-dimensional embedding data. Use need certain number downstream task. W Weight matrix created createWeightMatrix. Entry (,j) represents spatial correlation level tiles j. diagonal values 1. provided, SIR implementation used. varThreshold numeric value specifying desired proportion variance retain. e.g 95% (default), number directions used eigenvalues add 95% sum eigenvalues.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/sirCategorical.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"sirCategorical — sirCategorical","text":"list outputs 5 named slots. output wSIR function: final step wSIR function.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/sirPCA.html","id":null,"dir":"Reference","previous_headings":"","what":"sirPCA — sirPCA","title":"sirPCA — sirPCA","text":"function performs eigendecomposition (X^H)^t %% W %% (X^H), X^H matrix scaled slice means.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/sirPCA.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"sirPCA — sirPCA","text":"","code":"sirPCA( sliced_data, directions, W = diag(nrow(sliced_data)), varThreshold = 0.95 )"},{"path":"https://sydneybiox.github.io/wSIR/reference/sirPCA.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"sirPCA — sirPCA","text":"sliced_data matrix scaled slice means directions integer, number directions want final low-dimensional Z. W matrix slice weights. Output createWeightMatrix function. varThreshold numeric proportion eigenvalues variance t(X_H) %% W %% X_H retain. Default 0.95. Select higher threshold include dimensions, lower threshold include less dimensions.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/sirPCA.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"sirPCA — sirPCA","text":"list containing: 1) \"eigenvectors\" matrix eigenvectors (X^H)^t %% W %% (X^H) 2) \"d\" integer, selected number dimensions 3) \"evalues\" vector eigenvalues (X^H)^t %% W %% (X^H)","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/slicerCategorical.html","id":null,"dir":"Reference","previous_headings":"","what":"slicerCategorical — slicerCategorical","title":"slicerCategorical — slicerCategorical","text":"function averages columns X matrix category single-column Y dataframe. used find average position within tile create weight matrix, well create tile means used eigendecomposition step SIR/wSIR.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/slicerCategorical.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"slicerCategorical — slicerCategorical","text":"","code":"slicerCategorical(X, Y)"},{"path":"https://sydneybiox.github.io/wSIR/reference/slicerCategorical.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"slicerCategorical — slicerCategorical","text":"X matrix dataframe containing columns average Y dataframe single column named 'coordinate'. column contains categorical variable tile ID cell.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/slicerCategorical.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"slicerCategorical — slicerCategorical","text":"dataframe containing averages column within category Y. Dimension h * p, h number categories Y p number columns X.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/spatialAllocator.html","id":null,"dir":"Reference","previous_headings":"","what":"spatialAllocator — spatialAllocator","title":"spatialAllocator — spatialAllocator","text":"function allocates cell tile based specified number tiles.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/spatialAllocator.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"spatialAllocator — spatialAllocator","text":"","code":"spatialAllocator(coords, slices = 3)"},{"path":"https://sydneybiox.github.io/wSIR/reference/spatialAllocator.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"spatialAllocator — spatialAllocator","text":"coords dataframe contains spatial position cell. Column names c(\"x\", \"y'). Must include row names integer 1 nrow(coords). automatically included wSIR function prior function. slices integer number slices along two spatial axes. number tiles slices^2 since two spatial axes. E.g set slices = 4 use 4^2 = 16 tiles. Default value 3.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/spatialAllocator.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"spatialAllocator — spatialAllocator","text":"output matrix containing slice belonging axis long format. used lapply(coords_split, spatialAllocator, slices) wSIR output dataframe cell's tile allocation \"coordinate\" column.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/visualiseWSIRDirections.html","id":null,"dir":"Reference","previous_headings":"","what":"visualiseWSIRDirections — visualiseWSIRDirections","title":"visualiseWSIRDirections — visualiseWSIRDirections","text":"function easily visualise low-dimensional gene expression data. function plots cell true spatial coordinates, coloured values WSIR1 / WSIR2 / ... . plots give intuition biological signals contained WSIR directions.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/visualiseWSIRDirections.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"visualiseWSIRDirections — visualiseWSIRDirections","text":"","code":"visualiseWSIRDirections( coords, WSIR, dirs = 6, mincol = \"blue\", maxcol = \"red\" )"},{"path":"https://sydneybiox.github.io/wSIR/reference/visualiseWSIRDirections.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"visualiseWSIRDirections — visualiseWSIRDirections","text":"coords dataframe containing spatial positions n cells 2D space. Dimension n * 2. Column names must c(\"x\", \"y\"). WSIR wsir object output wSIR function. analyse different DR method, ensure slot named 'directions' contains loadings matrix gene names rownames. Must used coords parameter coords parameter function. dirs integer many low-dimensional directions like visualise. Recommend 10 ease visualisation. Default 6. mincol String colour low values low-dimensional directions. Personal choice user, default \"blue\". maxcol String colour high values low-dimensional directions. Personal choice user, default \"red\".","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/visualiseWSIRDirections.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"visualiseWSIRDirections — visualiseWSIRDirections","text":"Grid plots dirs number plots. shows cells spatial positions coloured value first 'dirs' WSIR directions.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/visualiseWSIRDirections.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"visualiseWSIRDirections — visualiseWSIRDirections","text":"","code":"data(MouseData) wsir_obj = wSIR(X = sample1_exprs, coords = sample1_coords, optim_params = FALSE, alpha = 4, slices = 6) # create wsir object vis_obj = visualiseWSIRDirections(coords = sample1_coords, WSIR = wsir_obj, dirs = 8) # create visualisations vis_obj"},{"path":"https://sydneybiox.github.io/wSIR/reference/wSIR.html","id":null,"dir":"Reference","previous_headings":"","what":"wSIR — wSIR","title":"wSIR — wSIR","text":"function perform supervised dimension reduction gene expression matrix using coordinates dataframe response value. Incorporates weighting mechanism SIR algorithm generate low-dimensional representation data allow projection new single-cell gene expression data low-dimensional space.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/wSIR.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"wSIR — wSIR","text":"","code":"wSIR( X, coords, samples = rep(1, nrow(coords)), slices = 8, alpha = 4, maxDirections = 50, varThreshold = 0.95, optim_params = TRUE, alpha_vals = c(0, 1, 2, 4, 8, 12), slice_vals = c(3, 5, 7, 10, 15, 20), metric = \"DC\", nrep = 5 )"},{"path":"https://sydneybiox.github.io/wSIR/reference/wSIR.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"wSIR — wSIR","text":"X matrix containing normalised gene expression data including n cells p genes, dimension n * p. coords dataframe containing spatial positions n cells 2D space. Dimension n * 2. Column names must c(\"x\", \"y\"). samples sample ID cell. total, must length equal number cells. example, dataset 10000 cells, first 5000 sample 1 remaining 5000 sample 2, write samples = c(rep(1, 5000), rep(2, 5000)) specify first 5000 cells sample 1 remaining sample 2. Default cells sample 1. Sample IDs can format: previous example, write samples = c(rep(\"sample 1\", 5000), rep(\"sample 2\", 5000)), result . slices integer number slices axis tissue. example, slices = 4 creates 4 slices along spatial axis, yielding 4^2 = 16 tiles. Default 8, suggested minimum 3. Suggest tune parameter. alpha integer specify desired strength spatial correlation. Suggest tune parameter testing dataset among e.g values c(0,2,4,8). alpha = 0 gives SIR implementation. Larger values give stronger spatial correlations. maxDirections integer upper limit number directions include low-dimensional space. Use need less certain number dimensions downstream analyes varThreshold numeric proportion eigenvalues variance t(X_H) %% W %% X_H retain. Default 0.95. Select higher threshold include dimensions, lower threshold include less dimensions. optim_params logical, like wSIR automatically optimise parameters slices alpha based either distance correlation correlation distances evaluation metric. Default TRUE. downstream task quite different either metrics, suggest tune two parameters using specific task evaluation metric. case, determine optimal slices alpha values use relevant function, setting optim_params = FALSE. alpha_vals optim_params = TRUE, values alpha optimise WSIR. 0 gives Sliced Inverse Regression (SIR) implementation, larger values represent stronger spatial correlation. Suggest use integers interpretability, can use non-integers. Values must non-negative. slice_vals optim_params = TRUE, values slices optimise WSIR. Suggest maximum value vector around \\(\\sqrt{n/20}\\), upper bound ensures average least 10 cells per tile training set. metric optim_params = TRUE, evaluation metric use parameter tuning. String, either \"DC\" use distance correlation \"CD\" use correlation distances. Default \"DC\". nrep optim_params = TRUE, integer number train/test splits data perform optimisation parameters slices alpha.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/wSIR.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"wSIR — wSIR","text":"wSIR object list containing 5 (named) positions. 1) scores matrix containing low-dimensional representation X wSIR algorithm. Dimension n * d, d chosen include least varThreshold proportion variance. 2) directions matrix containing WSIR directions, dimension p * d. Use project new data low-dimensional space via X_new %% directions. 3) estd integer stating many dimensions computed low-dimensional space needed account varThreshold proportion variance. number dimensions scores. 4) W matrix weight matrix cells_weight_matrix2 function 5) evalues vector containing p eigenvalues t(X_H) %% W %*% X_H. varThreshold parameter works evalues, e.g first j directions included sum first j evalues equals 0.95% sum evalues.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/wSIR.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"wSIR — wSIR","text":"","code":"data(MouseData) wsir_obj = wSIR(X = sample1_exprs, coords = sample1_coords, optim_params = TRUE, alpha_vals = c(0,2,4), slice_vals = c(3,6,10), metric = \"CD\", nrep = 1) # create wsir object #> Time difference of 0.1331813 secs #> Time difference of 0.1904442 secs #> Time difference of 0.2245536 secs #> Time difference of 0.1569602 secs #> Time difference of 0.183991 secs #> Time difference of 0.1858559 secs #> Time difference of 0.1477439 secs #> Time difference of 0.1676126 secs #> Time difference of 0.1930985 secs"},{"path":"https://sydneybiox.github.io/wSIR/reference/wSIROptimisation.html","id":null,"dir":"Reference","previous_headings":"","what":"wSIROptimisation — wSIROptimisation","title":"wSIROptimisation — wSIROptimisation","text":"function used calculate validation metric best tuning parameters selected","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/wSIROptimisation.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"wSIROptimisation — wSIROptimisation","text":"","code":"wSIROptimisation( exprs_train, coords_train, exprs_test, coords_test, samples_train, slices, alpha, maxDirections, varThreshold, metrics = c(\"CD\", \"DC\", \"ncol\") )"},{"path":"https://sydneybiox.github.io/wSIR/reference/wSIROptimisation.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"wSIROptimisation — wSIROptimisation","text":"exprs_train matrix normalised gene expression training data. coords_train dataframe containing spatial positions cells 2D space validation data. Dimension n * 2. Column names must c(\"x\", \"y\"). exprs_test matrix normalised gene expression validation data. samples_train sample ID cell training data. total, must length equal number cells. example, dataset 10000 cells, first 5000 sample 1 remaining 5000 sample 2, write samples = c(rep(1, 5000), rep(2, 5000)) specify first 5000 cells sample 1 remaining sample 2. Default cells sample 1. Sample IDs can format: previous example, write samples = c(rep(\"sample 1\", 5000), rep(\"sample 2\", 5000)), result . slices integer number slices axis tissue. example, slices = 4 creates 4 slices along spatial axis, yielding 4^2 = 16 tiles. Default 8, suggested minimum 3. Suggest tune parameter using exploreWSIRParams() function. alpha integer specify desired strength spatial correlation. alpha = 0 gives SIR implementation. Larger values give stronger spatial correlations. Default value 4, weight matrix value pair tiles inversely proportional physical distance . Suggest tune parameter using exploreWSIRParams() function. maxDirections integer maximum number directions include low-dimenensional embedding. Default 50. varThreshold numeric proportion variance t(X_H) %*% W %*% X_H retain. Must 0 1. Default 0.95. Select higher threshold include dimensions, lower threshold include less dimensions. metrics evaluation metrics use parameter tuning. String, options : \"DC\" use distance correlation; \"CD\" use correlation distances; \"ncol\" use number columns low-dimensional embedding. Default three, specified metrics = c(\"DC\", \"CD\", \"ncol\").","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/wSIROptimisation.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"wSIROptimisation — wSIROptimisation","text":"Average metric value selected metric(s) train/test split.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/wSIRSpecifiedParams.html","id":null,"dir":"Reference","previous_headings":"","what":"wSIR_specified_params — wSIRSpecifiedParams","title":"wSIR_specified_params — wSIRSpecifiedParams","text":"wSIR function specified parameters alpha, slices. ued internally wSIROptimisation wSIR functions, specific values alpha slices.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/wSIRSpecifiedParams.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"wSIR_specified_params — wSIRSpecifiedParams","text":"","code":"wSIRSpecifiedParams( X, coords, samples = rep(1, nrow(coords)), slices = 8, alpha = 4, maxDirections = 50, varThreshold = 0.95 )"},{"path":"https://sydneybiox.github.io/wSIR/reference/wSIRSpecifiedParams.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"wSIR_specified_params — wSIRSpecifiedParams","text":"X matrix containing normalised gene expression data including n cells p genes, dimension n * p. coords dataframe containing spatial positions n cells 2D space. Dimension n * 2. Column names must c(\"x\", \"y\"). samples sample ID cell. total, must length equal number cells. example, dataset 10000 cells, first 5000 sample 1 remaining 5000 sample 2, write samples = c(rep(1, 5000), rep(2, 5000)) specify first 5000 cells sample 1 remaining sample 2. Default cells sample 1. Sample IDs can format: previous example, write samples = c(rep(\"sample 1\", 5000), rep(\"sample 2\", 5000)), result . slices integer number slices axis tissue. example, slices = 4 creates 4 slices along spatial axis, yielding 4^2 = 16 tiles. Default 8, suggested minimum 3. Suggest tune parameter. alpha integer specify desired strength spatial correlation. Suggest tune parameter testing dataset among e.g values c(0,2,4,8). alpha = 0 gives SIR implementation. Larger values give stronger spatial correlations. maxDirections integer upper limit number directions include low-dimensional space. Use need less certain number dimensions downstream analyes varThreshold numeric proportion eigenvalues variance t(X_H) %% W %% X_H retain. Default 0.95. Select higher threshold include dimensions, lower threshold include less dimensions.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/wSIRSpecifiedParams.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"wSIR_specified_params — wSIRSpecifiedParams","text":"wSIR object list containing 5 (named) positions. 1) scores matrix containing low-dimensional representation X wSIR algorithm. Dimension n * d, d chosen include least varThreshold proportion variance. 2) directions matrix containing WSIR directions, dimension p * d. Use project new data low-dimensional space via X_new %% directions. 3) estd integer stating many dimensions computed low-dimensional space needed account varThreshold proportion variance. number dimensions scores. 4) W matrix weight matrix createWeightMatrix function 5) evalues vector containing p eigenvalues t(X_H) %% W %*% X_H. varThreshold parameter works evalues, e.g first j directions included sum first j evalues equals 0.95% sum evalues.","code":""}] +[{"path":"https://sydneybiox.github.io/wSIR/articles/wSIR_vignette.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Weighted Sliced Inverse Regression (WSIR)","text":"Weighted Sliced Inverse Regression (wSIR) supervised dimension reduction technique spatial transcriptomics data. method uses cell’s gene expression values covariates spatial position response. allows us create low-dimensional representation gene expression data retains information spatial patterns present gene expression data. resulting mapping gene expression data spatially aware low-dimensional embedding can used project new single-cell gene expression data low-dimensional space preserves ability predict cell’s spatial location low-dimensional embedding.","code":""},{"path":"https://sydneybiox.github.io/wSIR/articles/wSIR_vignette.html","id":"method-overview","dir":"Articles","previous_headings":"Introduction","what":"Method Overview","title":"Weighted Sliced Inverse Regression (WSIR)","text":"wSIR extension supervised dimension reduction technique Sliced Inverse Regression (SIR). SIR existing supervised dimension reduction method works grouping together observations similar values response. spatial transcriptomics data, means grouping cells certain number tiles based spatial position. example, use 4 tiles, cells top right quadrant image/tissue go one group, top left another, . groups summarised averaging expression level cells group genes. , eigendecomposition performed resulting matrix tile-gene means, returning SIR directions SIR scores. motivation behind wSIR SIR uses cell’s spatial position separating cells given number groups/tiles. groups created, lose fact groups may spatially related (come adjacent tiles) groups (come opposite sides tissue). wSIR uses weight matrix incorporate spatial correlation pairs cells SIR algorithm. matrix dimension H*H, H number tiles, (,j)th entry represents distance tiles j. matrix incorporated eigendeomposition step. wSIR output structure SIR output.","code":""},{"path":"https://sydneybiox.github.io/wSIR/articles/wSIR_vignette.html","id":"vignette-overview","dir":"Articles","previous_headings":"Introduction","what":"Vignette Overview","title":"Weighted Sliced Inverse Regression (WSIR)","text":"vignette, demonstrate use WSIR obtain low-dimensional embedding gene expression data. explore embedding using package’s built-functions. However, low-dimensional matrix importantly used downstream tasks benefit lower-dimensional representation gene expression data preserves information cell’s spatial location. perform basic downstream analysis demonstrate practicality wSIR.","code":""},{"path":"https://sydneybiox.github.io/wSIR/articles/wSIR_vignette.html","id":"data","dir":"Articles","previous_headings":"","what":"Data","title":"Weighted Sliced Inverse Regression (WSIR)","text":"use data Lohoff et al, 2021. code allow download mouse data using MouseGastrulationData scran R packages. randomly sample 20% cells three biological replicate samples. vignette examples function wSIR, simply load data already saved data/MouseData.rda.","code":"# Packages needed to download data #library(scran) # for logNormCounts #library(MouseGastrulationData) # to download the data for this vignette set.seed(2024) seqfish_data_sample1 <- LohoffSeqFISHData(samples = c(1,2)) seqfish_data_sample1 = logNormCounts(seqfish_data_sample1) # log transform variance stabilising rownames(seqfish_data_sample1) <- rowData(seqfish_data_sample1)[,\"SYMBOL\"] # change rownames to gene symbols that are consistent sample1_exprs = t(assay(seqfish_data_sample1, \"logcounts\")) # extract matrix of gene expressions sample1_coords = spatialCoords(seqfish_data_sample1)[,1:2] %>% as.data.frame() colnames(sample1_coords) = c(\"x\", \"y\") seqfish_data_sample2 <- LohoffSeqFISHData(samples = c(3,4)) seqfish_data_sample2 = logNormCounts(seqfish_data_sample2) rownames(seqfish_data_sample2) <- rowData(seqfish_data_sample2)[,\"SYMBOL\"] sample2_exprs = t(assay(seqfish_data_sample2, \"logcounts\")) sample2_coords = spatialCoords(seqfish_data_sample2)[,1:2] %>% as.data.frame() colnames(sample2_coords) = c(\"x\", \"y\") seqfish_data_sample3 <- LohoffSeqFISHData(samples = c(5,6)) seqfish_data_sample3 = logNormCounts(seqfish_data_sample3) rownames(seqfish_data_sample3) <- rowData(seqfish_data_sample3)[,\"SYMBOL\"] sample3_exprs = t(assay(seqfish_data_sample3, \"logcounts\")) sample3_coords = spatialCoords(seqfish_data_sample3)[,1:2] %>% as.data.frame() colnames(sample3_coords) = c(\"x\", \"y\") keep1 = sample(c(TRUE, FALSE), nrow(sample1_exprs), replace = TRUE, prob = c(0.2, 0.8)) keep2 = sample(c(TRUE, FALSE), nrow(sample2_exprs), replace = TRUE, prob = c(0.2, 0.8)) keep3 = sample(c(TRUE, FALSE), nrow(sample3_exprs), replace = TRUE, prob = c(0.2, 0.8)) sample1_exprs = sample1_exprs[keep1,] sample1_coords = sample1_coords[keep1,] sample2_exprs = sample2_exprs[keep2,] sample2_coords = sample2_coords[keep2,] sample3_exprs = sample3_exprs[keep3,] sample3_coords = sample3_coords[keep3,] sample1_cell_types = seqfish_data_sample1$celltype[keep1] sample2_cell_types = seqfish_data_sample2$celltype[keep2] sample3_cell_types = seqfish_data_sample3$celltype[keep3] save(sample1_exprs, sample1_coords, sample1_cell_types, sample2_exprs, sample2_coords, sample2_cell_types, sample3_exprs, sample3_coords, sample3_cell_types, file = \"../data/MouseData.rda\", compress = \"xz\") data(MouseData)"},{"path":[]},{"path":"https://sydneybiox.github.io/wSIR/articles/wSIR_vignette.html","id":"parameter-study","dir":"Articles","previous_headings":"Supervised dimension reduction with wSIR","what":"Parameter Study","title":"Weighted Sliced Inverse Regression (WSIR)","text":"wSIR contains two parameters, alpha slices. Parameter slices number groups along spatial axis split observations wSIR algorithm. slices means pick spatial information gene expression data, risk overfitting training set. Parameter alpha modifies strength weight matrix. alpha = 0 equivalent spatial weighting, meaning weight matrix becomes identity matrix. equivalent SIR. Larger alpha values means weight given spatial correlation rather gene expression differences alone computation wSIR directions. function exploreWSIRParams performs wSIR many choices alpha slices identify appropriate parameters moving forward. , use sample 1 . parameters tuned reasonable values. function exploreWSIRParams computes visualises performance wSIR given combinations slices alpha. performance computed following procedure: 1) combination slices alpha, split data 50% train 50% test (train test halves include gene expression data cell coordinates). 2) Perform wSIR training set using current combination slices alpha. 3) Project gene expression data testing set low-dimensional space using wSIR results step 2. 4) Evaluate wSIR’s performance computing either distance correlation (“DC”, default), correlation distances (“CD”) projected gene expression data test set test coordinates, according parameter metric. 5) Repeat steps 2-4 done nrep times (nrep parameter whose default 5). Calculate average metric value nrep iterations combination slices alpha. 6) Repeat steps 1-5 combinations slices alpha obtain average metric value combination. 7) Return combination slices alpha highest average metric value display plot showing performance every combination parameters. Note: key advantage wSIR SIR parameter robustness. , can see SIR’sperformance deteriorates use larger values slices. However, wSIR’s performance relatively stable vary slices alpha across reasonable values (e.g. among default values optimise ). following plot, metric value becomes smaller increase number slices α=0\\alpha = 0 (corresponds SIR). Performance stable non-zero alpha slice combinations (correspond wSIR).","code":"a <- Sys.time() optim_obj = exploreWSIRParams(exprs = sample1_exprs, coords = sample1_coords, alpha_vals = c(0,.5, 1,2,4,8), slice_vals = c(5,10,15), nrep = 20, metric = \"CD\") ## Time difference of 3.932933 secs ## Time difference of 4.387144 secs ## Time difference of 4.493731 secs ## Time difference of 3.365411 secs ## Time difference of 4.19184 secs ## Time difference of 4.502382 secs ## Time difference of 3.462631 secs ## Time difference of 4.207857 secs ## Time difference of 4.237237 secs ## Time difference of 2.842625 secs ## Time difference of 3.465169 secs ## Time difference of 3.73744 secs ## Time difference of 2.925163 secs ## Time difference of 3.187351 secs ## Time difference of 3.667856 secs ## Time difference of 2.88185 secs ## Time difference of 3.170469 secs ## Time difference of 3.585481 secs Sys.time()-a ## Time difference of 1.113478 mins optim_obj$plot"},{"path":"https://sydneybiox.github.io/wSIR/articles/wSIR_vignette.html","id":"wsir-computation","dir":"Articles","previous_headings":"Supervised dimension reduction with wSIR","what":"wSIR Computation","title":"Weighted Sliced Inverse Regression (WSIR)","text":"next perform wSIR using optimal parameter combination found previous section. use gene expression matrix spatial coordinates sample 1 . returns list results 5 (named) slots, whose details can found ?wSIR::wSIR.","code":"wsir_obj = wSIR(X = sample1_exprs, coords = sample1_coords, slices = optim_obj$best_slices, alpha = optim_obj$best_alpha, optim_params = FALSE) names(wsir_obj) ## [1] \"scores\" \"directions\" \"estd\" \"W\" \"evalues\""},{"path":"https://sydneybiox.github.io/wSIR/articles/wSIR_vignette.html","id":"wsir-results-analysis","dir":"Articles","previous_headings":"","what":"wSIR Results Analysis","title":"Weighted Sliced Inverse Regression (WSIR)","text":"section, demonstrate use built-analysis functions better understand wSIR creates spatially-informed low-dimensional embedding. functions use wSIR result input. , use output previous section, meaning studying result performing wSIR sample 1 .","code":""},{"path":"https://sydneybiox.github.io/wSIR/articles/wSIR_vignette.html","id":"wsir-top-genes","dir":"Articles","previous_headings":"wSIR Results Analysis","what":"wSIR Top Genes","title":"Weighted Sliced Inverse Regression (WSIR)","text":"findTopGenes function finds plots genes highest loading specified wSIR directions (default direction 1). gene high loading (terms magnitude), important wSIR direction. Since wSIR directions designed retain information cell’s spatial position, genes high loading spatially-related genes. plot , can see genes highest loading wSIR direction 1. useful gives us intuition wSIR creates low-dimensional embedding. can see genes known spatial genes (e.g. Cdx2, Hox-), expect see. can simultaneously plot top genes multiple directions, utilise ","code":"top_genes_obj = findTopGenes(WSIR = wsir_obj, highest = 8) # create top genes object top_genes_plot = top_genes_obj$plot # select plot top_genes_plot # print plot top_genes_obj = findTopGenes(WSIR = wsir_obj, highest = 8, dirs = 2:4) top_genes_plot = top_genes_obj$plot top_genes_plot"},{"path":"https://sydneybiox.github.io/wSIR/articles/wSIR_vignette.html","id":"visualising-wsir-scores","dir":"Articles","previous_headings":"wSIR Results Analysis","what":"Visualising wSIR Scores","title":"Weighted Sliced Inverse Regression (WSIR)","text":"visualiseWSIRDirections function plots cell spatial position, coloured value specified wSIR columns. gives us understanding column low-dimensional embedding represents. , visualise cells spatial positions, coloured 5 wSIR directions top left plot illustrates , example, wSIR direction 1 captures information “y” spatial axis, since cells higher “y” coordinate low wSIR1 value, cells lower “y” coordinate higher wSIR1 value. wSIR2 shown next plot (one titled “2”), can see wSIR column two appears capture information “x” spatial coordinate. remaining three wSIR columns contain information cell types, can tell regions high low wSIR column values spread across tissue.","code":"vis_obj = visualiseWSIRDirections(coords = sample1_coords, WSIR = wsir_obj, dirs = 8) # create visualisations vis_obj"},{"path":"https://sydneybiox.github.io/wSIR/articles/wSIR_vignette.html","id":"umap-on-low-dimensional-embedding","dir":"Articles","previous_headings":"wSIR Results Analysis","what":"UMAP on low-dimensional embedding","title":"Weighted Sliced Inverse Regression (WSIR)","text":"two functions generateUmapFromWSIR plotUmapFromWSIR create display UMAP dimension reduction calculated wSIR low-dimensional embedding. can colour UMAP plot (point represents cell) value various genes interest. visualises structure wSIR dimension reduction space, useful gain intuition space represents. Specifically, can see wSIR space contains neighbourhoods high expression specific genes, thus better understanding space made. specify genes like include, can use output findTopGenes function , finds spatially-related genes ranking highest loading relevant wSIR directions. output value highest_genes parameter. Otherwise, also specify genes interest specific genes like visualise. example, wanted visualise expression distribution Cdx2 Hoxb4, use genes = c(\"Cdx2\", \"Hoxb4\") argument plotUmapFromWSIR (leave highest_genes blank). , use UMAP function visualise wSIR space computed gene expression data sample 1. colour cell values 6 genes highest value wSIR direction 1 (found findTopGenes function previously). can see genes, specific regions high expression UMAP plots, suggesting wSIR space separates cells based expression genes.","code":"umap_coords = generateUmapFromWSIR(WSIR = wsir_obj) umap_plots = plotUmapFromWSIR(exprs = sample1_exprs, umap_coords = umap_coords, highest_genes = top_genes_obj, n_genes = 6) umap_plots"},{"path":"https://sydneybiox.github.io/wSIR/articles/wSIR_vignette.html","id":"projection-of-new-data-with-wsir","dir":"Articles","previous_headings":"","what":"Projection of new data with wSIR","title":"Weighted Sliced Inverse Regression (WSIR)","text":"key functionality wSIR package ability project new single-cell data wSIR low-dimensional space. allow low-dimensional representation gene expression data contains information cell’s spatial position even though access spatial coordinates new data. low-dimensional wSIR embedding especially useful downstream applications, like spatial alignment spatial clustering (don’t spatial coordinates). , demonstrate steps , well specific application. projection example, perform wSIR spatial transcriptomics dataset includes gene expression data spatial coordinates. project “single-cell” dataset, contains gene expression matrix, wSIR low-dimensional space.","code":""},{"path":"https://sydneybiox.github.io/wSIR/articles/wSIR_vignette.html","id":"single-sample-spatial-dataset-single-sample-single-cell-dataset","dir":"Articles","previous_headings":"Projection of new data with wSIR","what":"Single-sample spatial dataset, single-sample single-cell dataset","title":"Weighted Sliced Inverse Regression (WSIR)","text":", demonstrate steps project new sample single-cell dataset wSIR low-dimensional space already performed wSIR spatial transcriptomics dataset first sample. already performed wSIR sample 1, project sample 2’s gene expression matrix wSIR low-dimensional space, therefore ability predict sample 2’s (unknown stage) spatial locations. Check dimension sample 2’s low-dimensional gene expression data: Observe sample 2’s low-dimensional gene expression data: low-dimensional gene expression data can used later tasks benefit low-dimensional embedding gene expression data samples, rather just gene expression data.","code":"sample2_low_dim_exprs = projectWSIR(wsir = wsir_obj, newdata = sample2_exprs) dim(sample2_low_dim_exprs) ## [1] 2986 9 head(sample2_low_dim_exprs) ## [,1] [,2] [,3] [,4] [,5] [,6] ## [1,] 1.2044363 -0.3790739 -1.72818610 -1.797653672 -0.8684785 -0.74469382 ## [2,] 0.5738578 0.4719606 0.26341538 -0.341280096 -0.4274574 0.34500227 ## [3,] 1.2749872 -0.8741444 -1.34429322 0.009172746 0.4562988 0.42206043 ## [4,] 1.7326508 -0.3322124 -0.55148621 0.732668048 -0.2272738 0.30675261 ## [5,] 2.1501634 -0.8665235 0.04544417 0.779635209 -0.4277316 0.17938548 ## [6,] 1.2074795 -1.1035173 0.51632770 1.048309253 -1.0852001 -0.01835717 ## [,7] [,8] [,9] ## [1,] 3.437305 0.5718475 -0.4848100 ## [2,] 1.304516 1.7813543 0.6194540 ## [3,] 2.313171 0.0540894 -0.3177639 ## [4,] 2.269962 0.5799911 -1.2385839 ## [5,] 0.899609 1.5397581 0.1789930 ## [6,] 1.244870 0.5720243 0.4845666"},{"path":"https://sydneybiox.github.io/wSIR/articles/wSIR_vignette.html","id":"multi-sample-spatial-dataset-single-sample-single-cell-dataset","dir":"Articles","previous_headings":"Projection of new data with wSIR","what":"Multi-sample spatial dataset, single-sample single-cell dataset","title":"Weighted Sliced Inverse Regression (WSIR)","text":", perform wSIR samples 1 2 together. requires gene expression matrices samples joined together one matrix, coords dataframes joined one dataframe. concatenation using rbind. specify sample IDs row joined expression matrix coordinates dataframe using samples argument. vector “1” row sample 1 “2” row sample 2. use resulting wSIR output project gene expression data sample 3 low-dimensional space. check dimension resulting matrix. low-dimensional matrix can used downstream tasks benefit low-dimensional embedding sample 3’s gene expression matrix contains information cell’s location. Examples downstream use include spatial alignment single-cell spatial gene expression data via Tangram, using wSIR scores input rather (unreduced) gene expression matrix. example simple application using wSIR scores input KNN cell type classification algorithm. demonstrated , using ‘knn’ function ‘class’ package. code, use wSIR scores input simple KNN-based cell type classification tool. print tail prediction vector, demonstrating can use wSIR-based low-dimensional gene expression data new sample step realistic analysis pipeline.","code":"wsir_obj_samples12 <- wSIR(X = rbind(sample1_exprs, sample2_exprs), coords = rbind(sample1_coords, sample2_coords), samples = c(rep(1, nrow(sample1_coords)), rep(2, nrow(sample2_coords))), slices = optim_obj$best_slices, alpha = optim_obj$best_alpha, optim_params = FALSE) sample3_low_dim_exprs <- projectWSIR(wsir = wsir_obj_samples12, newdata = sample3_exprs) dim(sample3_low_dim_exprs) ## [1] 4607 7 samples12_cell_types = append(sample1_cell_types, sample2_cell_types) knn_classification_object = knn(train = wsir_obj_samples12$scores, test = sample3_low_dim_exprs, cl = samples12_cell_types, k = 10) tail(knn_classification_object) ## [1] Presomitic mesoderm Dermomyotome Presomitic mesoderm ## [4] Spinal cord Spinal cord Low quality ## 24 Levels: Allantois Anterior somitic tissues ... Surface ectoderm sessionInfo() ## R version 4.4.1 (2024-06-14) ## Platform: x86_64-pc-linux-gnu ## Running under: Ubuntu 22.04.4 LTS ## ## Matrix products: default ## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 ## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0 ## ## locale: ## [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 ## [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8 ## [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C ## [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C ## ## time zone: UTC ## tzcode source: system (glibc) ## ## attached base packages: ## [1] stats graphics grDevices utils datasets methods base ## ## other attached packages: ## [1] class_7.3-22 umap_0.2.10.0 vctrs_0.6.5 doBy_4.6.22 ## [5] Rfast_2.1.0 RcppParallel_5.1.9 RcppZiggurat_0.1.6 Rcpp_1.0.13 ## [9] ggplot2_3.5.1 magrittr_2.0.3 wSIR_0.1.2 BiocStyle_2.32.1 ## ## loaded via a namespace (and not attached): ## [1] gtable_0.3.5 xfun_0.47 bslib_0.8.0 ## [4] lattice_0.22-6 tools_4.4.1 generics_0.1.3 ## [7] parallel_4.4.1 tibble_3.2.1 fansi_1.0.6 ## [10] highr_0.11 pkgconfig_2.0.3 Matrix_1.7-0 ## [13] desc_1.4.3 lifecycle_1.0.4 farver_2.1.2 ## [16] compiler_4.4.1 stringr_1.5.1 textshaping_0.4.0 ## [19] microbenchmark_1.5.0 munsell_0.5.1 codetools_0.2-20 ## [22] htmltools_0.5.8.1 sass_0.4.9 yaml_2.3.10 ## [25] pillar_1.9.0 pkgdown_2.1.0 jquerylib_0.1.4 ## [28] tidyr_1.3.1 MASS_7.3-60.2 openssl_2.2.1 ## [31] BiocParallel_1.38.0 cachem_1.1.0 boot_1.3-30 ## [34] RSpectra_0.16-2 Deriv_4.1.6 tidyselect_1.2.1 ## [37] digest_0.6.37 stringi_1.8.4 dplyr_1.1.4 ## [40] purrr_1.0.2 bookdown_0.40 labeling_0.4.3 ## [43] distances_0.1.11 cowplot_1.1.3 fastmap_1.2.0 ## [46] grid_4.4.1 colorspace_2.1-1 cli_3.6.3 ## [49] utf8_1.2.4 broom_1.0.6 withr_3.0.1 ## [52] scales_1.3.0 backports_1.5.0 rmarkdown_2.28 ## [55] modelr_0.1.11 reticulate_1.39.0 askpass_1.2.0 ## [58] ragg_1.3.3 png_0.1-8 evaluate_0.24.0 ## [61] knitr_1.48 rlang_1.1.4 glue_1.7.0 ## [64] BiocManager_1.30.25 jsonlite_1.8.8 R6_2.5.1 ## [67] systemfonts_1.1.0 fs_1.6.4"},{"path":"https://sydneybiox.github.io/wSIR/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Max Woollard. Author, maintainer, contributor. Pratibha Panwar. Contributor. Linh Nghiem. Author, contributor. Shila Ghazanfar. Author, contributor.","code":""},{"path":"https://sydneybiox.github.io/wSIR/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Woollard M, Nghiem L, Ghazanfar S (2024). wSIR: Weighted Sliced Inverse Regression (WSIR) supervised dimension reduction spatial transcriptomics single cell gene expression data. R package version 0.1.2, https://sydneybiox.github.io/wSIR/, https://sydneybiox.github.io/wSIR.","code":"@Manual{, title = {wSIR: Weighted Sliced Inverse Regression (WSIR) for supervised dimension reduction of spatial transcriptomics and single cell gene expression data}, author = {Max Woollard and Linh Nghiem and Shila Ghazanfar}, year = {2024}, note = {R package version 0.1.2, https://sydneybiox.github.io/wSIR/}, url = {https://sydneybiox.github.io/wSIR}, }"},{"path":"https://sydneybiox.github.io/wSIR/index.html","id":"wsir","dir":"","previous_headings":"","what":"Weighted Sliced Inverse Regression (WSIR) for supervised dimension reduction of spatial transcriptomics and single cell gene expression data","title":"Weighted Sliced Inverse Regression (WSIR) for supervised dimension reduction of spatial transcriptomics and single cell gene expression data","text":"wSIR: Weighted Sliced Inverse Regression supervised dimension reduction spatial transcriptomics single cell gene expression data R package computation wSIR low-dimensional embedding gene expression data, using spatial coordinates. includes functions analyse resulting low-dimensional space, well mapping high-dimensional gene expression data low-dimensional space. function project new gene expression data (spatial coordinates unknown) low-dimensional space ability predict cell’s spatial location. overview method examples, see vignette website.","code":""},{"path":"https://sydneybiox.github.io/wSIR/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Weighted Sliced Inverse Regression (WSIR) for supervised dimension reduction of spatial transcriptomics and single cell gene expression data","text":"{r} library(devtools) install_github(\"SydneyBioX/wSIR\")","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/MouseData.html","id":null,"dir":"Reference","previous_headings":"","what":"MouseGastrulationData — MouseData","title":"MouseGastrulationData — MouseData","text":"Data set consists spatial transcriptomics data mouse embryo. three samples, gene expression data (351 genes), spatial coordinates two-dimensional spatial plane, cell type labels. Sample 1 contains 19451 cells, sample 2 contains 14891 cells sample 3 contains 23194 cells. randomly sampled 20% cells datasets vignette examples stop data large. random sampling, 3848 cells sample 1, 2986 cells sample 2 4607 cells sample 3.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/MouseData.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"MouseGastrulationData — MouseData","text":"sample1_exprs row cell sample 1 column expression level gene. sample1_coords row cell sample 1 column position two spatial axes. sample1_cell_types vector whose 'th entry contains cell type 'th cell sample 1. sample2_exprs row cell sample 2 column expression level gene. sample2_coords row cell sample 2 column position two spatial axes. sample2_cell_types vector whose 'th entry contains cell type 'th cell sample 2. sample3_exprs row cell sample 3 column expression level gene. sample3_coords row cell sample 3 column position two spatial axes. sample3_cell_types vector, whose 'th entry contains cell type 'th cell sample 3.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/MouseData.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"MouseGastrulationData — MouseData","text":"Integration spatial single-cell transcriptomic data elucidates mouse organogenesis, Nature Biotechnology, 2022. Webpage: https://www.nature.com/articles/s41587-021-01006-2","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/createWeightMatrix.html","id":null,"dir":"Reference","previous_headings":"","what":"createWeightMatrix — createWeightMatrix","title":"createWeightMatrix — createWeightMatrix","text":"function create weight matrix given location cells, tile allocations desired spatial weighting strength. Weight matrix entries represent level spatial correlation pairs tiles.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/createWeightMatrix.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"createWeightMatrix — createWeightMatrix","text":"","code":"createWeightMatrix(coords, labels, alpha = 4)"},{"path":"https://sydneybiox.github.io/wSIR/reference/createWeightMatrix.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"createWeightMatrix — createWeightMatrix","text":"coords dataframe dimension n * 2. Column names c(\"x\", \"y\"). Spatial position cell. labels dataframe dimension n * 1, column name c(\"coordinate\"). Tile allocation cell. automatically created wSIR function. alpha numeric value giving strength spatial weighting matrix. alpha = 0 returns identity matrix equals SIR. Large alpha values tend entries towards 1. Default 4.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/createWeightMatrix.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"createWeightMatrix — createWeightMatrix","text":"matrix containing weight value pairs tiles. value 0 1, 1 always diagonal.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/exploreWSIRParams.html","id":null,"dir":"Reference","previous_headings":"","what":"exploreWSIRParams function — exploreWSIRParams","title":"exploreWSIRParams function — exploreWSIRParams","text":"function used select optimal values parameters slices alpha weighted sliced inverse regression based provided gene expression data corresponding spatial coordinates. given evaluation metric, visualise performance WSIR varying function parameters based data, return optimal pair. pair slices alpha can used downstream tasks.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/exploreWSIRParams.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"exploreWSIRParams function — exploreWSIRParams","text":"","code":"exploreWSIRParams( exprs, coords, samples = rep(1, nrow(coords)), alpha_vals = c(0, 2, 4, 10), slice_vals = c(5, 10, 15, 20), varThreshold = 0.95, maxDirections = 50, metric = \"DC\", nrep = 5, param = MulticoreParam(workers = 1) )"},{"path":"https://sydneybiox.github.io/wSIR/reference/exploreWSIRParams.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"exploreWSIRParams function — exploreWSIRParams","text":"exprs matrix containing normalised gene expression data including n cells p genes, dimension n * p. coords dataframe containing spatial positions n cells 2D space. Dimension n * 2. Column names must c(\"x\", \"y\"). samples sample ID cell. total, must length equal number cells. example, dataset 10000 cells, first 5000 sample 1 remaining 5000 sample 2, write samples = c(rep(1, 5000), rep(2, 5000)) specify first 5000 cells sample 1 remaining sample 2. Default cells sample 1. Sample IDs can format: previous example, write samples = c(rep(\"sample 1\", 5000), rep(\"sample 2\", 5000)), result . alpha_vals vector numbers values parameter alpha use WSIR. 0 gives Sliced Inverse Regression (SIR) implementation, larger values represent stronger spatial correlation. Suggest use integers interpretability, can use non-integers. Values must non-negative. slice_vals vector integers values parameter slices use WSIR. Suggest maximum value vector around \\(\\sqrt{n/20}\\), upper bound ensures average least 10 cells per tile training set. varThreshold numeric proportion variance t(X_H) %*% W %*% X_H retain. Must 0 1. Default 0.95. Select higher threshold include dimensions, lower threshold include less dimensions. maxDirections integer maximum number directions include low-dimensional embedding. Default 50. metric evaluation metric use parameter tuning select optimal parameter combination. String, use \"DC\" use distance correlation, \"CD\" use correlation distances, \"ncol\" number dimensions low-dimensional embedding. Default \"DC\". nrep integer number train/test splits data perform. param parallel computing setup bplapply BiocParallel package. Default use single core, hence default value MulticoreParam(workers = 1)","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/exploreWSIRParams.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"exploreWSIRParams function — exploreWSIRParams","text":"List five slots, named \"plot\", \"message\", \"best_alpha\", \"best_slices\" \"results_dataframe\". \"plot\" shows average metric value across nrep iterations every combination parameters slices alpha. Larger circles slices/alpha combination indicates better performance pair values. one panel per evaluation metric selected \"metrics\" argument. \"message\" tells parameter combination highest metric value according selected metric. \"best_alpha\" returns integer best alpha values among values tested according selected metric. \"best_slices\" returns integer best slices value among values tested according selected metric. \"results_dataframe\" returns results dataframe used create \"plot\". dataframe length(alpha_vals)*length(slice_vals) rows, one combination parameters slices alpha. one column \"alpha\", one \"slices\" one evaluation metrics selected \"metrics\" argument. Column \"alpha\" includes value parameter alpha, column \"slices\" includes value parameter slices, metric column includes value specified metric, either Distance Correlation (\"DC\"), Correlation Distances (\"CD\"), number columns low-dimensional embedding (\"ncol\").","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/exploreWSIRParams.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"exploreWSIRParams function — exploreWSIRParams","text":"","code":"data(MouseData) explore_params = exploreWSIRParams(exprs = sample1_exprs, coords = sample1_coords, alpha_vals = c(0,2,4,8), slice_vals = c(3,6,10)) #> Time difference of 1.545631 secs #> Time difference of 0.8617067 secs #> Time difference of 1.213241 secs #> Time difference of 0.7298954 secs #> Time difference of 0.9463546 secs #> Time difference of 1.045403 secs #> Time difference of 0.6928875 secs #> Time difference of 0.7717257 secs #> Time difference of 1.010319 secs #> Time difference of 0.6815271 secs #> Time difference of 0.7364004 secs #> Time difference of 0.8060591 secs explore_params$plot explore_params$message #> [1] \"Optimal (alpha, slices) pair: (8, 3)\" best_alpha = explore_params$best_alpha best_slices = explore_params$best_slices wsir_obj = wSIR(X = sample1_exprs, coords = sample1_coords, optim_params = FALSE, alpha = best_alpha, slices = best_slices)"},{"path":"https://sydneybiox.github.io/wSIR/reference/findTopGenes.html","id":null,"dir":"Reference","previous_headings":"","what":"findTopGenes — findTopGenes","title":"findTopGenes — findTopGenes","text":"function find visualise genes highest (absolute value) loading WSIR1. genes contribute first low-dimensional direction.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/findTopGenes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"findTopGenes — findTopGenes","text":"","code":"findTopGenes(WSIR, highest = 10, dirs = 1)"},{"path":"https://sydneybiox.github.io/wSIR/reference/findTopGenes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"findTopGenes — findTopGenes","text":"WSIR wsir object output wSIR function. analyse different DR method, ensure slot named 'directions' contains loadings matrix gene names rownames. highest integer many top genes like see. Recommend 20 ease visualisation. Default 10. dirs integer vector direction / directions want show/find top genes .","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/findTopGenes.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"findTopGenes — findTopGenes","text":"List containing two slots. First named \"plot\" shows barplot top genes corresponding loadings. Second named \"genes\" vector genes highest (absolute value) loading low-dimensional direction 1. Length parameter highest.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/findTopGenes.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"findTopGenes — findTopGenes","text":"","code":"data(MouseData) wsir_obj = wSIR(X = sample1_exprs, coords = sample1_coords, optim_params = FALSE, alpha = 4, slices = 6) # create wsir object top_genes_obj = findTopGenes(WSIR = wsir_obj, highest = 8) # create top genes object top_genes_plot = top_genes_obj$plot # select plot top_genes_plot # print plot"},{"path":"https://sydneybiox.github.io/wSIR/reference/generateUmapFromWSIR.html","id":null,"dir":"Reference","previous_headings":"","what":"generateUmapfromWSIR — generateUmapFromWSIR","title":"generateUmapfromWSIR — generateUmapFromWSIR","text":"function generate UMAP coordinates low-dimensional embedding gene expression data. coordinates can later plotted plotUmapFromWSIR function. two functions separate can generate UMAP points using function (may take long time), modify resulting plot much desired plotUmapFromWSIR function.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/generateUmapFromWSIR.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"generateUmapfromWSIR — generateUmapFromWSIR","text":"","code":"generateUmapFromWSIR(WSIR)"},{"path":"https://sydneybiox.github.io/wSIR/reference/generateUmapFromWSIR.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"generateUmapfromWSIR — generateUmapFromWSIR","text":"WSIR wsir object output wSIR function. wish generate UMAP plots based DR methods, ensure slot named \"scores\" WSIR parameter contains low-dimensional representation exprs.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/generateUmapFromWSIR.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"generateUmapfromWSIR — generateUmapFromWSIR","text":"matrix UMAP coordinates dimension nrow(coords) * 2. Output function can directly used input plot_umap function.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/generateUmapFromWSIR.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"generateUmapfromWSIR — generateUmapFromWSIR","text":"","code":"data(MouseData) wsir_obj = wSIR(X = sample1_exprs, coords = sample1_coords, optim_params = FALSE, alpha = 4, slices = 6) # create wsir object umap_coords = generateUmapFromWSIR(WSIR = wsir_obj) top_genes_obj = findTopGenes(WSIR = wsir_obj, highest = 4) # create top genes object umap_plot = plotUmapFromWSIR(umap_coords = umap_coords, exprs = sample1_exprs, highest_genes = top_genes_obj, n_genes = 4) umap_plot"},{"path":"https://sydneybiox.github.io/wSIR/reference/plotUmapFromWSIR.html","id":null,"dir":"Reference","previous_headings":"","what":"plotUmapFromWSIR — plotUmapFromWSIR","title":"plotUmapFromWSIR — plotUmapFromWSIR","text":"function plot UMAP generated low-dimensional embedding gene expression data. points coloured value genes highest (absolute value) loading selected WSIR direction, default WSIR1.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/plotUmapFromWSIR.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"plotUmapFromWSIR — plotUmapFromWSIR","text":"","code":"plotUmapFromWSIR( exprs, umap_coords, highest_genes = NULL, genes = NULL, n_genes, ... )"},{"path":"https://sydneybiox.github.io/wSIR/reference/plotUmapFromWSIR.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"plotUmapFromWSIR — plotUmapFromWSIR","text":"exprs matrix containing normalised gene expression data including n cells p genes, dimension n * p. umap_coords UMAP coordinates cell output generateUmapFromWSIR function. UMAP coordinates can based dimension reduction method, e.g UMAP coordinates computed WSIR dimension reduction gene expression data, PCs (principal components), low-dimensional matrix. Must matrix dimension nrow(exprs) * 2. highest_genes output findTopGenes function. Default NULL error message can easily thrown genes highest_genes provided. genes vector gene names (must colnames(exprs)) wish show UMAP plot. cells plots coloured expression values genes provide . Must provide either genes highest_genes parameter (): provide genes want visualise specific genes, provide highest_genes want visualise genes found important WSIR directions. Default NULL error message can easily thrown genes highest_genes provided. n_genes integer number genes like show. Default number unique genes highest_genes parameter number genes (vector) parameter genes. Use parameter want show important genes (e.g select top 4 n_genes = 4). ... additional parameters ggplot functions, e.g size (size points).","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/plotUmapFromWSIR.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"plotUmapFromWSIR — plotUmapFromWSIR","text":"Grid umap plots n_genes number plots. shows cells UMAP generated low-dimensional gene expression data, coloured value genes found top_genes.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/plotUmapFromWSIR.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"plotUmapFromWSIR — plotUmapFromWSIR","text":"","code":"data(MouseData) wsir_obj = wSIR(X = sample1_exprs, coords = sample1_coords, optim_params = FALSE, alpha = 4, slices = 6) # create wsir object umap_coords = generateUmapFromWSIR(WSIR = wsir_obj) top_genes_obj = findTopGenes(WSIR = wsir_obj, highest = 4) # create top genes object umap_plot = plotUmapFromWSIR(umap_coords = umap_coords, exprs = sample1_exprs, highest_genes = top_genes_obj, n_genes = 4) umap_plot"},{"path":"https://sydneybiox.github.io/wSIR/reference/projectWSIR.html","id":null,"dir":"Reference","previous_headings":"","what":"projectWSIR — projectWSIR","title":"projectWSIR — projectWSIR","text":"function project new gene expression data low-dimensional space","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/projectWSIR.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"projectWSIR — projectWSIR","text":"","code":"projectWSIR(wsir, newdata)"},{"path":"https://sydneybiox.github.io/wSIR/reference/projectWSIR.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"projectWSIR — projectWSIR","text":"wsir wsir object usually output wSIR function. want project new data low-dim space following different DR method, param wsir use list matrix loadings slot 2 (e.g PCA loadings) dimension p * d newdata matrix new gene expression data project low-dimensional space. Must p columns columns X argument used generate wsir.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/projectWSIR.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"projectWSIR — projectWSIR","text":"matrix low-dimensional representation newdata gene expression data","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/projectWSIR.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"projectWSIR — projectWSIR","text":"","code":"data(MouseData) wsir_obj = wSIR(X = sample1_exprs, coords = sample1_coords, optim_params = FALSE, alpha = 4, slices = 6) sample2_low_dim_exprs = projectWSIR(wsir = wsir_obj, newdata = sample2_exprs)"},{"path":"https://sydneybiox.github.io/wSIR/reference/sirCategorical.html","id":null,"dir":"Reference","previous_headings":"","what":"sirCategorical — sirCategorical","title":"sirCategorical — sirCategorical","text":"function performs WSIR based provided gene expression data, tile allocations, weight matrix.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/sirCategorical.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"sirCategorical — sirCategorical","text":"","code":"sirCategorical(X, Y, directions = 50, W = NULL, varThreshold = 0.95)"},{"path":"https://sydneybiox.github.io/wSIR/reference/sirCategorical.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"sirCategorical — sirCategorical","text":"X matrix normalised gene expression data n genes across p cells. Y dataframe 1 column named \"coordinate\" tile allocation cell. slices^2 unique tile IDs column. directions Integer specify maximum number directions retain thee low-dimensional embedding data. Use need certain number downstream task. W Weight matrix created createWeightMatrix. Entry (,j) represents spatial correlation level tiles j. diagonal values 1. provided, SIR implementation used. varThreshold numeric value specifying desired proportion variance retain. e.g 95% (default), number directions used eigenvalues add 95% sum eigenvalues.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/sirCategorical.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"sirCategorical — sirCategorical","text":"list outputs 5 named slots. output wSIR function: final step wSIR function.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/sirPCA.html","id":null,"dir":"Reference","previous_headings":"","what":"sirPCA — sirPCA","title":"sirPCA — sirPCA","text":"function performs eigendecomposition (X^H)^t %% W %% (X^H), X^H matrix scaled slice means.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/sirPCA.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"sirPCA — sirPCA","text":"","code":"sirPCA( sliced_data, directions, W = diag(nrow(sliced_data)), varThreshold = 0.95 )"},{"path":"https://sydneybiox.github.io/wSIR/reference/sirPCA.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"sirPCA — sirPCA","text":"sliced_data matrix scaled slice means directions integer, number directions want final low-dimensional Z. W matrix slice weights. Output createWeightMatrix function. varThreshold numeric proportion eigenvalues variance t(X_H) %% W %% X_H retain. Default 0.95. Select higher threshold include dimensions, lower threshold include less dimensions.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/sirPCA.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"sirPCA — sirPCA","text":"list containing: 1) \"eigenvectors\" matrix eigenvectors (X^H)^t %% W %% (X^H) 2) \"d\" integer, selected number dimensions 3) \"evalues\" vector eigenvalues (X^H)^t %% W %% (X^H)","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/slicerCategorical.html","id":null,"dir":"Reference","previous_headings":"","what":"slicerCategorical — slicerCategorical","title":"slicerCategorical — slicerCategorical","text":"function averages columns X matrix category single-column Y dataframe. used find average position within tile create weight matrix, well create tile means used eigendecomposition step SIR/wSIR.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/slicerCategorical.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"slicerCategorical — slicerCategorical","text":"","code":"slicerCategorical(X, Y)"},{"path":"https://sydneybiox.github.io/wSIR/reference/slicerCategorical.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"slicerCategorical — slicerCategorical","text":"X matrix dataframe containing columns average Y dataframe single column named 'coordinate'. column contains categorical variable tile ID cell.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/slicerCategorical.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"slicerCategorical — slicerCategorical","text":"dataframe containing averages column within category Y. Dimension h * p, h number categories Y p number columns X.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/spatialAllocator.html","id":null,"dir":"Reference","previous_headings":"","what":"spatialAllocator — spatialAllocator","title":"spatialAllocator — spatialAllocator","text":"function allocates cell tile based specified number tiles.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/spatialAllocator.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"spatialAllocator — spatialAllocator","text":"","code":"spatialAllocator(coords, slices = 3)"},{"path":"https://sydneybiox.github.io/wSIR/reference/spatialAllocator.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"spatialAllocator — spatialAllocator","text":"coords dataframe contains spatial position cell. Column names c(\"x\", \"y'). Must include row names integer 1 nrow(coords). automatically included wSIR function prior function. slices integer number slices along two spatial axes. number tiles slices^2 since two spatial axes. E.g set slices = 4 use 4^2 = 16 tiles. Default value 3.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/spatialAllocator.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"spatialAllocator — spatialAllocator","text":"output matrix containing slice belonging axis long format. used lapply(coords_split, spatialAllocator, slices) wSIR output dataframe cell's tile allocation \"coordinate\" column.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/visualiseWSIRDirections.html","id":null,"dir":"Reference","previous_headings":"","what":"visualiseWSIRDirections — visualiseWSIRDirections","title":"visualiseWSIRDirections — visualiseWSIRDirections","text":"function easily visualise low-dimensional gene expression data. function plots cell true spatial coordinates, coloured values WSIR1 / WSIR2 / ... . plots give intuition biological signals contained WSIR directions.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/visualiseWSIRDirections.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"visualiseWSIRDirections — visualiseWSIRDirections","text":"","code":"visualiseWSIRDirections( coords, WSIR, dirs = 6, mincol = \"blue\", maxcol = \"red\" )"},{"path":"https://sydneybiox.github.io/wSIR/reference/visualiseWSIRDirections.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"visualiseWSIRDirections — visualiseWSIRDirections","text":"coords dataframe containing spatial positions n cells 2D space. Dimension n * 2. Column names must c(\"x\", \"y\"). WSIR wsir object output wSIR function. analyse different DR method, ensure slot named 'directions' contains loadings matrix gene names rownames. Must used coords parameter coords parameter function. dirs integer many low-dimensional directions like visualise. Recommend 10 ease visualisation. Default 6. mincol String colour low values low-dimensional directions. Personal choice user, default \"blue\". maxcol String colour high values low-dimensional directions. Personal choice user, default \"red\".","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/visualiseWSIRDirections.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"visualiseWSIRDirections — visualiseWSIRDirections","text":"Grid plots dirs number plots. shows cells spatial positions coloured value first 'dirs' WSIR directions.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/visualiseWSIRDirections.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"visualiseWSIRDirections — visualiseWSIRDirections","text":"","code":"data(MouseData) wsir_obj = wSIR(X = sample1_exprs, coords = sample1_coords, optim_params = FALSE, alpha = 4, slices = 6) # create wsir object vis_obj = visualiseWSIRDirections(coords = sample1_coords, WSIR = wsir_obj, dirs = 8) # create visualisations vis_obj"},{"path":"https://sydneybiox.github.io/wSIR/reference/wSIR.html","id":null,"dir":"Reference","previous_headings":"","what":"wSIR — wSIR","title":"wSIR — wSIR","text":"function perform supervised dimension reduction gene expression matrix using coordinates dataframe response value. Incorporates weighting mechanism SIR algorithm generate low-dimensional representation data allow projection new single-cell gene expression data low-dimensional space.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/wSIR.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"wSIR — wSIR","text":"","code":"wSIR( X, coords, samples = rep(1, nrow(coords)), slices = 8, alpha = 4, maxDirections = 50, varThreshold = 0.95, optim_params = TRUE, alpha_vals = c(0, 1, 2, 4, 8, 12), slice_vals = c(3, 5, 7, 10, 15, 20), metric = \"DC\", nrep = 5 )"},{"path":"https://sydneybiox.github.io/wSIR/reference/wSIR.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"wSIR — wSIR","text":"X matrix containing normalised gene expression data including n cells p genes, dimension n * p. coords dataframe containing spatial positions n cells 2D space. Dimension n * 2. Column names must c(\"x\", \"y\"). samples sample ID cell. total, must length equal number cells. example, dataset 10000 cells, first 5000 sample 1 remaining 5000 sample 2, write samples = c(rep(1, 5000), rep(2, 5000)) specify first 5000 cells sample 1 remaining sample 2. Default cells sample 1. Sample IDs can format: previous example, write samples = c(rep(\"sample 1\", 5000), rep(\"sample 2\", 5000)), result . slices integer number slices axis tissue. example, slices = 4 creates 4 slices along spatial axis, yielding 4^2 = 16 tiles. Default 8, suggested minimum 3. Suggest tune parameter. alpha integer specify desired strength spatial correlation. Suggest tune parameter testing dataset among e.g values c(0,2,4,8). alpha = 0 gives SIR implementation. Larger values give stronger spatial correlations. maxDirections integer upper limit number directions include low-dimensional space. Use need less certain number dimensions downstream analyes varThreshold numeric proportion eigenvalues variance t(X_H) %% W %% X_H retain. Default 0.95. Select higher threshold include dimensions, lower threshold include less dimensions. optim_params logical, like wSIR automatically optimise parameters slices alpha based either distance correlation correlation distances evaluation metric. Default TRUE. downstream task quite different either metrics, suggest tune two parameters using specific task evaluation metric. case, determine optimal slices alpha values use relevant function, setting optim_params = FALSE. alpha_vals optim_params = TRUE, values alpha optimise WSIR. 0 gives Sliced Inverse Regression (SIR) implementation, larger values represent stronger spatial correlation. Suggest use integers interpretability, can use non-integers. Values must non-negative. slice_vals optim_params = TRUE, values slices optimise WSIR. Suggest maximum value vector around \\(\\sqrt{n/20}\\), upper bound ensures average least 10 cells per tile training set. metric optim_params = TRUE, evaluation metric use parameter tuning. String, either \"DC\" use distance correlation \"CD\" use correlation distances. Default \"DC\". nrep optim_params = TRUE, integer number train/test splits data perform optimisation parameters slices alpha.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/wSIR.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"wSIR — wSIR","text":"wSIR object list containing 5 (named) positions. 1) scores matrix containing low-dimensional representation X wSIR algorithm. Dimension n * d, d chosen include least varThreshold proportion variance. 2) directions matrix containing WSIR directions, dimension p * d. Use project new data low-dimensional space via X_new %% directions. 3) estd integer stating many dimensions computed low-dimensional space needed account varThreshold proportion variance. number dimensions scores. 4) W matrix weight matrix cells_weight_matrix2 function 5) evalues vector containing p eigenvalues t(X_H) %% W %*% X_H. varThreshold parameter works evalues, e.g first j directions included sum first j evalues equals 0.95% sum evalues.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/wSIR.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"wSIR — wSIR","text":"","code":"data(MouseData) wsir_obj = wSIR(X = sample1_exprs, coords = sample1_coords, optim_params = TRUE, alpha_vals = c(0,2,4), slice_vals = c(3,6,10), metric = \"CD\", nrep = 1) # create wsir object #> Time difference of 0.1336157 secs #> Time difference of 0.1825285 secs #> Time difference of 0.2045898 secs #> Time difference of 0.1377778 secs #> Time difference of 0.1938689 secs #> Time difference of 0.1801209 secs #> Time difference of 0.3262882 secs #> Time difference of 0.1554558 secs #> Time difference of 0.1658032 secs"},{"path":"https://sydneybiox.github.io/wSIR/reference/wSIROptimisation.html","id":null,"dir":"Reference","previous_headings":"","what":"wSIROptimisation — wSIROptimisation","title":"wSIROptimisation — wSIROptimisation","text":"function used calculate validation metric best tuning parameters selected","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/wSIROptimisation.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"wSIROptimisation — wSIROptimisation","text":"","code":"wSIROptimisation( exprs_train, coords_train, exprs_test, coords_test, samples_train, slices, alpha, maxDirections, varThreshold, metrics = c(\"CD\", \"DC\", \"ncol\") )"},{"path":"https://sydneybiox.github.io/wSIR/reference/wSIROptimisation.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"wSIROptimisation — wSIROptimisation","text":"exprs_train matrix normalised gene expression training data. coords_train dataframe containing spatial positions cells 2D space validation data. Dimension n * 2. Column names must c(\"x\", \"y\"). exprs_test matrix normalised gene expression validation data. samples_train sample ID cell training data. total, must length equal number cells. example, dataset 10000 cells, first 5000 sample 1 remaining 5000 sample 2, write samples = c(rep(1, 5000), rep(2, 5000)) specify first 5000 cells sample 1 remaining sample 2. Default cells sample 1. Sample IDs can format: previous example, write samples = c(rep(\"sample 1\", 5000), rep(\"sample 2\", 5000)), result . slices integer number slices axis tissue. example, slices = 4 creates 4 slices along spatial axis, yielding 4^2 = 16 tiles. Default 8, suggested minimum 3. Suggest tune parameter using exploreWSIRParams() function. alpha integer specify desired strength spatial correlation. alpha = 0 gives SIR implementation. Larger values give stronger spatial correlations. Default value 4, weight matrix value pair tiles inversely proportional physical distance . Suggest tune parameter using exploreWSIRParams() function. maxDirections integer maximum number directions include low-dimenensional embedding. Default 50. varThreshold numeric proportion variance t(X_H) %*% W %*% X_H retain. Must 0 1. Default 0.95. Select higher threshold include dimensions, lower threshold include less dimensions. metrics evaluation metrics use parameter tuning. String, options : \"DC\" use distance correlation; \"CD\" use correlation distances; \"ncol\" use number columns low-dimensional embedding. Default three, specified metrics = c(\"DC\", \"CD\", \"ncol\").","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/wSIROptimisation.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"wSIROptimisation — wSIROptimisation","text":"Average metric value selected metric(s) train/test split.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/wSIRSpecifiedParams.html","id":null,"dir":"Reference","previous_headings":"","what":"wSIR_specified_params — wSIRSpecifiedParams","title":"wSIR_specified_params — wSIRSpecifiedParams","text":"wSIR function specified parameters alpha, slices. ued internally wSIROptimisation wSIR functions, specific values alpha slices.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/wSIRSpecifiedParams.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"wSIR_specified_params — wSIRSpecifiedParams","text":"","code":"wSIRSpecifiedParams( X, coords, samples = rep(1, nrow(coords)), slices = 8, alpha = 4, maxDirections = 50, varThreshold = 0.95 )"},{"path":"https://sydneybiox.github.io/wSIR/reference/wSIRSpecifiedParams.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"wSIR_specified_params — wSIRSpecifiedParams","text":"X matrix containing normalised gene expression data including n cells p genes, dimension n * p. coords dataframe containing spatial positions n cells 2D space. Dimension n * 2. Column names must c(\"x\", \"y\"). samples sample ID cell. total, must length equal number cells. example, dataset 10000 cells, first 5000 sample 1 remaining 5000 sample 2, write samples = c(rep(1, 5000), rep(2, 5000)) specify first 5000 cells sample 1 remaining sample 2. Default cells sample 1. Sample IDs can format: previous example, write samples = c(rep(\"sample 1\", 5000), rep(\"sample 2\", 5000)), result . slices integer number slices axis tissue. example, slices = 4 creates 4 slices along spatial axis, yielding 4^2 = 16 tiles. Default 8, suggested minimum 3. Suggest tune parameter. alpha integer specify desired strength spatial correlation. Suggest tune parameter testing dataset among e.g values c(0,2,4,8). alpha = 0 gives SIR implementation. Larger values give stronger spatial correlations. maxDirections integer upper limit number directions include low-dimensional space. Use need less certain number dimensions downstream analyes varThreshold numeric proportion eigenvalues variance t(X_H) %% W %% X_H retain. Default 0.95. Select higher threshold include dimensions, lower threshold include less dimensions.","code":""},{"path":"https://sydneybiox.github.io/wSIR/reference/wSIRSpecifiedParams.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"wSIR_specified_params — wSIRSpecifiedParams","text":"wSIR object list containing 5 (named) positions. 1) scores matrix containing low-dimensional representation X wSIR algorithm. Dimension n * d, d chosen include least varThreshold proportion variance. 2) directions matrix containing WSIR directions, dimension p * d. Use project new data low-dimensional space via X_new %% directions. 3) estd integer stating many dimensions computed low-dimensional space needed account varThreshold proportion variance. number dimensions scores. 4) W matrix weight matrix createWeightMatrix function 5) evalues vector containing p eigenvalues t(X_H) %% W %*% X_H. varThreshold parameter works evalues, e.g first j directions included sum first j evalues equals 0.95% sum evalues.","code":""}]