summarize_STlist.Rd
Produces a data frame with counts per gene and counts per ROI/spot/cell
summarize_STlist(x = NULL)
a data frame
The function creates a table with counts per gene and counts per region of interest (ROI), spot, or cell in the samples stored in the STlist
# 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
#> Warning: Sample ST_mel3_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!
summarize_STlist(melanoma)
#> # A tibble: 2 × 9
#> sample_name spotscells genes min_counts_per_spotcell mean_counts_per_spotcell
#> <chr> <int> <int> <dbl> <dbl>
#> 1 ST_mel1_rep2 293 16148 6 6056.
#> 2 ST_mel2_rep1 383 16831 9 3649.
#> # ℹ 4 more variables: max_counts_per_spotcell <dbl>,
#> # min_genes_per_spotcell <int>, mean_genes_per_spotcell <dbl>,
#> # max_genes_per_spotcell <int>