Compute cell-cell interaction enrichment for spots (observed vs expected)
cellProximityEnrichmentSpots(
gobject,
spat_unit = NULL,
feat_type = NULL,
spatial_network_name = "spatial_network",
cluster_column = "cell_ID",
cells_in_spot = 1,
number_of_simulations = 100,
adjust_method = c("none", "fdr", "bonferroni", "BH", "holm", "hochberg", "hommel",
"BY"),
set_seed = TRUE,
seed_number = 1234,
verbose = FALSE
)
giotto object
spatial unit (e.g. 'cell')
feature type (e.g. 'rna')
name of spatial network to use
name of column to use for clusters
cell number in each spot
number of simulations to create expected observations
method to adjust p.values (e.g. "none", "fdr", "bonferroni","BH","holm", "hochberg", "hommel","BY")
use of seed. Default = TRUE
seed number to use. Default = 1234
be verbose
List of cell Proximity scores (CPscores) in data.table format. The first data.table (raw_sim_table) shows the raw observations of both the original and simulated networks. The second data.table (enrichm_res) shows the enrichment results.
Spatial proximity enrichment or depletion between pairs of cell types is calculated by calculating the observed over the expected frequency of cell-cell proximity interactions. The expected frequency is the average frequency calculated from a number of spatial network simulations. Each individual simulation is obtained by reshuffling the cell type labels of each node (spot) in the spatial network.
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) * 7, mean = 10),
nrow = length(sign_gene)
)
rownames(sign_matrix) <- sign_gene
colnames(sign_matrix) <- paste0("celltype_", unique(x$cluster))
g <- runDWLSDeconv(gobject = g, sign_matrix = sign_matrix)
#> Error: package 'quadprog' is not yet installed
#>
#> To install:
#> install.packages(c("quadprog"))
cellProximityEnrichmentSpots(gobject = g)
#> $raw_sim_table
#> Index: <unified_int>
#> unified_int type_int V1 external
#> <char> <char> <num> <num>
#> 1: Astrocytes--Astrocytes homo 77.097645 77.097645
#> 2: Astrocytes--Neurons hetero 368.902614 342.075257
#> 3: Astrocytes--Oligos hetero 258.428639 238.459464
#> 4: Astrocytes--PeripheralGlia hetero 15.075425 13.983535
#> 5: Neurons--Neurons homo 1572.742242 1572.742242
#> ---
#> 1006: Neurons--Oligos hetero 1159.793815 1158.830010
#> 1007: Neurons--PeripheralGlia hetero 53.120837 53.097420
#> 1008: Oligos--Oligos homo 291.758384 291.758384
#> 1009: Oligos--PeripheralGlia hetero 24.678681 24.664819
#> 1010: PeripheralGlia--PeripheralGlia homo 1.249734 1.249734
#> internal orig round
#> <num> <char> <char>
#> 1: 0.00000000 original original
#> 2: 26.82735755 original original
#> 3: 19.96917482 original original
#> 4: 1.09188982 original original
#> 5: 0.00000000 original original
#> ---
#> 1006: 0.96380446 simulations sim100
#> 1007: 0.02341696 simulations sim100
#> 1008: 0.00000000 simulations sim100
#> 1009: 0.01386250 simulations sim100
#> 1010: 0.00000000 simulations sim100
#>
#> $enrichm_res
#> unified_int type_int original simulations enrichm
#> <fctr> <char> <num> <num> <num>
#> 1: Astrocytes--Astrocytes homo 77.097645 43.908466 0.7982916
#> 2: PeripheralGlia--PeripheralGlia homo 2.741436 1.238117 0.7413068
#> 3: Astrocytes--PeripheralGlia hetero 15.075425 9.601463 0.6005935
#> 4: Oligos--Oligos homo 436.276740 296.264218 0.5568008
#> 5: Oligos--PeripheralGlia hetero 34.552973 25.350889 0.4321185
#> 6: Astrocytes--Oligos hetero 258.428639 208.237077 0.3101992
#> 7: Neurons--Neurons homo 1572.742242 1352.935773 0.2170400
#> 8: Astrocytes--Neurons hetero 368.902614 439.918806 -0.2533675
#> 9: Neurons--PeripheralGlia hetero 41.364766 52.414225 -0.3343591
#> 10: Neurons--Oligos hetero 900.814538 1153.717050 -0.3566367
#> p_higher_orig p_lower_orig p.adj_higher p.adj_lower PI_value int_ranking
#> <num> <num> <num> <num> <num> <int>
#> 1: 0 1 0 1 1.5965832 1
#> 2: 0 1 0 1 1.4826135 2
#> 3: 0 1 0 1 1.2011870 3
#> 4: 0 1 0 1 1.1136016 4
#> 5: 0 1 0 1 0.8642371 5
#> 6: 0 1 0 1 0.6203985 6
#> 7: 0 1 0 1 0.4340799 7
#> 8: 1 0 1 0 -0.5067350 8
#> 9: 1 0 1 0 -0.6687182 9
#> 10: 1 0 1 0 -0.7132734 10
#>