View source: R/transform_data.R
transform_data | R Documentation |
Applies data transformation methods to spatial transcriptomics samples within an STlist
transform_data(
x = NULL,
method = "log",
scale_f = 10000,
sct_n_regr_genes = 3000,
sct_min_cells = 5,
cores = NULL
)
x |
an STlist with raw count matrices. |
method |
one of |
scale_f |
the scale factor used in logarithmic transformation |
sct_n_regr_genes |
the number of genes to be used in the regression model
during SCTransform. The function |
sct_min_cells |
The minimum number of spots/cells to be used in the regression
model fit by |
cores |
integer indicating the number of cores to use during parallelization.
If NULL, the function uses half of the available cores at a maximum. The parallelization
uses |
This function takes an STlist with raw counts and performs data transformation.
The user has the option to select between log transformation after library size
normalization (method='log'
), or SCTransform (method='sct'
). In the case of
logarithmic transformation, a scaling factor (10^4 by default) is applied. The
function uses parallelization using "forking" (not available in Windows OS).
Note that the method sct
returns a matrix with less genes as filtering is
done for low expression genes.
x an updated STlist with transformed counts.
# Using included melanoma example (Thrane et al.)
# Download example data set from spatialGE_Data
thrane_tmp = tempdir()
unlink(thrane_tmp, recursive=TRUE)
dir.create(thrane_tmp)
lk='https://github.com/FridleyLab/spatialGE_Data/raw/refs/heads/main/melanoma_thrane.zip?download='
download.file(lk, destfile=paste0(thrane_tmp, '/', 'melanoma_thrane.zip'), mode='wb')
zip_tmp = list.files(thrane_tmp, pattern='melanoma_thrane.zip$', full.names=TRUE)
unzip(zipfile=zip_tmp, exdir=thrane_tmp)
# Generate the file paths to be passed to the STlist function
count_files <- list.files(paste0(thrane_tmp, '/melanoma_thrane'),
full.names=TRUE, pattern='counts')
coord_files <- list.files(paste0(thrane_tmp, '/melanoma_thrane'),
full.names=TRUE, pattern='mapping')
clin_file <- list.files(paste0(thrane_tmp, '/melanoma_thrane'),
full.names=TRUE, pattern='clinical')
# Create STlist
library('spatialGE')
melanoma <- STlist(rnacounts=count_files[c(1,2)],
spotcoords=coord_files[c(1,2)],
samples=clin_file) # Only first two samples
melanoma <- transform_data(melanoma, method='log')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.