transform_data.Rd
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
)
an STlist with raw count matrices.
one of log
or sct
. If log
, log-normalization is performed.
If sct
, then the SCTransform method is applied by calling sctransform::vst
the scale factor used in logarithmic transformation
the number of genes to be used in the regression model
during SCTransform. The function sctransform::vst
makes a random gene selection
based on this number
The minimum number of spots/cells to be used in the regression
model fit by sctransform::vst
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 parallel::mclapply
and works only in Unix systems.
x an updated STlist with transformed counts.
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.
# Using included melanoma example (Thrane et al.)
library('spatialGE')
data_files <- list.files(system.file("extdata", package="spatialGE"), recursive=T, full.names=T)
count_files <- grep("counts", data_files, value=T)
coord_files <- grep("mapping", data_files, value=T)
clin_file <- grep("thrane_clinical", data_files, value=T)
melanoma <- STlist(rnacounts=count_files[c(1,2)], spotcoords=coord_files[c(1,2)], samples=clin_file) # Only first two samples
#> Warning: Sample ST_mel2_rep1 was not found among the count/coordinate files.
#> Warning: Sample ST_mel2_rep2 was not found among the count/coordinate files.
#> Warning: Sample ST_mel3_rep1 was not found among the count/coordinate files.
#> Warning: Sample ST_mel3_rep2 was not found among the count/coordinate files.
#> Warning: Sample ST_mel4_rep1 was not found among the count/coordinate files.
#> Warning: Sample ST_mel4_rep2 was not found among the count/coordinate files.
#> Found matrix data
#> Matching gene expression and coordinate data...
#> Converting counts to sparse matrices
#> Completed STlist!
#>
melanoma <- transform_data(melanoma, method='log')