View source: R/python-wrappers.R
runSPROD | R Documentation |
A wrapper around the algorithm introduced by Wang et al. 2022 to denoise expression data based on position and image information.
Note that this function creates a temporary folder.
runSPROD(
object,
img_name,
mtr_name,
mtr_name_new,
dir_env,
path_script = NULL,
path_conda = find_path("conda.sh"),
dir_temp = paste0("sprod_temp_", object@sample),
del_temp = TRUE,
assay_name = activeAssay(object),
overwrite = FALSE,
verbose = TRUE
)
object |
An object of class |
img_name |
Character. The name of the image to be used. |
mtr_name |
Character. The name of the input matrix that is denoised |
mtr_name_new |
Character. The name for the new processed (de-oised) matrix. Defaults to |
dir_env |
Character. The folder directory to the conda environment in which the python library sprod is installed. |
path_script |
Character. The path to the .../sprod.py script. By default, the directory of |
path_conda |
Character. The path to the conda initialization script .../conda.sh. By default, common paths are checked. |
dir_temp |
Character. The folder directory for writing temporary files (defaults to "~/sprod_temp_ |
del_temp |
Logical. If |
assay_name |
Only relevant if the |
overwrite |
Logical value. Must be |
verbose |
Logical. If (Warning messages will always be printed.) |
This function runs the SPROD denoising algorithm on a given SPATA2 object by:
Creating a temporary directory (dir_temp
) to store required input files (counts, spot metadata, and image).
Writing the counts matrix, spot metadata, and image to disk in dir_temp
.
Executing the external SPROD Python script (path_script
) via a system command that sources a conda environment (using dir_env
).
Reading the denoised matrix from the expected output file and adding it to the SPATA2 object.
Storing additional results (e.g., intensity and texture features) in the assay’s analysis slot.
Deleting the temporary directory if del_temp
is TRUE
.
The updated input object, containing the added, removed or computed results.
We recommend to set up a conda environment according to the tutorials at https://github.com/yunguan-wang/SPROD.
Wang, Y., Song, B., Wang, S. et al. Sprod for de-noising spatially resolved transcriptomics data based on position and image information. Nat Methods 19, 950–958 (2022). https://doi.org/10.1038/s41592-022-01560-w
## Not run:
library(SPATA2)
library(SPATAData)
library(ggplot2)
library(patchwork)
spata_obj <- downloadSpataObject("T313")
spata_obj <- normalizeCounts(spata_obj)
spata_obj <- runSPROD(
object = spata_obj,
img_name = "lowres",
mtr_name = "LogNormalize",
mtr_name_new = "Sprod",
dir_env = "dir/to/sprod_env",
dir_temp = paste0("sprod_temp_", spata_obj@sample),
del_temp = TRUE,
overwrite = FALSE,
verbose = TRUE
)
p1 <-
plotSurface(spata_obj, color_by = "VEGFA", mtr_name = "LogNormalize") +
labs(subtitle = "LogNormalize")
p2 <-
plotSurface(spata_obj, color_by = "VEGFA", mtr_name = "Sprod") +
labs(subtitle = "Sprod De-Noised")
plot(p1 + p2)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.