gene_interpolation.Rd
Performs spatial interpolation ("kriging") of transformed gene counts
gene_interpolation(
x = NULL,
genes = "top",
top_n = 10,
samples = NULL,
ngrid = 10000,
REML = F,
cores = NULL
)
an STlist with transformed RNA counts
a vector of gene names or 'top'. If 'top' (default), interpolation of
the 10 genes (top_n
default) with highest standard deviation in each ST sample
is estimated.
an integer indicating how many top genes to perform interpolation. Default is 10.
the spatial samples for which interpolations will be performed. If NULL (Default), all samples are interpolated.
an integer indicating the number of point to predict. Default is 10000, resulting in a grid of 100 x 100 points. Larger numbers provide more resolution, but computing time is longer.
wheter to use restricted maximum likelihood to estimate spatial covariance parameters. Default is FALSE. Setting to TRUE might speed up interpolation, but some issue have been found.
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 a STlist including spatial interpolations.
This function takes an STlist and a vector of gene names and generates spatial
interpolation of gene expression values via "kriging". If genes='top', then
the 10 genes (default) with the highest standard deviation for each ST sample
are interpolated. The resulting interpolations can be visualized via the
STplot_interpolation
function
# 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)
melanoma <- gene_interpolation(melanoma, genes=c('MLANA', 'COL1A1'), samples='ST_mel1_rep2')
#> Gene interpolation started.
#> Gene interpolation completed in 0.04 min.
#>
kp = STplot_interpolation(melanoma, genes=c('MLANA', 'COL1A1'))
#> Kriging for subject MLANA in sample ST_mel1_rep1 is not present in STlist
#> Kriging for subject COL1A1 in sample ST_mel1_rep1 is not present in STlist
ggpubr::ggarrange(plotlist=kp)