HOME  ›   pipelines
If your question is not answered here, please email us at:  ${email.software}

10x Genomics
Visium Spatial Gene Expression

Run Analysis

The count pipeline outputs several CSV files which contain automated secondary analysis results. A subset of these results are used to render the Analysis View in the run summary.

Dimensionality Reduction

Before clustering, Principal Component Analysis (PCA) is run on the normalized filtered feature-barcode matrix to reduce the number of feature (gene) dimensions. Only gene expression features are used as PCA features. The PCA analysis produces four output files. The first is a projection of each spot onto the first N principal components. By default N=10 (N=100 when chemistry batch correction is enabled).

$ cd /home/jdoe/runs/sample345/outs
$ head -2 analysis/pca/10_components/projection.csv

The second file is a components matrix which indicates how much each feature contributed (the loadings) to each principal component. Features that were not included in the PCA analysis have all of their loading values set to zero.

$ head -2 analysis/pca/10_components/components.csv

The third file records the proportion of total variance explained by each principal component. When choosing the number of principal components that are significant, it is useful to look at the plot of variance explained as a function of PC rank - when the numbers start to flatten out, subsequent PCs are unlikely to represent meaningful variation in the data.

$ head -5 analysis/pca/10_components/variance.csv

The final file lists the normalized dispersion of each feature, after binning features by their mean expression across the dataset. This provides a useful measure of variability of each feature.

$ head -5 analysis/pca/10_components/dispersion.csv


After running PCA, t-distributed Stochastic Neighbor Embedding (t-SNE) is run to visualize spots in a 2-D space.

$ head -5 analysis/tsne/2_components/projection.csv


Clustering is then run to group spots that have similar expression profiles together, based on their projection into PCA space. Graph-based clustering (under graphclust) is run once as it does not require a pre-specified number of clusters. K-means (under kmeans) is run for many values of K=2,...,N where K corresponds to the number of clusters, and N=10 by default. The corresponding results for each K is separated into its own directory.

$ ls analysis/clustering
graphclust         kmeans_10_clusters  kmeans_2_clusters  kmeans_3_clusters
kmeans_4_clusters  kmeans_5_clusters   kmeans_6_clusters  kmeans_7_clusters
kmeans_8_clusters  kmeans_9_clusters

For each clustering, spaceranger produces cluster assignments for each spot.

$ head -5 analysis/clustering/kmeans_3_clusters/clusters.csv

Differential Expression

spaceranger also produces a table indicating which features are differentially expressed in each cluster relative to all other clusters. For each feature we compute three values per cluster:

This is located in a different directory than the clustering results, but follows the same structure, with each clustering separated into its own directory.

$ head -5 analysis/diffexp/kmeans_3_clusters/differential_expression.csv

Feature ID,Feature Name,Cluster 1 Mean UMI Counts,Cluster 1 Log2 fold change,Cluster 1 Adjusted p value,Cluster 2 Mean UMI Counts,Cluster 2 Log2 fold change,Cluster 2 Adjusted p value,Cluster 3 Mean UMI Counts,Cluster 3 Log2 fold change,Cluster 3 Adjusted p value ENSG00000228327,RP11-206L10.2,0.0056858989363338264,2.6207666981569986,0.00052155805898912184,0.0,-0.75299726644507814,0.64066099091888962,0.00071455453829430329,-2.3725403666493312,0.0043023680184636837 ENSG00000237491,RP11-206L10.9,0.00012635330969630726,-0.31783275717885928,0.40959138980118809,0.0,3.8319652342760779,0.11986963938734894,0.0,0.56605908868652577,0.39910771338768203 ENSG00000177757,FAM87B,0.0,-2.9027952579000154,0.0,0.0,3.2470027335549219,0.19129034227967889,0.00071455453829430329,3.1510215894076818,0.0 ENSG00000225880,LINC00115,0.0003790599290889218,-5.71015017995762,8.4751637615375386e-28,0.20790015775229512,7.965820981010868,1.3374521290889345e-46,0.0017863863457357582,-2.2065304152104019,0.00059189960914085744

Spatial Enrichment

spaceranger produces a table of Moran's I values for each feature when specific conditions are met:

The Moran's I value can be anywhere between -1 (perfectly dispersed) to 1 (perfectly enriched) but in biological samples values significantly below 0 are unexpected. A p-value is provided, as well as an adjusted p-value which is corrected using the Benjamini-Hochberg method for multiple comparisons.

$ head -5 outs/spatial_enrichment.csv

Feature ID,Feature Name,I,P value,Adjusted p value,Feature Counts in Spots Under Tissue,Median Normalized Average Counts,Barcodes Detected per Feature ENSG00000108821,COL1A1,0.7537685359890554,0.0,0.0,233252,81.82037652661849,2436 ENSG00000164692,COL1A2,0.7465835682088932,0.0,0.0,178333,64.92945395285535,2437 ENSG00000168542,COL3A1,0.6872801298764767,0.0,0.0,77581,27.93455688536169,2405 ENSG00000113140,SPARC,0.6519299969668487,0.0,0.0,84647,30.836280395414637,2428

The spatial_enrichment.csv file is located in the outs directory of every spaceranger count run.

Downstream Analysis in R

Data structures produced by Visium can be analyzed and visualized in R. See Secondary Analysis in R for instructions.