The load_spatial() function is the entry point of the STarlight package. It will load the molecule coordinates and create a 2D binned grid with default size 25µm.
load_spatial(
path = "",
method = c("coordinates", "merscope", "merscope_csv", "xenium", "cosmx"),
bin_size = 25,
control = NULL,
sep = "\t",
threads = 1,
constrain = NULL,
verbose = TRUE,
mapping = NULL
)Either a file (if method is set to "coordinates") or a directory (if method is set to "merscope"). If method is set to "coordinates" the file should contain at least 3 columns ("x", "y", "gene"), ("x", "y", "feature") or ("x", "y", "cell").
The type of technology/file/directory structure. See details.
Numeric value representing the bin size (default to 25). Unit is microns for Xenium and Merscope and pixel for CosMx.
A regular expression to identify controls. As the function computes the sum of counts, this will allow to delete these blanks/controls for computation.
The separator when method is set to "coordinates" (default "\t").
The number of threads (see data.table::fread).
Whether to put constrains on a column when method is set to 'coordinates'. E.g: 'list("global_z==0", "fov==0")'. Works currently with 'coordinates'.
Whether to display the progress bar.
if method='coordinates' is used and non conventional column names are used in the input file,
An object of class STGrid.
If method is set to 'coordinates' a flat file with ("x", "y", "gene"), ("x", "y", "feature") or ("x", "y", "cell") expected for path. If method is set to 'merscope_csv' the transcript csv file exported by Merscope should be provided as path (contains 'global_x', 'global_y' and 'gene' column). If method is set to 'xenium' or 'merscope' path is passed to the 'data.dir' argument of Seurat::ReadXenium and Seurat::ReadVizgen respectively (see corresponding docs).
# Coordinate example
fp <- file.path(system.file("extdata", package = "STarlight"), "tyni.txt")
st <- load_spatial(fp, method = "coordinates")
#> |-- INFO : Technology is ' coordinates '.
#> |-- INFO : Loading data from file: /private/var/folders/zy/wl3dj2_n76zfc8sdvny1q06c0000gn/T/Rtmpqvrydk/temp_libpath1001266f709b3/STarlight/extdata/tyni.txt
#> |-- INFO : Binning a matrix...
#> |-- INFO : Looping over genes...
#>
|
| | 0%
|
|======== | 17%
|
|================= | 33%
|
|========================= | 50%
|
|================================= | 67%
|
|========================================== | 83%
|
|==================================================| 100%
#>
#> |-- INFO : Ordering
#> |-- INFO : Merging...
#> |-- INFO : Returning
#> |-- INFO : Computing sum of counts.
# merscope csv file
fp <- file.path(system.file("extdata", package = "STarlight"), "merscope_122_r1_sub.csv.gz")
st <- load_spatial(fp, method = "merscope_csv", sep=",")
#> |-- INFO : Technology is ' merscope_csv '.
#> |-- INFO : Loading data from file: /private/var/folders/zy/wl3dj2_n76zfc8sdvny1q06c0000gn/T/Rtmpqvrydk/temp_libpath1001266f709b3/STarlight/extdata/merscope_122_r1_sub.csv.gz
#> |-- INFO : Binning a matrix...
#> |-- INFO : Looping over genes...
#>
|
| | 0%
|
|============ | 25%
|
|========================= | 50%
|
|====================================== | 75%
|
|==================================================| 100%
#>
#> |-- INFO : Ordering
#> |-- INFO : Merging...
#> |-- INFO : Returning
#> |-- INFO : Computing sum of counts.
# Xenium
fp <- file.path(system.file("extdata", package = "STarlight"), "xenium_mouse_brain_tx_tiny.csv")
st <- load_spatial(fp,
method = "coordinates", sep=",",
mapping = c("x"="x_location", "y"="y_location", "feature"="feature_name"))
#> |-- INFO : Technology is ' coordinates '.
#> |-- INFO : Loading data from file: /private/var/folders/zy/wl3dj2_n76zfc8sdvny1q06c0000gn/T/Rtmpqvrydk/temp_libpath1001266f709b3/STarlight/extdata/xenium_mouse_brain_tx_tiny.csv
#> |-- INFO : Binning a matrix...
#> |-- INFO : Looping over genes...
#>
|
| | 0%
|
|==== | 7%
|
|======= | 14%
|
|=========== | 21%
|
|============== | 29%
|
|================== | 36%
|
|===================== | 43%
|
|========================= | 50%
|
|============================= | 57%
|
|================================ | 64%
|
|==================================== | 71%
|
|======================================= | 79%
|
|=========================================== | 86%
|
|============================================== | 93%
|
|==================================================| 100%
#>
#> |-- INFO : Ordering
#> |-- INFO : Merging...
#> |-- INFO : Returning
#> |-- INFO : Computing sum of counts.
# Cosmix
fp <- file.path(system.file("extdata", package = "STarlight"), "Lung5_Rep1_tx_file_tiny.csv.gz")
st <- load_spatial(fp, method = "coordinates", sep=",", mapping=c("x"="x_global_px", "y"="y_global_px", feature="target"))
#> |-- INFO : Technology is ' coordinates '.
#> |-- INFO : Loading data from file: /private/var/folders/zy/wl3dj2_n76zfc8sdvny1q06c0000gn/T/Rtmpqvrydk/temp_libpath1001266f709b3/STarlight/extdata/Lung5_Rep1_tx_file_tiny.csv.gz
#> |-- INFO : Binning a matrix...
#> |-- INFO : Looping over genes...
#>
|
| | 0%
|
|=== | 6%
|
|====== | 12%
|
|========= | 19%
|
|============ | 25%
|
|================ | 31%
|
|=================== | 38%
|
|====================== | 44%
|
|========================= | 50%
|
|============================ | 56%
|
|=============================== | 62%
|
|================================== | 69%
|
|====================================== | 75%
|
|========================================= | 81%
|
|============================================ | 88%
|
|=============================================== | 94%
|
|==================================================| 100%
#>
#> |-- INFO : Ordering
#> |-- INFO : Merging...
#> |-- INFO : Returning
#> |-- INFO : Computing sum of counts.