跳到正文
cccskills
免费在 GitHub 公开

bioconductor-spatialde

SpatialDE is a method to find spatially variable genes (SVG) from spatial transcriptomics data. This package provides wrappers to use the Python SpatialDE library in R, using reticulate and basilisk.

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(1)

  • SKILL.md6.0 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

spatialDE

Workflows

Standard Workflow

Identify, classify, and cluster spatially variable genes from raw count matrices and spatial coordinates.

library(spatialDE)
library(ggplot2)

# Load data
data("Rep11_MOB_0")
data("MOB_sample_info")

# 1. Filter out unobserved genes and calculate total counts per spot
counts <- Rep11_MOB_0[rowSums(Rep11_MOB_0) >= 3, ]
counts <- counts[, row.names(MOB_sample_info)]
MOB_sample_info$total_counts <- colSums(counts)
X <- MOB_sample_info[, c("x", "y")]

# 2. Stabilize variance using Anscombe's approximation
norm_expr <- stabilize(counts)

# 3. Regress out library size effects
resid_expr <- regress_out(norm_expr, sample_info = MOB_sample_info)

# 4. Classify SVGs into interpretable classes
sample_resid_expr <- head(resid_expr, 1000)
results <- spatialDE::run(sample_resid_expr, coordinates = X)
de_results <- results[results$qval < 0.05, ]
ms_results <- model_search(sample_resid_expr, coordinates = X, de_results = de_results)

# 5. Group SVGs into spatial patterns
sp <- spatial_patterns(sample_resid_expr, coordinates = X, de_results = de_results, n_patterns = 4L, length = 1.5)

# 6. Visualize results
FSV_sig(results, ms_results)

Input: Raw count matrices and spatial coordinates; Output: Spatially variable gene tables, model classifications, and spatial pattern clusters.

Spatial Experiment Workflow

Identify, classify, and cluster spatially variable genes directly using a SpatialExperiment object.

library(spatialDE)
library(SpatialExperiment)

# Load data
data("Rep11_MOB_0")
data("MOB_sample_info")
partial_counts <- head(Rep11_MOB_0, 1000)

spe <- SpatialExperiment(
  assays = list(counts = partial_counts),
  spatialData = DataFrame(MOB_sample_info[, c("x", "y")]),
  spatialCoordsNames = c("x", "y")
)

# Run spatialDE on SpatialExperiment
out <- spatialDE(spe, assay_type = "counts", verbose = FALSE)

# 1. Visualize spatial patterns of multiple genes
spe_results <- out[out$qval < 0.05, ]
ordered_spe_results <- spe_results[order(spe_results$qval), ]
multiGenePlots(spe, assay_type = "counts", ordered_spe_results[1:6, ]$g, point_size = 4, viridis_option = "D", dark_theme = FALSE)

# 2. Classify SVGs into interpretable classes
msearch <- modelSearch(spe, de_results = out, qval_thresh = 0.05, verbose = FALSE)

# 3. Group SVGs into spatial patterns
spatterns <- spatialPatterns(spe, de_results = spe_results, qval_thresh = 0.05, n_patterns = 4L, length = 1.5, verbose = FALSE)

Input: A SpatialExperiment object; Output: Updated data frames of spatially variable genes, model classifications, and spatial patterns.

When to Use

  • Finding spatially variable genes (SVGs) from spatial transcriptomics data using spatialDE::run() or spatialDE().
  • Stabilizing negative binomial count variance using Anscombe's approximation with stabilize().
  • Regressing out library size effects with regress_out().
  • Classifying SVGs into interpretable spatial models (e.g., linear, general) using model_search() or modelSearch().
  • Grouping SVGs into spatial patterns using automatic expression histology (AEH) with spatial_patterns() or spatialPatterns().

When NOT to Use

  • For non-spatial single-cell RNA-seq differential expression, use scran or DESeq2 because spatialDE requires spatial coordinates.
  • For spatial clustering of spots/cells rather than genes, use packages like BayesSpace because spatialDE focuses on identifying and clustering spatially variable genes.

Data Requirements

  • Raw spatial transcriptomics count matrix (genes as rows, spots/cells as columns) or a SpatialExperiment object.
  • Spatial coordinates (X and Y) for each spot/cell.
  • Sample information containing total counts per spot for library size regression.

Key Parameters

  • coordinates: Data frame containing the spatial coordinates (e.g., x and y) of the spots.
  • de_results: Data frame of differential expression results from spatialDE::run().
  • n_patterns (4L): Number of spatial patterns to group SVGs into.
  • length (1.5): Characteristic length scale for spatial correlation.
  • qval_thresh (0.05): Q-value threshold for filtering significant SVGs in modelSearch() or spatialPatterns().
  • assay_type ("counts"): Assay name to extract counts from in SpatialExperiment workflows.

Best Practices

  • Filter out practically unobserved genes (e.g., rowSums(counts) >= 3) before running the pipeline to reduce computational overhead.
  • Always stabilize variance using stabilize() and regress out library size effects using regress_out() before running the core SpatialDE test.
  • Run the SpatialDE test on a subset of genes first to estimate running time, as running on the full genome can be computationally intensive.

Common Pitfalls

  • Non-stabilized counts: Running SpatialDE directly on raw counts violates the normality assumption; fix this by applying stabilize() first.
  • Transposition errors: stabilize() expects samples in columns and genes in rows, whereas SpatialExperiment objects store genes in rows and spots in columns; ensure correct orientation or use the SpatialExperiment wrapper spatialDE().

Alternatives

  • SpatialExperiment: For storing and manipulating spatial transcriptomics data.
  • ggplot2: For custom spatial gene expression plotting.

Citations

  • Svensson et al. (2018), Nature Methods.

References

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

The package contains functions for exploratory oligonucleotide array analysis. The dependence on tkWidgets only concerns few convenience functions. 'affy' is fully functional without it.

中文简介正在准备中。当前显示原文说明。

bioMate-AI/biomate-bioconductor-kb7932026年6月21日 更新

This tool uses the label-tree function from HyPhy to annotate a phylogenetic tree. It allows users to select a subset of leaves using either a regular expression or a list of sequence names, and then apply a specified label to these selecte

中文简介正在准备中。当前显示原文说明。

bioMate-AI/biomate-bioconductor-kb7932026年6月21日 更新

This package provides a client for the Bioconductor AnnotationHub web resource. The AnnotationHub web resource provides a central location where genomic files (e.g., VCF, bed, wig) and other resources from standard locations (e.g., UCSC, En

中文简介正在准备中。当前显示原文说明。

bioMate-AI/biomate-bioconductor-kb7932026年6月21日 更新

apeglm provides Bayesian shrinkage estimators for effect sizes for a variety of GLM models, using approximation of the posterior for individual coefficients.

中文简介正在准备中。当前显示原文说明。

bioMate-AI/biomate-bioconductor-kb7932026年6月21日 更新

ASURAT is a software for single-cell data analysis. Using ASURAT, one can simultaneously perform unsupervised clustering and biological interpretation in terms of cell type, disease, biological process, and signaling pathway activity. Inputting a single-cell RNA-seq data and knowledge-based databases, such as Cell Ontology, Gene Ontology, KEGG, etc., ASURAT transforms gene expression tables into original multivariate tables, termed sign-by-sample matrices (SSMs).

中文简介正在准备中。当前显示原文说明。

bioMate-AI/biomate-bioconductor-kb7932026年6月21日 更新

AUCell allows to identify cells with active gene sets (e.g. signatures, gene modules...) in single-cell RNA-seq data. AUCell uses the "Area Under the Curve" (AUC) to calculate whether a critical subset of the input gene set is enriched with

中文简介正在准备中。当前显示原文说明。

bioMate-AI/biomate-bioconductor-kb7932026年6月21日 更新

查看 bioMate-AI 的全部技能

报告此技能的问题