
DecoupleR integration
spacedeconv_decoupleR.RmdWe provide wrapper functions to spatially quantify Pathway and Transcription Factor activities using DecoupleR.
## → Setting up spacedeconv environment..
## → Using conda environment 'spacedeconv-env'
Built-in references can be retrieved via decoupleR by selecting the
reference database with the method argument: “progeny”,
“dorothea”, or “collectri”. Custom reference tables can also be supplied
directly, as shown below.
ref <- get_decoupleR_reference(method = "progeny", organism = "human")
## ── spacedeconv ─────────────────────────────────────────────────────────────────
## ℹ Getting decoupleR reference
## Warning: 'OmnipathR::get_annotation_resources' is deprecated.
## Use 'annotation_resources' instead.
## See help("Deprecated")
## Warning: 'OmnipathR::import_omnipath_annotations' is deprecated.
## Use 'annotations' instead.
## See help("Deprecated")
## Warning in organism_table_safe(oma_organisms, oma_code = character(),
## ncbi_tax_id = integer(), : Failed to load organism names by `oma_organisms`,
## the names from this resource will be missing. Reason: missing columns
## ✔ Got decoupleR reference [6.1s]
##
head(ref)
## # A tibble: 6 × 4
## source target weight p_value
## <chr> <chr> <dbl> <dbl>
## 1 Androgen TMPRSS2 11.5 2.38e-47
## 2 Androgen NKX3-1 10.6 2.21e-44
## 3 Androgen MBOAT2 10.5 4.63e-44
## 4 Androgen KLK2 10.2 1.94e-40
## 5 Androgen SARG 11.4 2.79e-40
## 6 Androgen SLC38A4 7.36 1.25e-39In the next step the activities can be computed.
data("spatial_data_3")
spatial_data_3 <- preprocess(spatial_data_3)
## ── spacedeconv ─────────────────────────────────────────────────────────────────
## ℹ testing parameter
## ✔ parameter OK [52ms]
##
## ℹ Removing 137 observations with umi count below threshold
## ✔ Removed 137 observations with umi count below threshold [799ms]
##
## ℹ Removing 13049 variables with all zero expression
## Warning in preprocess(spatial_data_3): There are 13 mitochondrial genes
## present. Consider removing them.
## ✔ Removed 13049 variables with all zero expression [160ms]
##
## ℹ Checking for ENSEMBL Identifiers
## ! Warning: ENSEMBL identifiers detected in gene names
## ℹ Checking for ENSEMBL Identifiersℹ Consider using Gene Names for first-generation deconvolution tools
## ℹ Checking for ENSEMBL Identifiers✔ Finished Preprocessing [10ms]
spatial_data_3 <- spacedeconv::normalize(spatial_data_3)
## ── spacedeconv ─────────────────────────────────────────────────────────────────
## ℹ testing parameter
## ✔ parameter OK [17ms]
##
## ℹ Normalizing using cpm
## ✔ Finished normalization using cpm [3.1s]
##
## ℹ Please note the normalization is stored in an additional assay
spe <- compute_activities(spatial_data_3, reference = ref, method = "wmean", assay = "cpm")
## ── spacedeconv ─────────────────────────────────────────────────────────────────
## ℹ testing parameter
## ✔ parameter OK [11ms]
##
## ℹ Running decoupleR
## → Calculated multiple results, using corr_wmean , other available results: norm_wmeanCalculated multiple results, using corr_wmean , other available results: wmean
## ℹ Running decoupleR✔ Finished [32.3s]Custom references can be passed directly to
compute_activities() as a table with source
(gene set or regulator), target (gene identifier), and
weight. Use weight 1 for unsigned membership, or
biologically justified weights when available. Gene identifiers must
match the expression assay row names and organism. At least five
matching genes per set are required, and each source-target pair should
occur only once. Activity scoring methods such as ULM use the supplied
weights, whereas AUCell, FGSEA, GSVA, and ORA ignore them.
# Illustrative genes only; use a validated signature or database gene set for analysis.
ref <- data.frame(
source = rep("my_signature", 5),
target = c("STAT1", "IRF1", "CXCL9", "CXCL10", "IDO1"),
weight = rep(1, 5)
)
spe <- compute_activities(spatial_data_3, reference = ref, method = "ulm", assay = "cpm")
# Scores are stored in colData(spe), e.g. spe$decoupleR_my_signature.For example, MSigDB Hallmark gene sets can be retrieved via decoupleR and converted to a custom reference. This example uses human gene symbols. The initial download retrieves the full MSigDB resource and may take a while.
msigdb <- decoupleR::get_resource("MSigDB")
hallmark <- subset(msigdb, collection == "hallmark")
ref <- unique(data.frame(source = hallmark$geneset, target = hallmark$genesymbol))
ref <- ref[!is.na(ref$target) & nzchar(ref$target), ]
ref$weight <- 1
# Optional: keep only selected Hallmark gene sets.
# ref <- ref[ref$source %in% c("HALLMARK_HYPOXIA", "HALLMARK_INTERFERON_GAMMA_RESPONSE"), ]
spe <- compute_activities(spatial_data_3, reference = ref, method = "ulm", assay = "cpm")
# Example result columns:
# spe$decoupleR_HALLMARK_HYPOXIA
# spe$decoupleR_HALLMARK_INTERFERON_GAMMA_RESPONSE