Extracts gene-level metadata and spatial statistics (if already computed)

get_gene_meta(x = NULL, sthet_only = F)

Arguments

x

an STlist

sthet_only

logical, return only genes with spatial statistics

Value

a data frame with gene-level data

Details

This function extracts data from the x@gene_meta slot, optionally subsetting only to those genes for which spatial statistics (Moran's I or Geary's C, see SThet) have been calculated. The output is a data frame with data from all samples in the STlist

Examples

# 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')
melanoma <- SThet(melanoma, genes=c('MLANA', 'TP53'), method='moran')
#> SThet started.
#> 	Calculating spatial weights...
#> SThet completed in 0.01 min.
#> 
get_gene_meta(melanoma, sthet_only=T)
#> # A tibble: 4 × 15
#>   sample      patient slice gender BRAF_…¹ NRAS_…² CDKN2…³ survi…⁴ survi…⁵   RIN
#>   <chr>         <dbl> <chr> <chr>  <chr>   <chr>   <chr>   <chr>     <dbl> <dbl>
#> 1 ST_mel1_re…       1 A     Male   mut     wt      hd      10_plu…     120   6.2
#> 2 ST_mel1_re…       1 A     Male   mut     wt      hd      10_plu…     120   6.2
#> 3 ST_mel1_re…       1 B     Male   mut     wt      hd      10_plu…     120   6.2
#> 4 ST_mel1_re…       1 B     Male   mut     wt      hd      10_plu…     120   6.2
#> # … with 5 more variables: gene <chr>, gene_mean <dbl>, gene_stdevs <dbl>,
#> #   moran_i <dbl>, geary_c <lgl>, and abbreviated variable names ¹​BRAF_status,
#> #   ²​NRAS_status, ³​CDKN2A_status, ⁴​survival, ⁵​survival_months