| Title: | Spatial Transcriptomics Deconvolution and Integration in R |
|---|---|
| Description: | STRIDER (Spatial Transcriptomics deconvolutIon and integration in R) provides comprehensive tools for analyzing spatial transcriptomics data. The package implements topic modeling based deconvolution using Latent Dirichlet Allocation (LDA) to decompose spatial spots into cell type proportions. It also provides multi-sample integration using Fused Gromov-Wasserstein (FGW) optimal transport, spatial clustering with neighborhood awareness, and visualization functions. STRIDER is designed to work seamlessly with Seurat objects (v4 and v5) and supports various input formats including 10X Genomics HDF5 files. |
| Authors: | Zaoqu Liu [aut, cre] |
| Maintainer: | Zaoqu Liu <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.0 |
| Built: | 2026-05-24 07:39:23 UTC |
| Source: | https://github.com/Zaoqu-Liu/STRIDER |
Align two spatial transcriptomics samples using Fused Gromov-Wasserstein optimal transport.
align_samples( topic1, topic2, coords1, coords2, alpha = 0.5, reg = 0.1, max.iter = 100 )align_samples( topic1, topic2, coords1, coords2, alpha = 0.5, reg = 0.1, max.iter = 100 )
topic1 |
Topic distribution for sample 1 (topics x spots) |
topic2 |
Topic distribution for sample 2 (topics x spots) |
coords1 |
Spatial coordinates for sample 1 |
coords2 |
Spatial coordinates for sample 2 |
alpha |
Trade-off parameter (default: 0.5) |
reg |
Regularization parameter (default: 0.1) |
max.iter |
Maximum iterations (default: 100) |
A list containing:
transportOptimal transport plan matrix
rotationRotation matrix for alignment
fgw_distFGW distance value
## Not run: alignment <- align_samples(topic1, topic2, coords1, coords2) ## End(Not run)## Not run: alignment <- align_samples(topic1, topic2, coords1, coords2) ## End(Not run)
Add STRIDER deconvolution results to a Seurat object.
as_seurat(strider, seurat, assay.name = "STRIDER")as_seurat(strider, seurat, assay.name = "STRIDER")
strider |
STRIDER result object |
seurat |
Seurat object |
assay.name |
Name for new assay (default: "STRIDER") |
Seurat object with deconvolution results
Evaluate STRIDER performance using simulated data with known cell type proportions.
benchmark_strider(strider_result, true_proportions)benchmark_strider(strider_result, true_proportions)
strider_result |
STRIDER result |
true_proportions |
True cell type proportions (spots x celltypes) |
Benchmark metrics
Calculate celltype-topic association using Bayes' theorem, incorporating prior probabilities of cell types.
calculate_celltype_topic_bayes(topic_celltype, celltype_counts, total_cells)calculate_celltype_topic_bayes(topic_celltype, celltype_counts, total_cells)
topic_celltype |
Topic-celltype matrix (topics x celltypes) |
celltype_counts |
Named vector of cell counts per cell type |
total_cells |
Total number of cells |
Applies Bayes' theorem: P(celltype|topic) = P(topic|celltype) * P(celltype) / P(topic)
This accounts for differences in cell type abundance in the reference data, preventing overrepresentation of abundant cell types in deconvolution.
Celltype-topic Bayes matrix (celltypes x topics)
Calculate topic coherence scores to evaluate model quality. Implements UMass and optionally C_v coherence metrics.
calculate_coherence( model, matrix, n.words = 10, type = "both", cell_gene_list = NULL )calculate_coherence( model, matrix, n.words = 10, type = "both", cell_gene_list = NULL )
model |
LDA model from train_lda() |
matrix |
Original count matrix used for training |
n.words |
Number of top words per topic (default: 10) |
type |
Coherence type: "umass", "cv", or "both" (default: "both") |
cell_gene_list |
List of genes expressed per cell (for c_v, auto-generated if NULL) |
UMass coherence measures how often top words co-occur in the corpus: C_UMass = sum_j=2^M sum_i=1^j-1 log((D(w_i, w_j) + 1) / D(w_i))
C_v coherence uses normalized pointwise mutual information (NPMI) with a sliding window and cosine similarity, providing better correlation with human judgments.
A list containing:
umassUMass coherence (mean across topics)
cvC_v coherence (mean across topics), NA if type="umass"
umass_per_topicUMass score for each topic
cv_per_topicC_v score for each topic
Mimno, D., et al. (2011). Optimizing semantic coherence in topic models. EMNLP. Röder, M., et al. (2015). Exploring the Space of Topic Coherence Measures. WSDM.
Calculate the average cell type fractions from neighboring spots.
calculate_neighbor_fractions(deconv, neighbors)calculate_neighbor_fractions(deconv, neighbors)
deconv |
Cell type fraction matrix (spots x celltypes) |
neighbors |
List of neighbor indices from find_neighbors() |
Matrix of neighbor-averaged fractions (spots x celltypes)
Calculate NMI between predicted clusters and true cell types.
calculate_nmi(pred, truth)calculate_nmi(pred, truth)
pred |
Predicted labels |
truth |
True labels |
NMI score between 0 and 1
Calculate quality control metrics for cells/spots.
calculate_qc_metrics(matrix, mito.pattern = "^MT-|^mt-")calculate_qc_metrics(matrix, mito.pattern = "^MT-|^mt-")
matrix |
Count matrix (genes x cells/spots) |
mito.pattern |
Pattern to match mitochondrial genes (default: "^MT-|^mt-") |
Data frame with QC metrics
## Not run: qc <- calculate_qc_metrics(mat) ## End(Not run)## Not run: qc <- calculate_qc_metrics(mat) ## End(Not run)
Calculate the association between topics and cell types by aggregating topic distributions across cells of each type.
calculate_topic_celltype(topic_cell, celltypes, method = "mean")calculate_topic_celltype(topic_cell, celltypes, method = "mean")
topic_cell |
Topic-cell matrix (topics x cells) |
celltypes |
Named vector of cell type annotations |
method |
Aggregation method: "mean" (default), "median", or "sum" |
This matrix represents P(topic|celltype), the probability of each topic given a cell type. It is computed by averaging topic distributions across all cells of each type.
Topic-celltype matrix (topics x celltypes)
## Not run: topic_ct <- calculate_topic_celltype(topic_cell, celltypes) ## End(Not run)## Not run: topic_ct <- calculate_topic_celltype(topic_cell, celltypes) ## End(Not run)
Center coordinates by weighted mean.
center_coords(coords, weights = NULL)center_coords(coords, weights = NULL)
coords |
Coordinate data frame or matrix (n x 2) |
weights |
Point weights (default: uniform) |
Centered coordinates as data frame
Center point coordinates by subtracting the weighted centroid.
center_points_cpp(X, weights)center_points_cpp(X, weights)
X |
Points (n x d) |
weights |
Point weights (n), should sum to 1 |
Centered points (n x d)
Calculate cell type composition statistics for each cluster.
cluster_composition(deconv, clusters)cluster_composition(deconv, clusters)
deconv |
Deconvolution matrix (spots x celltypes) |
clusters |
Cluster assignments (vector or data frame with 'cluster' column) |
Data frame with mean composition per cluster
Cluster cells in topic space and evaluate clustering quality.
cluster_in_topic_space( topic_cell, true_celltypes, n_clusters = NULL, n_iter = 1000, seed = 42 )cluster_in_topic_space( topic_cell, true_celltypes, n_clusters = NULL, n_iter = 1000, seed = 42 )
topic_cell |
Topic-cell matrix (topics x cells) |
true_celltypes |
Named vector of true cell type annotations |
n_clusters |
Number of clusters (default: auto from celltypes) |
n_iter |
Maximum k-means iterations (default: 1000) |
seed |
Random seed |
A list containing cluster assignments and NMI score
Calculate silhouette score to assess clustering quality.
cluster_silhouette(deconv, clusters)cluster_silhouette(deconv, clusters)
deconv |
Deconvolution matrix |
clusters |
Cluster assignments |
Average silhouette score
Functions for neighborhood-aware clustering of spatial spots
Combine multiple ggplot objects into a single figure.
combine_plots(plots, ncol = 2, nrow = NULL, title = NULL)combine_plots(plots, ncol = 2, nrow = NULL, title = NULL)
plots |
List of ggplot objects |
ncol |
Number of columns |
nrow |
Number of rows (optional) |
title |
Overall title |
A combined plot
Compute pairwise Euclidean distance matrix from coordinates.
compute_distance_matrix(coords)compute_distance_matrix(coords)
coords |
Coordinate data frame or matrix |
Distance matrix
Compute pairwise KL divergence between probability distributions. Matches the exact implementation in Python STRIDE's KLDivergency function.
compute_kl_divergence(P, Q, eps = 1e-10)compute_kl_divergence(P, Q, eps = 1e-10)
P |
First matrix (n x k), rows are distributions |
Q |
Second matrix (m x k), rows are distributions |
eps |
Small constant to avoid log(0) (default: 1e-10) |
KL divergence matrix (n x m)
Find the optimal rotation matrix R to align X to Y using Procrustes analysis (SVD of cross-covariance).
compute_rotation_svd_cpp(X, Y, weights)compute_rotation_svd_cpp(X, Y, weights)
X |
Source points (n x d) |
Y |
Target points (n x d) |
weights |
Point weights (n) |
Minimizes weighted sum of squared alignment errors. Solution uses SVD: R = U * V' where H = Y' * W * X = U * S * V'
Rotation matrix R (d x d) such that X * R aligns with Y
Create a bipartite graph connecting spots to their most similar cells.
create_mapping_graph(mapping, threshold = NULL)create_mapping_graph(mapping, threshold = NULL)
mapping |
Mapping result from map_spots_to_cells() |
threshold |
Distance threshold for edges (optional) |
An igraph object (if igraph is available) or edge list
Create a STRIDER result object.
create_strider_object( deconv, topic_spot = NULL, model = NULL, method = NULL, n_topics = NULL, metrics = NULL, genes_used = NULL, celltypes = NULL )create_strider_object( deconv, topic_spot = NULL, model = NULL, method = NULL, n_topics = NULL, metrics = NULL, genes_used = NULL, celltypes = NULL )
deconv |
Deconvolution results matrix (spots x celltypes) |
topic_spot |
Topic-spot distribution matrix |
model |
Trained LDA model |
method |
Selected deconvolution method |
n_topics |
Number of topics |
metrics |
Model evaluation metrics |
genes_used |
Genes used in model training |
celltypes |
Cell types in the model |
A STRIDER object
Functions for reading and writing spatial transcriptomics data
Core functions for deconvolving cell type proportions in spatial transcriptomics
Perform cell type deconvolution on spatial transcriptomics data using a trained LDA model.
deconvolve( st.matrix, model, topic_celltype, celltype_topic_bayes = NULL, method = "Bayes", n.iter = 100 )deconvolve( st.matrix, model, topic_celltype, celltype_topic_bayes = NULL, method = "Bayes", n.iter = 100 )
st.matrix |
Spatial count matrix (genes x spots) |
model |
Trained LDA model from train_lda() |
topic_celltype |
Topic-celltype association matrix |
celltype_topic_bayes |
Bayesian celltype-topic matrix (required for Bayes methods) |
method |
Deconvolution method:
|
n.iter |
Inference iterations (default: 100) |
The deconvolution computes cell type fractions for each spot by:
Inferring topic distributions for spatial spots
Applying celltype-topic weights to convert topics to cell types
Normalizing to obtain fractions that sum to 1
A list containing:
celltype_fracCell type fractions (spots x celltypes)
topic_spotTopic distributions (topics x spots)
Compute pairwise Euclidean distances between points.
euclidean_distance_cpp(X, Y_nullable = NULL)euclidean_distance_cpp(X, Y_nullable = NULL)
X |
First point set (n x d) |
Y_nullable |
Second point set (m x d), optional. If NULL, computes pairwise distances within X. |
Distance matrix (n x m or n x n)
Evaluate LDA model quality by predicting cell types and comparing with known annotations.
evaluate_model_prediction( topic_cell, topic_celltype, true_celltypes, method = "Raw", celltype_topic_bayes = NULL )evaluate_model_prediction( topic_cell, topic_celltype, true_celltypes, method = "Raw", celltype_topic_bayes = NULL )
topic_cell |
Topic-cell matrix (topics x cells) |
topic_celltype |
Topic-celltype matrix (topics x celltypes) |
true_celltypes |
Named vector of true cell type annotations |
method |
Deconvolution method: "Raw", "Norm", "NormBySD", "Bayes", "BayesNorm" |
celltype_topic_bayes |
Bayesian celltype-topic matrix (for Bayes methods) |
A list containing:
accuracyPrediction accuracy
predictionsPredicted cell types
confusionConfusion matrix
## Not run: eval <- evaluate_model_prediction(topic_cell, topic_ct, true_ct) ## End(Not run)## Not run: eval <- evaluate_model_prediction(topic_cell, topic_ct, true_ct) ## End(Not run)
Train and evaluate LDA models with different numbers of topics to find the optimal configuration.
evaluate_topic_range( matrix, celltypes, topic_range, methods = c("Raw", "Norm", "NormBySD", "Bayes", "BayesNorm"), n.iter = 500, seed = 42, save.models = FALSE, out.dir = NULL )evaluate_topic_range( matrix, celltypes, topic_range, methods = c("Raw", "Norm", "NormBySD", "Bayes", "BayesNorm"), n.iter = 500, seed = 42, save.models = FALSE, out.dir = NULL )
matrix |
Normalized count matrix (genes x cells) |
celltypes |
Named vector of cell type annotations |
topic_range |
Vector of topic numbers to test |
methods |
Vector of evaluation methods |
n.iter |
LDA iterations (default: 500) |
seed |
Random seed |
save.models |
Save intermediate models (default: FALSE) |
out.dir |
Output directory for models |
A list containing:
metricsData frame of evaluation metrics
best_modelBest LDA model
best_n_topicsOptimal number of topics
best_methodBest evaluation method
## Not run: results <- evaluate_topic_range(mat, celltypes, topic_range = 5:15) ## End(Not run)## Not run: results <- evaluate_topic_range(mat, celltypes, topic_range = 5:15) ## End(Not run)
Filter cells or spots based on minimum expression criteria.
filter_cells(matrix, min.genes = 200, min.counts = 0, max.counts = Inf)filter_cells(matrix, min.genes = 200, min.counts = 0, max.counts = Inf)
matrix |
Count matrix (genes x cells/spots) |
min.genes |
Minimum number of genes detected (default: 200) |
min.counts |
Minimum total counts (default: 0) |
max.counts |
Maximum total counts (default: Inf) |
Filtered matrix
## Not run: filtered <- filter_cells(mat, min.genes = 200) ## End(Not run)## Not run: filtered <- filter_cells(mat, min.genes = 200) ## End(Not run)
Filter genes based on minimum expression criteria.
filter_genes(matrix, min.cells = 10, min.counts = 0)filter_genes(matrix, min.cells = 10, min.counts = 0)
matrix |
Count matrix (genes x cells/spots) |
min.cells |
Minimum number of cells expressing the gene (default: 10) |
min.counts |
Minimum total counts for a gene (default: 0) |
Filtered matrix
## Not run: filtered <- filter_genes(mat, min.cells = 10) ## End(Not run)## Not run: filtered <- filter_genes(mat, min.cells = 10) ## End(Not run)
Identify cell types that are enriched in each cluster compared to the overall distribution using statistical testing.
find_cluster_markers( deconv, clusters, method = "wilcox", p.adjust.method = "BH" )find_cluster_markers( deconv, clusters, method = "wilcox", p.adjust.method = "BH" )
deconv |
Deconvolution matrix (spots x celltypes) |
clusters |
Cluster assignments |
method |
Statistical test: "wilcox" or "t" (default: "wilcox") |
p.adjust.method |
P-value adjustment method (default: "BH") |
Data frame with enrichment statistics per cluster-celltype pair
Identify differentially expressed marker genes for each cell type using Wilcoxon rank-sum test. This is crucial for training the LDA model.
find_markers( matrix, celltypes, n.top = 200, min.pct = 0.1, logfc.threshold = 0.25, only.pos = TRUE, test.use = "wilcox", adjust.method = "BH", ncores = 1 )find_markers( matrix, celltypes, n.top = 200, min.pct = 0.1, logfc.threshold = 0.25, only.pos = TRUE, test.use = "wilcox", adjust.method = "BH", ncores = 1 )
matrix |
Count matrix (genes x cells), should be normalized |
celltypes |
Named vector of cell type annotations |
n.top |
Number of top markers per cell type (default: 200) |
min.pct |
Minimum fraction of cells expressing the gene (default: 0.1) |
logfc.threshold |
Minimum log fold change threshold (default: 0.25) |
only.pos |
Only return positive markers (default: TRUE) |
test.use |
Statistical test to use: "wilcox" or "t" (default: "wilcox") |
adjust.method |
P-value adjustment method (default: "BH") |
ncores |
Number of cores for parallel computation (default: 1) |
A list containing:
markersData frame of all markers with statistics
top_markersCharacter vector of top marker genes
## Not run: markers <- find_markers(norm_mat, celltypes, n.top = 200) ## End(Not run)## Not run: markers <- find_markers(norm_mat, celltypes, n.top = 200) ## End(Not run)
Identify differentially expressed marker genes for each cell type using the exact scanpy/STRIDE workflow including preprocessing steps.
find_markers_scanpy( matrix, celltypes, n.top = 200, min.genes = 200, min.cells = 10, target.sum = 10000, n.hvg = NULL, ncores = 1 )find_markers_scanpy( matrix, celltypes, n.top = 200, min.genes = 200, min.cells = 10, target.sum = 10000, n.hvg = NULL, ncores = 1 )
matrix |
Raw count matrix (genes x cells) |
celltypes |
Named vector of cell type annotations |
n.top |
Number of top markers per cell type (default: 200) |
min.genes |
Minimum genes per cell for filtering (default: 200) |
min.cells |
Minimum cells per gene for filtering (default: 10) |
target.sum |
Target sum for normalization (default: 1e4) |
n.hvg |
Number of highly variable genes to use (default: NULL, use all) |
ncores |
Number of cores for parallel computation (default: 1) |
This function replicates the scanpy workflow used in Python STRIDE:
Filter cells with < min.genes expressed genes
Filter genes expressed in < min.cells cells
Normalize counts to target.sum per cell
Log-transform: log1p(x)
Optionally select highly variable genes
Run rank_genes_groups with Wilcoxon test and tie correction
A list containing:
markersData frame of all markers with statistics
top_markersCharacter vector of top marker genes
## Not run: markers <- find_markers_scanpy(raw_count_mat, celltypes, n.top = 200) ## End(Not run)## Not run: markers <- find_markers_scanpy(raw_count_mat, celltypes, n.top = 200) ## End(Not run)
Find neighbors for each spot based on spatial coordinates using k-nearest neighbors or distance threshold.
find_neighbors(coords, k = 6, radius = NULL, include.self = FALSE)find_neighbors(coords, k = 6, radius = NULL, include.self = FALSE)
coords |
Data frame with spatial coordinates (columns: x, y) |
k |
Number of nearest neighbors (default: 6) |
radius |
Distance radius for neighbors (alternative to k) |
include.self |
Include the spot itself as a neighbor (default: FALSE) |
For Visium data, k=6 corresponds to the hexagonal grid structure. For other technologies, adjust k based on expected spatial relationships.
A list where each element contains indices of neighbors for each spot
## Not run: neighbors <- find_neighbors(spatial_coords, k = 6) ## End(Not run)## Not run: neighbors <- find_neighbors(spatial_coords, k = 6) ## End(Not run)
Identify highly variable genes using the variance stabilization approach (similar to Seurat's VST method).
find_variable_genes( matrix, n.top = 2000, min.mean = 0.0125, max.mean = 3, min.var = 0.5, span = 0.3 )find_variable_genes( matrix, n.top = 2000, min.mean = 0.0125, max.mean = 3, min.var = 0.5, span = 0.3 )
matrix |
Count matrix (genes x cells) |
n.top |
Number of top variable genes (default: 2000) |
min.mean |
Minimum mean expression (default: 0.0125) |
max.mean |
Maximum mean expression (default: 3) |
min.var |
Minimum variance (default: 0.5) |
span |
Loess span parameter (default: 0.3) |
A list containing:
hvgCharacter vector of highly variable genes
statsData frame with gene statistics
## Not run: hvg <- find_variable_genes(mat, n.top = 2000) ## End(Not run)## Not run: hvg <- find_variable_genes(mat, n.top = 2000) ## End(Not run)
Extract data from Seurat object for STRIDER analysis.
from_seurat(seurat, celltype.col, assay = "RNA")from_seurat(seurat, celltype.col, assay = "RNA")
seurat |
Seurat object |
celltype.col |
Column name in metadata containing cell types |
assay |
Assay to use (default: "RNA") |
List with matrix and celltypes
Compute Fused Gromov-Wasserstein (FGW) distance, which combines feature-based Wasserstein distance and structure-based Gromov-Wasserstein distance.
fused_gromov_wasserstein_cpp( M, C1, C2, p, q, alpha = 0.5, reg = 0.1, max_iter = 100L, tol = 1e-07 )fused_gromov_wasserstein_cpp( M, C1, C2, p, q, alpha = 0.5, reg = 0.1, max_iter = 100L, tol = 1e-07 )
M |
Feature distance/cost matrix (n x m) |
C1 |
Source structural distance matrix (n x n) |
C2 |
Target structural distance matrix (m x m) |
p |
Source distribution (n), must sum to 1 |
q |
Target distribution (m), must sum to 1 |
alpha |
Trade-off parameter between 0 and 1 (default: 0.5)
|
reg |
Entropic regularization (default: 0.1) |
max_iter |
Maximum iterations (default: 100) |
tol |
Convergence tolerance (default: 1e-7) |
The FGW distance is defined as: FGW(p,q) = min_T (1-alpha) * <M, T> + alpha * GW(C1, C2, T) subject to T * 1 = p, T^T * 1 = q
List with:
T: Optimal transport plan (n x m)
fgw_dist: FGW distance value
Vayer, T., et al. (2020). Fused Gromov-Wasserstein distance for structured objects. Algorithms.
A carefully curated color palette for visualizing cell types and clusters. Designed to be colorblind-friendly and distinguishable.
get_default_colors()get_default_colors()
A character vector of 36 hex color codes
colors <- get_default_colors() scales::show_col(colors)colors <- get_default_colors() scales::show_col(colors)
Generate a color palette with a specified number of colors.
get_extended_colors(n, palette = "default")get_extended_colors(n, palette = "default")
n |
Number of colors needed |
palette |
Base palette: "default" or "viridis" |
A character vector of hex color codes
get_extended_colors(10) get_extended_colors(50, palette = "viridis")get_extended_colors(10) get_extended_colors(50, palette = "viridis")
Extract information about cells mapped to each spot.
get_mapped_celltypes(mapping, celltypes, aggregate = "majority")get_mapped_celltypes(mapping, celltypes, aggregate = "majority")
mapping |
Mapping result from map_spots_to_cells() |
celltypes |
Named vector of cell type annotations |
aggregate |
How to aggregate cell types: "majority", "all", or "weighted" |
Data frame with spot-level cell type information
Integrate multiple spatial transcriptomics samples using Fused Gromov-Wasserstein (FGW) optimal transport. This aligns samples based on both topic distribution similarity and spatial structure.
integrate_samples( deconv.list, topic.list, coords.list, sample.ids = NULL, alpha = 0.5, reg = 0.1, max.iter = 100, seed = 42 )integrate_samples( deconv.list, topic.list, coords.list, sample.ids = NULL, alpha = 0.5, reg = 0.1, max.iter = 100, seed = 42 )
deconv.list |
List of deconvolution result matrices (spots x celltypes) |
topic.list |
List of topic distribution matrices (topics x spots) |
coords.list |
List of spatial coordinate data frames |
sample.ids |
Sample identifiers (default: S1, S2, ...) |
alpha |
Trade-off parameter between feature and spatial similarity (default: 0.5)
|
reg |
Sinkhorn regularization parameter (default: 0.1) |
max.iter |
Maximum iterations for FGW (default: 100) |
seed |
Random seed |
The integration is performed sequentially, aligning each sample to the previous one. The FGW distance balances:
Feature similarity: KL divergence between topic distributions
Structural similarity: Gromov-Wasserstein distance on spatial structure
A list containing:
aligned_coordsData frame of aligned coordinates for all samples
transport_plansList of optimal transport plans between samples
deconvCombined deconvolution results
rotation_matricesList of rotation matrices
Vayer, T., et al. (2020). Fused Gromov-Wasserstein distance for structured objects. Algorithms.
## Not run: integrated <- integrate_samples( deconv.list = list(deconv1, deconv2, deconv3), topic.list = list(topic1, topic2, topic3), coords.list = list(coords1, coords2, coords3) ) ## End(Not run)## Not run: integrated <- integrate_samples( deconv.list = list(deconv1, deconv2, deconv3), topic.list = list(topic1, topic2, topic3), coords.list = list(coords1, coords2, coords3) ) ## End(Not run)
Functions for integrating multiple spatial transcriptomics samples using Fused Gromov-Wasserstein optimal transport
Calculate metrics to assess integration quality.
integration_quality(integration_result)integration_quality(integration_result)
integration_result |
Result from integrate_samples() |
Data frame with quality metrics
Compute pairwise KL divergence between probability distributions (rows of P and Q).
kl_divergence_matrix_cpp(P, Q)kl_divergence_matrix_cpp(P, Q)
P |
First matrix (n x k), rows are distributions |
Q |
Second matrix (m x k), rows are distributions |
KL(p||q) = sum_k p_k * log(p_k / q_k)
KL divergence matrix (n x m) where entry at row i, col j is KL(P_i || Q_j)
Identify the most similar single cells for each spatial spot based on topic distribution similarity.
map_spots_to_cells(topic.spot, topic.cell, n.top = 10, method = "euclidean")map_spots_to_cells(topic.spot, topic.cell, n.top = 10, method = "euclidean")
topic.spot |
Topic distribution for spots (topics x spots) |
topic.cell |
Topic distribution for cells (topics x cells) |
n.top |
Number of top similar cells per spot (default: 10) |
method |
Distance metric: "euclidean", "cosine", or "correlation" (default: "euclidean") |
A data frame with spot-cell mappings and similarity scores
## Not run: mapping <- map_spots_to_cells(topic_spot, topic_cell, n.top = 10) ## End(Not run)## Not run: mapping <- map_spots_to_cells(topic_spot, topic_cell, n.top = 10) ## End(Not run)
Functions for mapping spatial spots to similar single cells
Functions for identifying cell-type specific marker genes.
Functions for evaluating and selecting the best LDA model
Normalize count matrix by total counts per cell/spot.
normalize_counts(matrix, scale.factor = NULL, log.transform = FALSE)normalize_counts(matrix, scale.factor = NULL, log.transform = FALSE)
matrix |
Count matrix (genes x cells/spots) |
scale.factor |
Target sum for normalization (default: NULL, auto-detect) |
log.transform |
Apply log1p transformation (default: FALSE) |
Normalized matrix
## Not run: normalized <- normalize_counts(mat, scale.factor = 10000) ## End(Not run)## Not run: normalized <- normalize_counts(mat, scale.factor = 10000) ## End(Not run)
Functions for visualizing deconvolution and analysis results
Create heatmap of cell type composition across spots.
plot_celltype_heatmap( deconv_mat, title = "Cell Type Composition", scale.by = "none" )plot_celltype_heatmap( deconv_mat, title = "Cell Type Composition", scale.by = "none" )
deconv_mat |
Deconvolution matrix (spots x celltypes) |
title |
Plot title |
scale.by |
Scale values: "row", "column", or "none" |
A ggplot object
Visualize spatial clustering results.
plot_cluster(cluster_result, pt.size = 4, colors = NULL, title = NULL)plot_cluster(cluster_result, pt.size = 4, colors = NULL, title = NULL)
cluster_result |
Clustering result from spatial_cluster() |
pt.size |
Point size (default: 4) |
colors |
Color palette |
title |
Plot title |
A ggplot object
Main plotting function for STRIDER deconvolution results. Supports scatter pie plots, scatter plots, and heatmaps.
plot_deconv( deconv, coords, plot.type = "scatterpie", sample.id = NULL, pt.size = NULL, colors = NULL, title = NULL, coord.flip = FALSE )plot_deconv( deconv, coords, plot.type = "scatterpie", sample.id = NULL, pt.size = NULL, colors = NULL, title = NULL, coord.flip = FALSE )
deconv |
Deconvolution result (STRIDER object or matrix) |
coords |
Spatial coordinates data frame |
plot.type |
Type of plot: "scatterpie", "scatter", or "heatmap" |
sample.id |
Sample ID to plot (if multiple samples) |
pt.size |
Point size (default: auto) |
colors |
Color palette (default: STRIDER palette) |
title |
Plot title (default: auto) |
coord.flip |
Flip x and y coordinates (default: FALSE) |
A ggplot object
## Not run: plot_deconv(strider_result, coords, plot.type = "scatterpie") ## End(Not run)## Not run: plot_deconv(strider_result, coords, plot.type = "scatterpie") ## End(Not run)
Create scatter pie plot showing cell type composition at each spot.
plot_deconv_pie( deconv_mat, coords, pt.size = 8, colors = NULL, title = "Cell Type Distribution", coord.flip = FALSE )plot_deconv_pie( deconv_mat, coords, pt.size = 8, colors = NULL, title = "Cell Type Distribution", coord.flip = FALSE )
deconv_mat |
Deconvolution matrix (spots x celltypes) |
coords |
Spatial coordinates |
pt.size |
Point/pie size |
colors |
Color palette |
title |
Plot title |
coord.flip |
Flip coordinates |
A ggplot object
Create scatter plot colored by dominant cell type.
plot_deconv_scatter( deconv_mat, coords, pt.size = 2, colors = NULL, title = "Dominant Cell Type", coord.flip = FALSE )plot_deconv_scatter( deconv_mat, coords, pt.size = 2, colors = NULL, title = "Dominant Cell Type", coord.flip = FALSE )
deconv_mat |
Deconvolution matrix (spots x celltypes) |
coords |
Spatial coordinates |
pt.size |
Point size |
colors |
Color palette |
title |
Plot title |
coord.flip |
Flip coordinates |
A ggplot object
Visualize integrated samples.
plot_integration( integration_result, color.by = "sample", pt.size = 2, deconv = NULL )plot_integration( integration_result, color.by = "sample", pt.size = 2, deconv = NULL )
integration_result |
Result from integrate_samples() |
color.by |
Color spots by: "sample", "celltype", or NULL |
pt.size |
Point size (default: 2) |
deconv |
Deconvolution results for cell type coloring |
A ggplot object
Create visualization of spot-cell mapping relationships.
plot_mapping(mapping, celltypes, spots = NULL)plot_mapping(mapping, celltypes, spots = NULL)
mapping |
Mapping result from map_spots_to_cells() |
celltypes |
Named vector of cell type annotations |
spots |
Specific spots to visualize (default: first 10) |
A ggplot object
Visualize model evaluation metrics across topic numbers.
plot_model_selection(metrics, metric = "accuracy")plot_model_selection(metrics, metric = "accuracy")
metrics |
Metrics data frame from evaluate_topic_range() |
metric |
Which metric to plot: "accuracy", "coherence", or "nmi" |
A ggplot object
Create heatmap of topic distributions across samples.
plot_topic_heatmap( topic_mat, celltypes = NULL, title = "Topic Distribution", cluster.rows = TRUE, cluster.cols = FALSE )plot_topic_heatmap( topic_mat, celltypes = NULL, title = "Topic Distribution", cluster.rows = TRUE, cluster.cols = FALSE )
topic_mat |
Topic distribution matrix (topics x cells/spots) |
celltypes |
Named vector of cell type annotations (optional) |
title |
Plot title |
cluster.rows |
Cluster rows (default: TRUE) |
cluster.cols |
Cluster columns (default: FALSE) |
A ggplot object
Visualize comparison between STRIDER and reference results.
plot_validation(strider_result, reference_result, plot_type = "scatter")plot_validation(strider_result, reference_result, plot_type = "scatter")
strider_result |
STRIDER result |
reference_result |
Reference result |
plot_type |
Type of plot: "scatter", "bland_altman", "correlation" |
A ggplot object
Functions for preprocessing single-cell and spatial transcriptomics data
Complete preprocessing pipeline for single-cell RNA-seq data.
preprocess_sc( matrix, celltypes, scale.factor = NULL, min.cells = 10, min.genes = 200, normalize = TRUE, scale = FALSE )preprocess_sc( matrix, celltypes, scale.factor = NULL, min.cells = 10, min.genes = 200, normalize = TRUE, scale = FALSE )
matrix |
Count matrix (genes x cells) |
celltypes |
Named vector of cell type annotations |
scale.factor |
Target sum for normalization (default: NULL) |
min.cells |
Minimum cells per gene (default: 10) |
min.genes |
Minimum genes per cell (default: 200) |
normalize |
Whether to normalize (default: TRUE) |
scale |
Whether to scale by SD (default: FALSE) |
A list containing preprocessed data
## Not run: sc_data <- preprocess_sc(mat, celltypes) ## End(Not run)## Not run: sc_data <- preprocess_sc(mat, celltypes) ## End(Not run)
Complete preprocessing pipeline for spatial transcriptomics data.
preprocess_st(matrix, scale.factor = NULL, normalize = TRUE, scale = FALSE)preprocess_st(matrix, scale.factor = NULL, normalize = TRUE, scale = FALSE)
matrix |
Count matrix (genes x spots) |
scale.factor |
Target sum for normalization (default: NULL) |
normalize |
Whether to normalize (default: TRUE) |
scale |
Whether to scale by SD (default: FALSE) |
A list containing preprocessed data
## Not run: st_data <- preprocess_st(mat) ## End(Not run)## Not run: st_data <- preprocess_st(mat) ## End(Not run)
Print STRIDER Object
## S3 method for class 'STRIDER' print(x, ...)## S3 method for class 'STRIDER' print(x, ...)
x |
A STRIDER object |
... |
Additional arguments (unused) |
Print Benchmark Results
## S3 method for class 'strider_benchmark' print(x, ...)## S3 method for class 'strider_benchmark' print(x, ...)
x |
A strider_benchmark object |
... |
Additional arguments (unused) |
Print Method for Integration Result
## S3 method for class 'strider_integration' print(x, ...)## S3 method for class 'strider_integration' print(x, ...)
x |
A strider_integration object |
... |
Additional arguments (unused) |
Print Method for LDA Model
## S3 method for class 'strider_lda' print(x, ...)## S3 method for class 'strider_lda' print(x, ...)
x |
A strider_lda object |
... |
Additional arguments (unused) |
Print Validation Report
## S3 method for class 'strider_validation' print(x, ...)## S3 method for class 'strider_validation' print(x, ...)
x |
A strider_validation object |
... |
Additional arguments (unused) |
Read gene expression data from 10X Genomics HDF5 format. Supports both Cell Ranger v2 and v3 formats.
read_10x_h5(filename, use.names = TRUE, unique.features = TRUE)read_10x_h5(filename, use.names = TRUE, unique.features = TRUE)
filename |
Path to the HDF5 file |
use.names |
Use gene names instead of IDs (default: TRUE) |
unique.features |
Make feature names unique (default: TRUE) |
A list containing:
matrixSparse dgCMatrix of counts
featuresGene names/IDs
barcodesCell/spot barcodes
## Not run: data <- read_10x_h5("filtered_feature_bc_matrix.h5") ## End(Not run)## Not run: data <- read_10x_h5("filtered_feature_bc_matrix.h5") ## End(Not run)
Read cell type annotations from tab-separated text file. File should have two columns: cell ID and cell type.
read_celltype_annotations(filename, sep = "\t", header = FALSE)read_celltype_annotations(filename, sep = "\t", header = FALSE)
filename |
Path to the annotation file |
sep |
Field separator (default: tab) |
header |
Whether file has header (default: FALSE) |
A named vector mapping cell IDs to cell types
## Not run: celltypes <- read_celltype_annotations("celltype.txt") ## End(Not run)## Not run: celltypes <- read_celltype_annotations("celltype.txt") ## End(Not run)
Read gene expression count matrix from tab-separated text file. First column should contain gene names, first row should contain cell/spot IDs.
read_count_matrix( filename, sep = "\t", header = TRUE, row.names = 1, sparse = TRUE )read_count_matrix( filename, sep = "\t", header = TRUE, row.names = 1, sparse = TRUE )
filename |
Path to the text file |
sep |
Field separator (default: tab) |
header |
Whether file has header (default: TRUE) |
row.names |
Column containing row names (default: 1) |
sparse |
Convert to sparse matrix (default: TRUE) |
A list containing:
matrixCount matrix (sparse or dense)
featuresGene names
barcodesCell/spot barcodes
## Not run: data <- read_count_matrix("gene_count.txt") ## End(Not run)## Not run: data <- read_count_matrix("gene_count.txt") ## End(Not run)
Read a list of genes from a text file (one gene per line).
read_gene_list(filename)read_gene_list(filename)
filename |
Path to the gene list file |
A character vector of gene names
## Not run: genes <- read_gene_list("markers.txt") ## End(Not run)## Not run: genes <- read_gene_list("markers.txt") ## End(Not run)
Read spatial coordinates from tab-separated text file. First column should contain spot IDs, followed by coordinates.
read_spatial_coords( filename, sep = "\t", header = TRUE, spot.col = 1, coord.cols = c(2, 3), sample.col = NULL )read_spatial_coords( filename, sep = "\t", header = TRUE, spot.col = 1, coord.cols = c(2, 3), sample.col = NULL )
filename |
Path to the text file |
sep |
Field separator (default: tab) |
header |
Whether file has header (default: TRUE) |
spot.col |
Column containing spot IDs (default: 1) |
coord.cols |
Columns containing coordinates (default: c(2, 3)) |
sample.col |
Column containing sample IDs (optional) |
A data.frame with columns: spot, x, y (and optionally sample)
## Not run: coords <- read_spatial_coords("location.txt") ## End(Not run)## Not run: coords <- read_spatial_coords("location.txt") ## End(Not run)
Main entry point for STRIDER cell type deconvolution. This function performs the complete pipeline including marker identification, LDA training, model selection, and spatial deconvolution.
run_strider( sc.data, st.data, sc.celltype, gene.use = NULL, n.topics = NULL, method = "auto", sc.scale.factor = NULL, st.scale.factor = NULL, normalize = FALSE, n.markers = 200, lda.iter = 500, seed = 42, out.dir = ".", out.prefix = "STRIDER", save.model = TRUE )run_strider( sc.data, st.data, sc.celltype, gene.use = NULL, n.topics = NULL, method = "auto", sc.scale.factor = NULL, st.scale.factor = NULL, normalize = FALSE, n.markers = 200, lda.iter = 500, seed = 42, out.dir = ".", out.prefix = "STRIDER", save.model = TRUE )
sc.data |
Single-cell data. Can be:
|
st.data |
Spatial transcriptomics data. Same formats as sc.data. |
sc.celltype |
Cell type annotations. Can be:
|
gene.use |
Genes to use for model training:
|
n.topics |
Number of topics, or vector of numbers to test. Default: seq(n_celltypes, 3*n_celltypes) |
method |
Deconvolution method: "auto", "Raw", "Norm", "NormBySD", "Bayes", "BayesNorm" |
sc.scale.factor |
Scale factor for single-cell normalization (default: auto) |
st.scale.factor |
Scale factor for spatial normalization (default: auto) |
normalize |
Whether to scale by SD (default: FALSE) |
n.markers |
Number of marker genes per cell type (default: 200) |
lda.iter |
LDA iterations (default: 500) |
seed |
Random seed (default: 42) |
out.dir |
Output directory (default: ".") |
out.prefix |
Output file prefix (default: "STRIDER") |
save.model |
Save trained model (default: TRUE) |
The STRIDER pipeline consists of the following steps:
Load and preprocess single-cell and spatial data
Identify marker genes for each cell type
Train LDA topic model on single-cell data
Evaluate models with different topic numbers
Select optimal model and deconvolution method
Apply model to spatial data for deconvolution
A STRIDER object containing:
deconvCell type fractions matrix (spots x celltypes)
topic_spotTopic distributions for spots (topics x spots)
modelTrained LDA model
methodSelected deconvolution method
n_topicsSelected number of topics
metricsModel evaluation metrics
Sun, D., et al. (2022). STRIDE: accurately decomposing and integrating spatial transcriptomics using single-cell RNA sequencing. Nucleic Acids Research.
## Not run: # From matrices result <- run_strider( sc.data = sc_matrix, st.data = st_matrix, sc.celltype = celltypes ) # From Seurat objects result <- run_strider( sc.data = seurat_sc, st.data = seurat_st, sc.celltype = "celltype" ) ## End(Not run)## Not run: # From matrices result <- run_strider( sc.data = sc_matrix, st.data = st_matrix, sc.celltype = celltypes ) # From Seurat objects result <- run_strider( sc.data = seurat_sc, st.data = seurat_st, sc.celltype = "celltype" ) ## End(Not run)
Save a ggplot object to file with sensible defaults.
save_plot(plot, filename, width = 8, height = 6, dpi = 300)save_plot(plot, filename, width = 8, height = 6, dpi = 300)
plot |
A ggplot object |
filename |
Output filename |
width |
Plot width in inches (default: 8) |
height |
Plot height in inches (default: 6) |
dpi |
Resolution (default: 300) |
Scale data by dividing by standard deviation (without centering). Uses population SD (N) instead of sample SD (N-1) to match sklearn's StandardScaler(with_mean=False) used in Python STRIDE.
scale_data(matrix, center = FALSE, scale = TRUE)scale_data(matrix, center = FALSE, scale = TRUE)
matrix |
Normalized matrix (genes x cells/spots) |
center |
Center data (subtract mean) (default: FALSE) |
scale |
Scale data (divide by SD) (default: TRUE) |
Scaled matrix
## Not run: scaled <- scale_data(mat) ## End(Not run)## Not run: scaled <- scale_data(mat) ## End(Not run)
Automatically select the best model from evaluation results.
select_best_model(eval_results, criterion = "accuracy")select_best_model(eval_results, criterion = "accuracy")
eval_results |
Results from evaluate_topic_range() |
criterion |
Selection criterion: "accuracy", "coherence", or "balanced" |
Selected model components
Perform clustering of spatial spots based on cell type composition with optional neighborhood information.
spatial_cluster( deconv, coords, n.clusters = 5, weight = 0.5, k = 6, method = "kmeans", seed = 42 )spatial_cluster( deconv, coords, n.clusters = 5, weight = 0.5, k = 6, method = "kmeans", seed = 42 )
deconv |
Deconvolution result (STRIDER object or matrix) |
coords |
Spatial coordinates data frame |
n.clusters |
Number of clusters (default: 5) |
weight |
Weight for spot's own composition vs neighbors (default: 0.5)
|
k |
Number of neighbors for local composition (default: 6) |
method |
Clustering method: "kmeans" or "hierarchical" (default: "kmeans") |
seed |
Random seed |
The clustering combines each spot's own cell type composition with the average composition of its spatial neighbors. This produces spatially coherent clusters that reflect local tissue microenvironments.
A data frame with spot coordinates and cluster assignments
## Not run: clusters <- spatial_cluster(strider_result, coords, n.clusters = 5) ## End(Not run)## Not run: clusters <- spatial_cluster(strider_result, coords, n.clusters = 5) ## End(Not run)
Summary of STRIDER Object
## S3 method for class 'STRIDER' summary(object, ...)## S3 method for class 'STRIDER' summary(object, ...)
object |
A STRIDER object |
... |
Additional arguments (unused) |
Train a Latent Dirichlet Allocation (LDA) topic model on single-cell gene expression data. The model treats cells as documents and genes as words, following the methodology described in STRIDE.
train_lda( matrix, n.topics = 10, n.iter = 500, n.passes = 1, convergence.tol = 1e-04, alpha = NULL, beta = 0.01, gamma.threshold = 0.001, seed = NULL, verbose = TRUE )train_lda( matrix, n.topics = 10, n.iter = 500, n.passes = 1, convergence.tol = 1e-04, alpha = NULL, beta = 0.01, gamma.threshold = 0.001, seed = NULL, verbose = TRUE )
matrix |
Normalized count matrix (genes x cells) |
n.topics |
Number of topics (default: 10) |
n.iter |
Number of iterations per pass (default: 500) |
n.passes |
Number of passes over the corpus (default: 1) |
convergence.tol |
Convergence tolerance (default: 1e-4) |
alpha |
Dirichlet prior for document-topic distribution. Default is 50/n.topics as in original STRIDE (matching gensim). |
beta |
Dirichlet prior for topic-word distribution (default: 0.01) |
gamma.threshold |
Minimum change in gamma for document convergence (default: 0.001) |
seed |
Random seed for reproducibility |
verbose |
Print progress messages (default: TRUE) |
The LDA model is trained using Variational Bayes inference via the text2vec package, matching gensim's LdaModel behavior as closely as possible. The default hyperparameters (alpha = 50/K, beta = 0.01) follow the original STRIDE implementation for optimal performance on single-cell data.
Note: gensim uses Online Variational Bayes by default, while text2vec uses standard Variational Bayes. For single-cell data with moderate corpus size, results are highly correlated.
An LDA model object with components:
topic_geneTopic-gene distribution matrix (phi)
topic_cellDocument-topic distribution matrix (theta)
vocabGene vocabulary
n_topicsNumber of topics
Sun, D., et al. (2022). STRIDE: accurately decomposing and integrating spatial transcriptomics using single-cell RNA sequencing. Nucleic Acids Research.
## Not run: model <- train_lda(norm_mat, n.topics = 10) ## End(Not run)## Not run: model <- train_lda(norm_mat, n.topics = 10) ## End(Not run)
Train an LDA model from single-cell data with automatic topic-celltype association calculation.
train_model( sc.matrix, celltypes, gene.use = NULL, n.topics = 10, n.iter = 500, seed = 42 )train_model( sc.matrix, celltypes, gene.use = NULL, n.topics = 10, n.iter = 500, seed = 42 )
sc.matrix |
Single-cell count matrix (genes x cells) |
celltypes |
Named vector of cell type annotations |
gene.use |
Genes to use (optional) |
n.topics |
Number of topics |
n.iter |
LDA iterations |
seed |
Random seed |
Trained LDA model object with topic-celltype matrices
Transfer cell type labels from single-cell reference to spatial spots using mapping results.
transfer_labels(mapping, celltypes, method = "knn", k = NULL)transfer_labels(mapping, celltypes, method = "knn", k = NULL)
mapping |
Mapping result from map_spots_to_cells() |
celltypes |
Named vector of cell type annotations |
method |
Transfer method: "knn" (k-nearest neighbor voting) or "weighted" |
k |
Number of neighbors for kNN (default: all mapped cells) |
Named vector of transferred labels
Apply a trained LDA model to transform new data (e.g., spatial spots) into topic space using variational inference.
transform_lda(model, newdata, n.iter = 100)transform_lda(model, newdata, n.iter = 100)
model |
Trained LDA model from train_lda() |
newdata |
Matrix to transform (genes x cells/spots) |
n.iter |
Number of inference iterations (default: 100) |
This function performs inference on new documents using the trained topic-word distributions. Genes not present in the training vocabulary are ignored.
Topic distribution matrix (topics x cells/spots)
## Not run: topic_dist <- transform_lda(model, st_matrix) ## End(Not run)## Not run: topic_dist <- transform_lda(model, st_matrix) ## End(Not run)
Functions for validating STRIDER results against benchmarks and assessing scientific equivalence with Python STRIDE.
Compare STRIDER deconvolution results with reference results (e.g., from Python STRIDE) to assess scientific equivalence.
validate_strider( strider_result, reference_result, metrics = c("correlation", "dominant", "error", "rank"), tolerance = 0.01 )validate_strider( strider_result, reference_result, metrics = c("correlation", "dominant", "error", "rank"), tolerance = 0.01 )
strider_result |
STRIDER result object or deconvolution matrix (spots x celltypes) |
reference_result |
Reference result (matrix, data frame, or file path) |
metrics |
Which metrics to compute (default: all) |
tolerance |
Numerical tolerance for "exact" comparisons (default: 0.01) |
The validation assesses scientific equivalence rather than numerical identity. Two results are considered equivalent if:
Pearson correlation > 0.95
Dominant cell type match > 0.90
RMSE < 0.05
A validation report object with:
pearson_rPearson correlation of flattened matrices
spearman_rSpearman correlation of flattened matrices
rmseRoot mean squared error
maeMean absolute error
dominant_matchFraction of spots with same dominant cell type
rank_correlationMean rank correlation per spot
verdict"EQUIVALENT" if metrics pass thresholds
## Not run: validation <- validate_strider(strider_result, "stride_result.txt") print(validation) ## End(Not run)## Not run: validation <- validate_strider(strider_result, "stride_result.txt") print(validation) ## End(Not run)
Write gene expression data to 10X Genomics HDF5 format.
write_10x_h5(matrix, features, barcodes, filename, overwrite = FALSE)write_10x_h5(matrix, features, barcodes, filename, overwrite = FALSE)
matrix |
Sparse matrix (genes x cells/spots) |
features |
Gene names |
barcodes |
Cell/spot barcodes |
filename |
Output file path |
overwrite |
Overwrite existing file (default: FALSE) |
Invisible NULL
## Not run: write_10x_h5(mat, genes, cells, "output.h5") ## End(Not run)## Not run: write_10x_h5(mat, genes, cells, "output.h5") ## End(Not run)
Write STRIDER results to tab-separated text files.
write_results(x, filename, row.names = TRUE, col.names = TRUE)write_results(x, filename, row.names = TRUE, col.names = TRUE)
x |
Data to write (matrix or data.frame) |
filename |
Output file path |
row.names |
Include row names (default: TRUE) |
col.names |
Include column names (default: TRUE) |
Invisible NULL