Skip to contents

Loading Spatial Metabolic Data into a SpaMTP Seurat Object

Functions that allow the user to load in SM data in different formats

LoadSM()
Loads spatial metabolic data into a SpaMTP Seurat Object
ReadSM_mtx()
Read Spatial Metabolomics matrix file (.csv format)
Load_METASPACE()
Load METASPACE Data and Create Seurat Object

Converting Between Data Objects

Functions that allow the user to convert between SpaMTP Seurat Objects and Cardinal Objects

CardinalToSeurat()
Converts a Cardinal Object into a SpaMTP Seurat Object
ConvertSeuratToCardinal()
Converts a SpaMTP Seurat object to a Cardinal object, including annotations and metadata

Loading Versioned Annotation Databases

Functions for inspecting and loading bundled RaMP annotation resources

Binning Spatial Metabolomic Data

Functions that bin m/z values into a lower resolution/wider peak.

BinSpaMTP()
Bin SpaMTP Object

Annotating m/z Masses

Functions required for performing and handling m/z annotation using a reference metabolic database

AnnotateSM()
Annotates m/z values stored in a SpaMTP Object
AnnotateMZ()
Annotate one or more observed m/z values
DeconvolveSMILES()
Decompose explicit functional groups in SMILES strings
AnnotateSMILESStructure()
Add SMILES-derived structural features to a metabolite database
PredictAdductsFromSMILES()
Predict a structure-aware adduct search space from SMILES
AdductRules()
Return the validated SpaMTP adduct rule table
MALDIMatrixProfiles()
List MALDI matrix and on-tissue derivatization profiles
MALDIMatrixRules()
Select annotation rules from the MALDI matrix/reagent profile
BuildMZAnnotationIndex()
Build a reusable indexed metabolite annotation search space
QueryMZAnnotationIndex()
Query an indexed metabolite annotation search space
AnnotationInfo()
Inspect the metabolite annotation provenance stored in a SpaMTP object
print(<spamtp_mz_index>)
Print an indexed metabolite annotation search space
AddCustomMZAnnotations()
Assign custom annotations to m/z values
AddFMP10Annotations()
Annotates FMP10 matrix data
SearchAnnotations()
Find Annotation
GetMZMetadata()
Gets values from a single metadata column for a respective m/z value.
FindDuplicateAnnotations()
Finds if any metabolite is duplicated across multiple m/z values.
SubsetMZFeatures()
Subset a SpaMTP Seurat Spatial Metabolomic object by a list of m/z's
AnnotateBigData()
Annotates vector of m/z values
getRefinedAnnotations()
Refines and reduces m/z annotations

Simplify Annotations

Functions required for simplifying m/z annotation results

CalculateAnnotationStatistics()
Calculate annotation statistics for all m/z value suggesting the most likely metabolite based on correlated pathway expression.
CalculateSingleAnnotationStatistics()
Calculate annotation statistics for a single m/z value suggesting the most likely metabolite based on correlated pathway expression.
Pseudo_msms()
Find all library spectra10 above a cosine threshold for each imaging peak, restricting to a global precursor-mz range.
CreatePathwayObject()
Create a SpaMTP Seurat Object containing expression values for all present pathways

Simplifying Lipid Nomenclature

Function used to simplify lipid names into general lipid categories, classes, and more

RefineLipids()
Uses common lipid nomenclature to simplify lipid annotations

Analysis of Differentially Expressed Peaks

Functions required for performing pseudo-bulking differential expression analysis

FindAllDEMs()
Finds differentially expressed m/z values/metabolites between all comparison groups.

Visualising DEPs Analysis

Functions used to generate a heatmap from DEP results

DEMsHeatmap()
Heatmap of Differentially Expressed Metabolites

Metabolic and Transcriptomic Pathway Analysis

Functions used to perform pathway analysis, both PCA and metabolite/gene set-based (GSEA)

FishersPathwayAnalysis()
Calculates Significant Metabolic Pathways using a Fisher Exact Test
FindRegionalPathways()
Regional Pathway Enrichment
RunRAMPgeseca()
Runs multilevel Monte-Carlo variant for performing gene sets co-regulation analysis using the RAMP_DB metabolite/gene database.
CreatePathwayAssay()
Create a Pathway Assay from Gene or Metabolite Data

Metabolic and Transcriptomic Pathway Visualisation

Functions used to visualise pathway analysis results

VisualisePathways()
Visualise Significant Pathways
PlotRegionalPathways()
Plot significantly enriched pathways per region
PlotPathways()
Plots the expression profile of a feature set corresponding to specified pathways onto a 2D scatter plot based on a dimensionality reduction technique.
PlotPathwaysSpatially()
Plots the spatial expression profile of a feature set corresponding to specified pathways

Pathway Network Plotting

Functions used to generate network plots for specified patheays

PathwayNetworkPlots()
Construct an interactive pathway network visualization

Dimentionality Reduction Analysis

Functions that are used for calculating PCA embeddings and projections based on SM and/or ST data

RunMetabolicPCA()
Generates PCA analysis results for a SpaMTP Seurat Object
RunSpatialGraphPCA()
Perform Dimensionality Reduction using Graph-Regularised PCA on Spatial Data
GetKmeanClusters()
Perform K-means clustering on a specified reduction

SpaMTP Metabolic Data Visualisation

Functions that can be used to visualize data from SpaMTP object

ImageMZPlot()
Plot expression of m/z values spatially
ImageMZAnnotationPlot()
Plot expression of annotated metabolites spatially
SpatialMZPlot()
Plot expression of m/z values spatially for a Spatial SpaMTP Seurat Objects.
SpatialMZAnnotationPlot()
Plot expression of metabolites in spatially from a Spatial SpaMTP Objects.
Plot3DFeature()
Generates a 3D spatial feature plot from a SpaMTP object
MassIntensityPlot()
Plot mass intensity spectra
DensityMap()
Generates interactive 3D spatial density plot for m/z values
CheckAlignment()
Check multi-modal coordinate alignment

Interactive Spatial Binning Visualisation

Interactive plot that displays spatial changes to m/z intensity values based on changes to bin size.

InteractiveSpatialPlot()
Interactive Spatial Plot for visualising different m/z bin sizes

Additional SpaMTP Functions

Functions that can be used to find the closest metabolite and bin the expression of multiple metabolites into one

FindNearestMZ()
Finds the nearest m/z peak to a given value in a SpaMTP Object
BinMetabolites()
Sums the intensity values of multiple m/z values into one

Spatial Analysis of Metabolomic Data

Functions used to identify spatially correlated features (metabolites/genes)

FindCorrelatedFeatures()
Find top features and metabolites that are strongly correlated with a given feature
FindSpatiallyVariableMetabolites()
Find Spatially Variable Metabolites
GetSpatiallyVariableMetabolites()
Get top spatially variable metabolites
RowVar()
Compute the row variances for each m/z value

Multi-Omic Data Integration

Functions used to Align, Map and Integrate Spatial Metabolomic and Transcriptomic data

MapSpatialOmics()
Maps Spatial Metabolomic (MALDI) data to corresponding Spatial Transcriptomics data and coordinates.
ApplySpatialAlignment()
Apply automatic or precomputed spatial alignment
AlignSpatialOmics()
Interactive app for SM and ST coordinate alignment
MultiOmicIntegration()
Mult-Omic data integration
CreateMergedModalityAssay()
Create a singular multiomics assay by merging data from multiple assays.

Adding Image Data

Functions used to align and add an image to a spatial metabolic SpaMTP object.

AddSMImage()
Manually align an image (e.g. H&E, Immuno) to a SM SpaMTP dataset

ROI Selection

Functions used subset or select specific spatial regions of interest.

SelectROIs()
Launch an Interactive ROI Annotation App for Seurat Spatial Data

Pre-Processing SpaMTP Metabolic Data

Functions for normalising and visualising the pre-processing of SpaMTP datasets

NormalizeSMData()
Normalizes m/z intensity data stored in a SpaMTP Seurat Object
TMMNormalize()
Performs TMM normalization between categories based on a specified ident
MZRidgePlot()
Generates a ridge plot of spatial metabolic intensity data
MZVlnPlot()
Generates a violin plot of spatial metabolic intensity data
MZBoxPlot()
Generates a Boxplot of spatial metabolic intensity data

Exporting SpaMTP Data

Function to export SpaMTP data in .mtx, barcodes.csv, features.csv, metadata.csv, and feature.metadata.csv files

SaveSpaMTPData()
Saves SpaMTP Object

Bundled Annotation and Network Constants

Small compatibility tables used by annotation and pathway visualisation

adduct_file
Common adduct constants
reaction_type
Pathway-network reaction styles

Cardinal Wrapper Functions

Functions used to alter Cardinal Objects.

add_ssc_annotation()
Adds Cardinal ssc segmentation annotation to m/z count data object

Additional Worker Functions

Various helper functions used by SpaMTP

subset_SPM()
Subsets SpaMTP Seurat Object containing FOVs
check_cardinal_version()
Check Cardinal Version

Utility Functions

Binning Helper Functions

Helper functions for binning m/z intensity spectra for SpaMTP objects

BinnedCardinalToSeurat()
Converts a SpaMTP binned Cardinal Object into a SpaMTP Seurat Object
spectral_binning()
Spectral binning of intensity values stored in a Matrix object, converted from matter.

Plotting Helper Functions

Helper functions used for SpaMTP data visualisation

bin.mz()
Bins multiple m/z values into one.
plusminus()
Identifies all mz peaks within a plus-minus range of the target_mz
plot_plus_minus()
Helper Function to generate merged counts within the plus minus range provided
check_column_type()
Helper function to determine if a column contains categorical or continuous Data
pixelPlot()
Helper function for converting Seurat Class ggplots from spot to pixel layout

Annotation Helper Functions

Helper functions required for running ‘AnnotateSM()’

annotateTable()
Annotates m/z values stored in a data.frame based on reference metabolite dataset
labels_to_show()
Filters the annotation list to only include the first n number of annotations per m/z
add_backslashes_to_specialfeatures()
Adds in backslashes required to take into account special using grepl such as brackets and +
check_and_truncate_adduct_vector()
Checks if the complete adduct is in the data base, else returns a truncated adduct
db_adduct_filter()
Filters the provided metabolomic database by polarity and adducts
formula_filter()
Filters reference Database to only select natural elements
calculate_bounds()
Calculates the mz range of the observed_df
ppm_error()
Calculates the ppm error as a valve
ppm_range_match()
Check whether m/z values match within a ppm tolerance

METASPACE Loader helper functions

Helper functions required for running ‘Load_METASPACE()’

metaspace_client()
Metaspace R Client Constructor
get_metaspace()
Core METASPACE Data Retrieval
metaspace_to_feature_matrix()
Convert METASPACE Images to Feature Matrix

Differential Abundance Helper Functions

Helper functions for calculating and plotting differentially expressed metabolites

run_pooling()
Pools SpaMTP Seurat object into random pools for pseudo-bulking.
run_DE()
Runs EdgeR analysis for pooled data
save_pheatmap_as_pdf()
Saves a DEMsHeatmap as a PDF

Pathway Analysis Helper Functions

Helper functions used for running pathway analysis

PlotSinglePathway()
Plots the expression profile of a feature set corresponding to specified pathways onto a 2D scatter plot based on a dimensionality reduction technique.
PlotSinglePathwaySpatially()
Plot expression profile of a single RAMP pathway spatially
addGesecaScores()
Add GESECA Scores to SpaMTP Object
get_analytes_db()
Helper function for building a pathway db based on detected
list_to_pprcomp()
Creates a pprcomp object based on an input list

Multi-Omic Helper Functions

Helper functions used in multi-omic analysis functions

kneighbors_graph()
Construct a k-Nearest Neighbour Graph from Spatial Coordinates.
get_square_coordinates()
This function computes the coordinates of a square's four corners based on a given center point and width.
lowresMapping()
Maps SM pixels to low resolution ST data
hiresMapping()
Maps SM pixels to high resolution ST data
combine.tr()
Combines rigid tranformation matrices

Pre-Processing Helper Functions

Helper functions for generating pre-processing plots

statPlot()
Helper function for QC plots by generating intensity count data