This pipeline is designed for the analysis of spatial transcriptomics data using the Giotto package in R. It processes CosMx subcellular transcriptomics data, performs data visualization, and conducts clustering and dimension reduction analyses. The pipeline includes various steps such as data loading, feature extraction, normalization, clustering, and visualization.
Install required packages:
Install and load the Giotto package along with any other dependencies like data.table, and ensure a working Python installation with required libraries.
Configure paths:
Data files (transcript coordinates, field of vision positions, etc.)
Output directory for saving results.
Python environment:
Optionally, specify the path to a Python executable within a conda environment.
- Create Giotto CosMx Object
Loads spatial transcriptomics data from the specified directory.
Creates a Giotto object containing subcellular transcript data and field of views (FOVs). - Data Exploration and Feature Extraction
Loads and inspects subcellular detection information.
Filters and separates features from negative probes.
Visualizes the spatial distribution of features and probes. - Create Giotto Objects for FOVs
Processes each FOV, creating Giotto objects that include subcellular data, segmentation masks, and feature coordinates. - Join FOVs
Combines data from multiple FOVs into a single Giotto object, aligning them based on provided offsets. - Visualize Cells and Features
Generates various spatial and in situ plots of feature distributions across cells.
Visualizes cell centroids and feature-specific expression. - Aggregate Features and Normalize Data
Aggregates subcellular features into cell-level data.
Performs data filtering and normalization (log-normalization and Pearson residuals method). - Dimension Reduction
Detects highly variable genes and performs PCA and UMAP.
Plots PCA and UMAP results to visualize feature distributions. - Clustering
Constructs a nearest-neighbor network and applies Leiden clustering.
Visualizes clustering results spatially and across dimension-reduced space. - Small Subset Visualization
Extracts a small region of interest from the Giotto object based on spatial coordinates.
Visualizes genes and clustering results within the subset.
Custom Color Palettes
The pipeline uses custom color palettes for plotting, defined at the beginning of the script (pal10, viv10, pal13). You can modify these to customize the appearance of the plots.
Plots for feature and cell distribution in spatial and dimension-reduced space.
Aggregated and normalized expression matrices.
Clustered cell populations, visualized through UMAP and spatial plots.
Saving Results
Plots and output files are automatically saved to the specified results_folder. You can adjust the save directory and other plot options using the instrs object, which controls the behavior of Giotto's plotting functions.