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)

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

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
AddCustomMZAnnotations()
Assign custom annotations to m/z values
AddFMP10Annotations()
Annotates FMP10 matrix data
SearchAnnotations()
Find Annotation
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
getRefinedAnnotations()
Refines and reduces m/z annotations

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

Metabolic and Transcriptomic Pathway Visualisation

Functions used to visualise pathway analysis results

VisualisePathways()
Visualise Significant Pathways
PlotRegionalPathways()
Plot significantly enriched pathways per region

Pathway Network Plotting

Functions used to generate network plots for specified patheays

PathwayNetworkPlots()
Constructs an interactive network for exploring spatial metabolomics and transcriptomics data.

PCA Metabolite Analysis

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

RunMetabolicPCA()
Generates PCA analysis results for a SpaMTP Seurat Object

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.
AlignSpatialOmics()
Interactive app for SM and ST coordinate alignment
MultiOmicIntegration()
Mult-Omic data integration

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

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

Reference Metabolite Datasets

Metabolite datasets used for annotating m/z masses

HMDB_db
HMDB_db: A cleaned version of the reference metabolomics dataset from the Human Metabolome Database (HMDB)
Lipidmaps_db
Lipidmaps_db: A cleaned version of the lipid database from LIPID MAPS
Chebi_db
Chebi_db: Cleaned ChEBI (Chemical entities of biological interest) reference dataset
GNPS_db
GNPS_db: A cleaned database of metabolites from GNPS
filtered_fmp10
filtered_fmp10: data.frame containing FMP10+ metabolite mappings

Metabolic Pathway Datasets

Various datasets required for pathway analysis

adduct_file
adduct_file: A dataframe containing possible adducts used for pathway analysis
analyte
analyte: A dataframe containing ID's of possible RAMP analytes
analytehaspathway
analytehaspathway: A dataframe containing RAMP_pathway ID's
chem_props
chem_props: A database containing the chemical properties and metadata of each RAMP_DB analyte
pathway
pathway: A dataframe containing RAMP_DB pathways and their relative metadata
source_df
source_df: A dataframe containing source information about RAMP_ID analyte used for analysis

Pathway Network Datasets

Various datasets required for generated pathway network plots

RAMP_hmdb
RAMP_hmdb: A list containing network plot information about pathways from the HMDB database
RAMP_Reactome
RAMP_Reactome: A list containing network plot information about pathways from the Reactome database
RAMP_kegg
RAMP_kegg: A list containing network plot information about pathways from the KEGG database
RAMP_wikipathway
RAMP_wikipathway: A list containing network plot information about pathways from the Wiki database
reaction_type
reaction_type: data.frame containing reaction type mappings

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

verbose_message()
Helper function for suppressing function progress messages
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.
bin_SpectralImagingExperiment()
Generate binned intensity matrix based on reference peaks generated via Cardinal
bin_cardinal()
Bins spectral data generated by Cardinal from a matter object to a Matrix object

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 sotred 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
is_formula_valid()
Checks if a formula contains only the allowed elements
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()
Calculates the ppm range and check if mz values are within the range
  • Returns TRUE if match is found and false if no match.

proc_db()
Searches observed mz values against the data base list and returns matching annotations

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

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
rescale()
Helper function to rescale a sampled matrix
ResizeMat()
Helper function to resize a matrix back to its original layout after sampling

Multi-Omic Helper Functions

Helper functions used in multi-omic analysis functions

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
translate()
Creates a transformation matrix that translates an object in 2D
mirror()
Creates a transformation matrix that mirrors an object in 2D along either the x axis or y axis around its center of mass
stretch()
Stretch along angle
rigid.rot()
Creates a transformation matrix for rotation
rigid.transf()
Creates a transformation matrix for rotation and translation
rigid.transl()
Creates a transformation matrix for translation with an offset of (h, k)
rigid.refl()
Creates a transformation matrix for reflection
rigid.stretch()
Creates a transformation matrix for stretching
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