STplot_interpolation.Rd
Produces a gene expression surface from kriging interpolation of ST data.
STplot_interpolation(
x = NULL,
genes = NULL,
top_n = 10,
samples = NULL,
color_pal = "BuRd"
)
an STlist containing results from gene_krige
for the genes selected.
a vector of gene names (one or several) to plot. If 'top', the 10 genes with highest standard deviation from each spatial sample are plotted.
an integer indicating how many top genes to perform kriging. Default is 10.
a vector indicating the spatial samples to plot. If vector of numbers,
it follows the order of names(x@counts)
. If NULL, the function plots all samples
a color scheme from khroma
or RColorBrewer
.
a list of plots
This function produces a gene expression surface plot via kriging for one or several genes and spatial samples
# 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.06 min.
#>
kp = STplot_interpolation(melanoma, genes=c('MLANA', 'COL1A1'), samples='ST_mel1_rep2')
#> Loading required namespace: rgeos
#> Loading required package: ggpolypath
#> Loading required package: ggplot2
ggpubr::ggarrange(plotlist=kp)