### Cardinal installation error output Source: https://genomicsmachinelearning.github.io/SpaMTP/articles/SpaMTP.html Example error output when Cardinal fails to install due to missing EBImage dependency and fftw3.h header. ```text ERROR: dependency ‘EBImage’ is not available for package ‘Cardinal’ BiocManager::install("EBImage") fftwtools.c:28:9: fatal error: fftw3.h: No such file or directory 28 | #include | ^~~~~~~~~ ``` -------------------------------- ### Example call with transform = TRUE Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/metaspace_to_feature_matrix.html Example call to metaspace_to_feature_matrix with transform = TRUE, as shown in the documentation examples section. ```R # metaspace_to_feature_matrix(mtx, transform = TRUE) ``` -------------------------------- ### Cairo installation error output Source: https://genomicsmachinelearning.github.io/SpaMTP/articles/SpaMTP.html Example error output when Cairo fails to install due to missing cairo.h. Use this to identify the issue. ```text checking if R was compiled with the RConn patch... no checking for cairo.h... no configure: error: Cannot find cairo.h! Please install cairo (http://www.cairographics.org/) and/or set CAIRO_CFLAGS/LIBS correspondingly. ERROR: configuration failed for package ‘Cairo’ ``` -------------------------------- ### MZRidgePlot example Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/MZRidgePlot.html Example call to MZRidgePlot, grouping by the 'sample' metadata column. This is the only example provided. ```r # MZRidgePlot(SeuratObj, group.by = "sample") ``` -------------------------------- ### pixelPlot example with SpatialFeaturPlot Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/pixelPlot.html Example call to pixelPlot, commented out, converting the output of SpatialFeaturPlot to pixel layout. The example is not executed. ```r #pixelPlot(SpatialFeaturPlot(SpaMTP.obj, features = "nFeature_Spatial")) ``` -------------------------------- ### Example: Filtering and running proc_db Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/proc_db.html Commented example showing how to load a database, filter by adduct (M+H) and natural elements, then run proc_db with ppm_threshold = 5. The example is commented out and uses placeholder objects. ```r # HMDB_db <- load("data/HMDB_1_names.rds") # mz_df <- SeuratObject[["Spatial"]][["mz"]] # mz_df$row_id <- seq(1, length(mz_df$mz)) ## 1) Filter DB by adduct. # db_1 <- db_adduct_filter(HMDB_db, c("M+H"), polarity = "pos") ## 2) only select natural elements # db_2 <- formula_filter(db_1) ## 3) search db against mz df return results # db_3 <- proc_db(mz_df, db_2, ppm_threshold = 5) ``` -------------------------------- ### DEMsHeatmap example usage Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/DEMsHeatmap.html Example calls to FindAllDEMs and DEMsHeatmap, commented out. The example shows how to generate a heatmap from edgeR output. ```R # DEMs <- FindAllDEMs(SeuratObj, "sample") # DEMsHeatmap(DEMs) ``` -------------------------------- ### BinSpaMTP example call Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/BinSpaMTP.html Example call to BinSpaMTP with a resolution of 10 ppm and return.only.mtx = TRUE, which returns only the binned intensity matrix. The example is commented out in the source. ```r #BinSpaMTP(spamtp.obj, resolution = 10, units = "ppm", return.only.mtx = TRUE) ``` -------------------------------- ### metaspace_client example Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/metaspace_client.html Example of creating a client, commented out. Use this to instantiate the client for querying METASPACE data. ```r # ms <- metaspace_client() ``` -------------------------------- ### Install rgoslin via mamba Source: https://genomicsmachinelearning.github.io/SpaMTP/articles/SpaMTP.html Alternative installation of rgoslin using mamba. ```bash mamba install bioconductor-rgoslin ``` -------------------------------- ### LoadSM example usage Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/LoadSM.html Example call to LoadSM, commented out, showing how to specify file name, folder, mass range, resolution, and assay. The example is provided in the documentation but is not executed. ```R # data <-LoadSM(name = "run1", folder = "/Documents/SpaMTP_test_data/", mass.range = c(160,1500), resolution = 10, assay = "Spatial") ``` -------------------------------- ### AddFMP10Annotations example call Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/AddFMP10Annotations.html Example call to AddFMP10Annotations with only.fmp.adduct set to FALSE. This is the only example provided in the documentation. ```R # AddFMP10Annotations(spamtp, only.fmp.adduct = FALSE) ``` -------------------------------- ### run_DE example with run_pooling Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/run_DE.html Example of running run_DE() on pooled data, with commented-out run_pooling() call. The example uses n=3, logFC_threshold=1.2, annotation.column='all_IsomerNames', and assay='Spatial'. ```r # pooled_obj <- run_pooling(SeuratObj, "sample", n = 3) # run_DE(pooled_obj, SeuratObj, "sample", "~/Documents/DE_output/", "run_1", n = 3, logFC_threshold = 1.2, annotation.column = "all_IsomerNames", assay = "Spatial") ``` -------------------------------- ### Install SpaMTP and load libraries Source: https://genomicsmachinelearning.github.io/SpaMTP/articles/Single_Cell_MultiOmics.html Install SpaMTP from GitHub if not already installed, then load required libraries: SpaMTP, Cardinal, Seurat, dplyr, and ggplot2. ```R ## Install SpaMTP if not previously installed if (!require("SpaMTP")) devtools::install_github("GenomicsMachineLearning/SpaMTP") #General Libraries library(SpaMTP) library(Cardinal) library(Seurat) library(dplyr) library(ggplot2) ``` -------------------------------- ### Install SpaMTP from GitHub with devtools Source: https://genomicsmachinelearning.github.io/SpaMTP/index.html Installs the current version of SpaMTP from the GenomicsMachineLearning/SpaMTP repository using devtools. Requires devtools to be installed first. ```r if (!require("devtools", quietly = TRUE)) install.packages("devtools") devtools::install_github("GenomicsMachineLearning/SpaMTP") ``` -------------------------------- ### SpatialMZPlot example usage Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/SpatialMZPlot.html Example calls to SpatialMZPlot, showing how to plot specific m/z values and optionally set a plusminus threshold. The examples are commented out. ```r # SpatialMZPlot(SeuratObj, mzs = c(400.678, 300.1)) # SpatialMZPlot(SeuratObj, mzs = c(400.678, 300.1), plusminus = 0.05) ``` -------------------------------- ### SpatialMZAnnotationPlot usage examples Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/SpatialMZAnnotationPlot.html Two commented example calls showing how to plot metabolites with and without a plusminus threshold. The examples are commented out and use a placeholder SeuratObj. ```R # SpatialMZAnnotationPlot(SeuratObj, mzs = c("Glucose", "Glutamine")) # SpatialMZAnnotationPlot(SeuratObj, mzs = c("Glucose", "Glutamine"), plusminus = 0.05) ``` -------------------------------- ### CalculateSingleAnnotationStatistics example Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/CalculateSingleAnnotationStatistics.html Example usage with commented-out code. The example shows how to create a pathway object and then calculate annotation statistics for a specific m/z value. The code is commented out, indicating it is not run directly. ```r #data <- CreatePathwayObject(data,assay="SPT_pathway",slot = "scale.data") #CalculateSingleAnnotationStatistics(mz = "mz-674.2805",data = data,mz.assay = "SPM",pathway.assay = "pathway",mz.slot = "scale.data") ``` -------------------------------- ### Create conda environment and install SpaMTP dependencies Source: https://genomicsmachinelearning.github.io/SpaMTP/index.html Creates a conda environment with Python 3.10, R 4.4, and ImageMagick, then installs all required R and Bioconductor packages for SpaMTP. Finally runs dependencies.R to install SpaMTP. ```bash conda create --prefix [some-directory]/conda/spamtp python=3.10 r-base=4.4 imagemagick --y conda activate [some-directory]/conda/spamtp conda install -c conda-forge jupyter libconfig fontconfig freetype libtiff r-irkernel --y conda install --no-update-deps -c conda-forge r-here r-matrix r-Seurat r-SeuratObject r-hdf5r r-ggplot2 r-reshape2 r-patchwork fftw r-RCurl r-jpeg r-locfit r-ontologyindex --y conda install --no-update-deps -c conda-forge r-fields r-ggdendro r-ggnewscale r-magick r-naturalsort r-pheatmap r-sf r-shinyjs r-zeallot r-r.utils --y conda install --no-update-deps -c bioconda bioconductor-BiocGenerics bioconductor-enhancedvolcano bioconductor-biocparallel --y conda install --no-update-deps -c bioconda bioconductor-protgenerics bioconductor-s4vectors bioconductor-biobase --y conda install --no-update-deps -c bioconda bioconductor-edger bioconductor-fgsea bioconductor-limma bioconductor-scater bioconductor-singlecellexperiment --y conda install --no-update-deps -c bioconda bioconductor-delayedmatrixstats bioconductor-hdf5array bioconductor-rhdf5 bioconductor-rhdf5lib --y conda install --no-update-deps -c bioconda bioconductor-msnbase bioconductor-ebimage==4.48.0-0 --y Rscript dependencies.R ``` -------------------------------- ### Example: save_pheatmap_as_pdf call Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/save_pheatmap_as_pdf.html Example call to save a pheatmap plot to a PDF file. The filename argument is a full filepath. ```r # save_pheatmap_as_pdf(pheatmap, filename = "/Documents/plots/pheatmap1") ``` -------------------------------- ### DensityMap example call Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/DensityMap.html Example call to DensityMap with a SpaMTP Seurat object. The actual object is commented out. ```r # DensityMap(SpaMTP.obj) ``` -------------------------------- ### Install rgoslin via BiocManager Source: https://genomicsmachinelearning.github.io/SpaMTP/articles/SpaMTP.html Installs the rgoslin package using BiocManager. ```R BiocManager::install("rgoslin") ``` -------------------------------- ### Install and import R libraries for SpaMTP analysis Source: https://genomicsmachinelearning.github.io/SpaMTP/articles/Annotation_Refinement.html Installs SpaMTP if not already installed and loads required R libraries including SpaMTP, Cardinal, Seurat, dplyr, tidyr, ggplot2, EnhancedVolcano, and viridis. Run this before any SpaMTP analysis. ```R ## Install SpaMTP if not previously installed if (!require("SpaMTP")) devtools::install_github("GenomicsMachineLearning/SpaMTP") #General Libraries library(SpaMTP) library(Cardinal) library(Seurat) library(dplyr) library(tidyr) #For plotting + DE plots library(ggplot2) library(EnhancedVolcano) library(viridis) ``` -------------------------------- ### AddCustomMZAnnotations example usage Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/AddCustomMZAnnotations.html Example usage of AddCustomMZAnnotations, commented out. It shows passing a SpaMTP object and an annotation data frame. ```r # annotated_data <- AddCustomMZAnnotations(SpaMTP.obj, annotation.df) ``` -------------------------------- ### Install and load required R packages Source: https://genomicsmachinelearning.github.io/SpaMTP/articles/human_brain_tissue_analysis.html Loads SpaMTP, Seurat, dplyr, ggplot2, viridis, and patchwork for the tutorial. Must be run before any analysis steps. ```R library(SpaMTP) library(Seurat) library(dplyr) library(ggplot2) library(viridis) library(patchwork) ``` -------------------------------- ### Install r-cairo via conda Source: https://genomicsmachinelearning.github.io/SpaMTP/articles/SpaMTP.html Installs the r-cairo package via conda-forge to resolve Cairo installation issues. ```bash conda install conda-forge::r-cairo ``` -------------------------------- ### bin.mz example (commented out) Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/bin.mz.html Example usage of bin.mz, commented out. It shows how to call bin.mz with a Seurat object and a vector of m/z values. ```r # mz_values <- plusminus(SeuratObj, 448.2, 0.05) # bin.mz(SeuratObj, mz_values) ``` -------------------------------- ### PlotSinglePathwaySpatially example usage Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/PlotSinglePathwaySpatially.html Example usage of PlotSinglePathwaySpatially with a glycolysis pathway list and a SpaMTP Seurat object. The example is commented out. ```R #glycolysis_list <- list("Glycolysis" = c("RAMP_C_000218730","RAMP_G_000012583","RAMP_G_000001171","RAMP_G_000007564","RAMP_C_000218226","RAMP_C_000040403","RAMP_C_000001115","RAMP_G_000008859")) #PlotSinglePathwaySpatially(glycolysis_list, spamtp_obj) ``` -------------------------------- ### Build SpaMTP Apptainer image from definition file Source: https://genomicsmachinelearning.github.io/SpaMTP/index.html Builds a SpaMTP Apptainer image from scratch using the spamtp.def definition file. Requires environment-linux.yml, dependencies.R, and spamtp.def files. ```bash apptainer build spamtp.sif spamtp.def ``` -------------------------------- ### Plot3DFeature example usage Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/Plot3DFeature.html Example call to Plot3DFeature with two features, specifying assays and an image to display. The example is commented out. ```R # Plot3DFeature(data = my_data, features = c("gene1", "gene2"), assays = c("SPT", "SPM"), show.image = "slice1") ``` -------------------------------- ### Load_METASPACE example call Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/Load_METASPACE.html Example call to Load_METASPACE with a dataset ID, FDR threshold, database, and relative normalization enabled. The code is commented out. ```r # Load_METASPACE(dataset_id = "2020-12-07_03h16m14s", fdr = 0.1, database= c("HMDB", "v4"), relative = TRUE) ``` -------------------------------- ### Example: CreateMergedModalityAssay usage Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/CreateMergedModalityAssay.html Example call to CreateMergedModalityAssay, merging assays 'SPM' and 'SPT' into a new assay named 'merged'. The example is commented out. ```r # merged_obj <- CreateMergedModalityAssay(SpaMTP = spamtp_obj, assays.to.merge = c("SPM", "SPT"),new.assay = "merged") ``` -------------------------------- ### Example: Filter database to natural elements Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/formula_filter.html Example workflow: first filter the database by adduct (commented out), then refine to only include natural elements using formula_filter. ```R ## Get filtered DB by adduct # db_1 <- db_adduct_filter(db, test_add_pos, polarity = "pos") ## Refine to only include natural elements # db_2 <- formula_filter(db_1) ``` -------------------------------- ### FindRegionalPathways example call Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/FindRegionalPathways.html Example call to FindRegionalPathways. Note: the example uses a 'polarity' argument that is not documented in the function signature; it may be outdated or incomplete. ```R # SpaMTP = FindRegionalPathways(SpaMTP, polarity = "positive") ``` -------------------------------- ### get_metaspace example call Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/get_metaspace.html Example call to get_metaspace with a specific dataset ID, FDR threshold, database, and relative normalization. The call is commented out, indicating it is for demonstration. ```R # get_metaspace(dataset_id = "2020-12-07_03h16m14s", fdr = 0.1, database= c("HMDB", "v4"), relative = TRUE) ``` -------------------------------- ### FishersPathwayAnalysis example calls for mzs, metabolites, and combined modes Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/FishersPathwayAnalysis.html Commented examples showing how to run the function in 'mzs' mode, 'metabolites' mode, and combined 'metabolites' and 'genes' mode. These are illustrative and not executable as-is. ```r ## Running in 'mzs' mode: # FishersPathwayAnalysis(Analyte = list("mzs" = mz_values), ppm_error = 3) ## Running in 'metabolites' mode # FishersPathwayAnalysis(Analyte = list("metabolites" = metabolite_ids)) ## Running 'metabolites' and 'genes' combined # FishersPathwayAnalysis(Analyte = list("metabolites" = metabolite_ids, "genes" = gene_names)) ``` -------------------------------- ### RunRAMPgeseca example Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/RunRAMPgeseca.html Example usage commented out. It shows how to run the function with minSize=15 and maxSize=500 on a feature loadings matrix from a SpaMTP object. ```r # E <- SpaMTP@reductions$pca.rev@feature.loadings # sig_pathways <- RunRAMPgeseca(E, minSize=15, maxSize=500) ``` -------------------------------- ### PlotSinglePathway example usage Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/PlotSinglePathway.html Commented example showing how to call PlotSinglePathway with a glycolysis pathway list and a SpaMTP Seurat object, using the 'umap' reduction. The pathway list is commented out, indicating it should be defined beforehand. ```r #glycolysis_list <- list("Glycolysis" = c("RAMP_C_000218730","RAMP_G_000012583","RAMP_G_000001171","RAMP_G_000007564","RAMP_C_000218226","RAMP_C_000040403","RAMP_C_000001115","RAMP_G_000008859")) #PlotSinglePathway(glycolysis_list, spamtp_obj, reduction = "umap") ``` -------------------------------- ### MassIntensityPlot examples Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/MassIntensityPlot.html Four commented examples showing different ways to call MassIntensityPlot: plotting the whole tissue, grouping by 'ssc', splitting by 'ssc' with m/z labels, and splitting with metabolite annotations. Note that the examples are commented out and the last example uses a 'plot.layout' argument not in the function signature. ```R ## Plot mean of whole tissue section # MassIntensityPlot(SeuratObj) ## Plot ssc segmentation groups on the same plot # MassIntensityPlot(SeuratObj, group.by = "ssc") ## Plot mean of each ssc segmentation of separate plot with mz annotations # MassIntensityPlot(SeuratObj, split.by= "ssc", mz.labels = c(329.166), plot.layout = c(5,2)) ## Plot mean of each ssc segmentation of separate plot with metabolite annotations # MassIntensityPlot(SeuratObj, split.by= "ssc", mz.labels = c(329.166), label.annotations = TRUE) ``` -------------------------------- ### ConvertSeuratToCardinal example Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/ConvertSeuratToCardinal.html Example call to ConvertSeuratToCardinal with feature.metadata = TRUE. The code is commented out. ```R # cardinal.obj <- ConvertSeuratToCardinal(SeuratObject, feature.metadata = TRUE) ``` -------------------------------- ### AnnotateBigData example with Cardinal data Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/AnnotateBigData.html Example workflow: reads an imzML file with Cardinal, extracts m/z values, annotates them with HMDB_db at 3 ppm tolerance and negative polarity adducts, subsets the Cardinal object to annotated peaks, and converts to a SpaMTP Seurat object. The code is commented out. ```R #cardinal <- readImzML("./Test_Data/Spotted/test_data1") #mzs <- data.frame(Cardinal::featureData(cardinal))$mz #results <- AnnotateBigData(mzs, db = HMDB_db, ppm_error = 3, adducts = c("M-H", "M+Cl"), polarity = "negative") #cardinal_subset <- Cardinal::subset(cardinal, mz %in% results$observed_mz) #SpaMTP_data <- CardinalToSeurat(cardinal_subset) ``` -------------------------------- ### GetMZMetadata examples Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/GetMZMetadata.html Two commented example calls. The first retrieves all isomer names for m/z 'mz-100'. The second retrieves metabolite annotation IDs for the same m/z value using the 'all_Isomers' column. ```r # GetMZMetadata(SpaMTP, mz = "mz-100", metadata.column = "all_IsomerNames") ##### Example for getting metabolite annotation IDs for a m/z value # GetMZMetadata(SpaMTP, mz = "mz-100", metadata.column = "all_Isomers") ``` -------------------------------- ### RefineLipids usage example Source: https://genomicsmachinelearning.github.io/SpaMTP/reference/RefineLipids.html Example call to RefineLipids with a data frame containing lipid annotations. The function simplifies annotations to general terms, groups, and classes. The example is commented out and uses default parameters. ```R # RefineLipids(DEPs_df) ``` -------------------------------- ### Install Cardinal directly via conda Source: https://genomicsmachinelearning.github.io/SpaMTP/articles/SpaMTP.html Installs Cardinal directly from bioconda if other methods fail. ```bash conda install bioconda::bioconductor-cardinal ```