Function to calculate gene signature enrichment scores per spatial position using an enrichment test.

runSpatialEnrich(
  gobject,
  spat_unit = NULL,
  feat_type = NULL,
  enrich_method = c("PAGE", "rank", "hypergeometric"),
  sign_matrix,
  expression_values = c("normalized", "scaled", "custom"),
  min_overlap_genes = 5,
  reverse_log_scale = TRUE,
  logbase = 2,
  p_value = FALSE,
  n_times = 1000,
  rbp_p = 0.99,
  num_agg = 100,
  max_block = 2e+07,
  top_percentage = 5,
  output_enrichment = c("original", "zscore"),
  name = NULL,
  verbose = TRUE,
  return_gobject = TRUE
)

Arguments

gobject

Giotto object

spat_unit

spatial unit

feat_type

feature type

enrich_method

method for gene signature enrichment calculation

sign_matrix

Matrix of signature genes for each cell type / process

expression_values

expression values to use

min_overlap_genes

minimum number of overlapping genes in sign_matrix required to calculate enrichment (PAGE)

reverse_log_scale

reverse expression values from log scale

logbase

log base to use if reverse_log_scale = TRUE

p_value

calculate p-value (default = FALSE)

n_times

(page/rank) number of permutation iterations to calculate p-value

rbp_p

(rank) fractional binarization threshold (default = 0.99)

num_agg

(rank) number of top genes to aggregate (default = 100)

max_block

number of lines to process together (default = 20e6)

top_percentage

(hyper) percentage of cells that will be considered to have gene expression with matrix binarization

output_enrichment

how to return enrichment output

name

to give to spatial enrichment results, default = PAGE

verbose

be verbose

return_gobject

return giotto object

Value

Giotto object or enrichment results if return_gobject = FALSE

Details

For details see the individual functions:

Examples

g <- GiottoData::loadGiottoMini("visium")
#> 1. read Giotto object
#> 2. read Giotto feature information
#> 3. read Giotto spatial information
#> 3.1 read Giotto spatial shape information
#> 3.2 read Giotto spatial centroid information
#> 3.3 read Giotto spatial overlap information
#> 4. read Giotto image information
#> python already initialized in this session
#>  active environment : '/usr/bin/python3'
#>  python version : 3.10
#> checking default envname 'giotto_env'
#> a system default python environment was found
#> Using python path:
#>  "/usr/bin/python3"
x <- findMarkers_one_vs_all(g,
    cluster_column = "leiden_clus", min_feats = 20
)
#> using 'Scran' to detect marker feats. If used in published
#>       research, please cite: Lun ATL, McCarthy DJ, Marioni JC (2016).
#>       'A step-by-step workflow for low-level analysis of single-cell RNA-seq
#>       data with Bioconductor.'
#>       F1000Res., 5, 2122. doi: 10.12688/f1000research.9501.2. 
#> start with cluster  1start with cluster  2start with cluster  3start with cluster  4start with cluster  5start with cluster  6start with cluster  7
sign_gene <- x$feats

sign_matrix <- matrix(rnorm(length(sign_gene) * 8, mean = 10),
    nrow = length(sign_gene)
)
rownames(sign_matrix) <- sign_gene
colnames(sign_matrix) <- paste0("celltype_", unique(x$cluster))
#> Error in dimnames(x) <- dn: length of 'dimnames' [2] not equal to array extent

runSpatialEnrich(gobject = g, sign_matrix = sign_matrix)
#> Error in sign_matrix[interGene, available_ct]: subscript out of bounds