### Setup and Load Giotto Suite and Example Datasets Source: https://giottosuite.com/articles/networks Installs and loads the Giotto Suite, Giotto Data, and sets up the Python environment. It then loads example 'vizgen' (MERSCOPE) and 'starmap' datasets for spatial analysis. ```R # Ensure Giotto Suite is installed if(!"Giotto" %in% installed.packages()) { pak::pkg_install("drieslab/Giotto") } # Ensure Giotto Data is installed if(!"GiottoData" %in% installed.packages()) { pak::pkg_install("drieslab/GiottoData") } library(Giotto) # Ensure the Python environment for Giotto has been installed genv_exists <- checkGiottoEnvironment() if(!genv_exists){ # The following command need only be run once to install the Giotto environment installGiottoEnvironment() } # load the object mer <- GiottoData::loadGiottoMini("vizgen") activeSpatUnit(mer) <- "aggregate" star <- GiottoData::loadGiottoMini("starmap") ``` -------------------------------- ### Install and Setup Giotto Environment Source: https://giottosuite.com/articles/openst_mouse_hippocampus Ensures the Giotto Suite and its Python environment are installed. It checks for existing installations and installs them if necessary. This is a prerequisite for using Giotto functionalities. ```R if(!'Giotto' %in% installed.packages()) { pak::pkg_install("drieslab/Giotto") } genv_exists <- Giotto::checkGiottoEnvironment() if(!genv_exists){ # The following command need only be run once to install the Giotto environment. Giotto::installGiottoEnvironment() } ``` -------------------------------- ### Install and Setup Giotto Environment Source: https://giottosuite.com/articles/mouse_embryo_dbitseq Ensures the Giotto package and its required Python environment are installed. This is a prerequisite for running the tutorial and involves checking for existing installations and initiating installation if necessary. ```r # Ensure Giotto Suite is installed if(!'Giotto' %in% installed.packages()) { pak::pkg_install("drieslab/Giotto") } # Ensure the Python environment for Giotto has been installed genv_exists <- Giotto::checkGiottoEnvironment() if(!genv_exists){ # The following command need only be run once to install the Giotto environment Giotto::installGiottoEnvironment() } ``` -------------------------------- ### Run Giotto Suite Convenient Installer Source: https://giottosuite.com/articles/installation Executes the `suite_install()` function from the 'GiottoUtils' package to install Giotto Suite. The `ref` parameter should be set to the desired version or branch of the suite. ```r GiottoUtils::suite_install(ref = ???) ``` -------------------------------- ### Install and Setup Giotto Suite and Dependencies Source: https://giottosuite.com/articles/resolve_biosciences This snippet ensures that the Giotto Suite and its helper module GiottoData are installed. It also checks for and installs the necessary Python environment for Giotto, which is crucial for its functionality. This is a one-time setup process. ```R # Ensure Giotto Suite is installed. if (!"Giotto" %in% installed.packages()) { pak::pkg_install("drieslab/Giotto") } # Ensure GiottoData, a small, helper module for tutorials, is installed. if (!"GiottoData" %in% installed.packages()) { pak::pkg_install("drieslab/GiottoData") } # Ensure the Python environment for Giotto has been installed. genv_exists <- Giotto::checkGiottoEnvironment() if (!genv_exists) { # The following command need only be run once to install the Giotto environment. Giotto::installGiottoEnvironment() } ``` -------------------------------- ### Install and Setup Giotto Suite Source: https://giottosuite.com/articles/vizgen_mouse_brain Installs the Giotto Suite, GiottoData, and the Python environment required for Giotto. It checks for existing installations and installs them if not found. This ensures all necessary components are available for subsequent analysis. ```r # Ensure Giotto Suite is installed. if(!"Giotto" %in% installed.packages()) { pak::pkg_install("drieslab/Giotto") } # Ensure GiottoData, a small, helper module for tutorials, is installed. if(!"GiottoData" %in% installed.packages()) { pak::pkg_install(("drieslab/GiottoData") } # Ensure the Python environment for Giotto has been installed. genv_exists <- Giotto::checkGiottoEnvironment() if(!genv_exists){ # The following command need only be run once to install the Giotto environment. Giotto::installGiottoEnvironment() } ``` -------------------------------- ### Install and Setup Giotto Suite and Dependencies Source: https://giottosuite.com/articles/tesselation Ensures that the Giotto and GiottoData packages are installed and loads the necessary libraries. It also checks and installs the Giotto Python environment if it's not already set up. ```r if(!"Giotto" %in% installed.packages()) { pak::pkg_install("drieslab/Giotto") } if(!"GiottoData" %in% installed.packages()) { pak::pkg_install("drieslab/GiottoData") } library(Giotto) genv_exists <- checkGiottoEnvironment() if(!genv_exists){ installGiottoEnvironment() } ``` -------------------------------- ### Install and Setup Giotto Suite and Dependencies Source: https://giottosuite.com/articles/merfish_mouse_sagittal_bil Installs the Giotto Suite and its helper module GiottoData using the 'pak' package manager. It also checks for and installs the necessary Giotto Python environment. This is a prerequisite for running Giotto functionalities. ```R if(!"Giotto" %in% installed.packages()) { pak::pkg_install("drieslab/Giotto") } if(!"GiottoData" %in% installed.packages()) { pak::pkg_install(("drieslab/GiottoData") } genv_exists <- Giotto::checkGiottoEnvironment() if(!genv_exists){ Giotto::installGiottoEnvironment() } ``` -------------------------------- ### Install Giotto Suite and Data, Load Example Dataset Source: https://giottosuite.com/articles/hvf Installs the Giotto Suite and Giotto Data R packages if not already present, then loads a mini 'visium' dataset. It also checks and installs the necessary Python environment for Giotto. ```R if(!"Giotto" %in% installed.packages()) { pak::pkg_install("drieslab/Giotto") } if(!"GiottoData" %in% installed.packages()) { pak::pkg_install("drieslab/GiottoData") } library(Giotto) genv_exists <- checkGiottoEnvironment() if(!genv_exists){ installGiottoEnvironment() } # load the object g <- GiottoData::loadGiottoMini("visium") ``` -------------------------------- ### Install Giotto Suite using pak Source: https://giottosuite.com/articles/installation Installs the currently released version of Giotto Suite using the {pak} package manager. It first checks if {pak} is installed and then uses `pak::pkg_install()` to install Giotto from the 'drieslab/Giotto' repository, automatically handling dependencies. ```r if(!"pak" %in% installed.packages()) { install.packages("pak") } pak::pkg_install("drieslab/Giotto") ``` -------------------------------- ### Install Giotto Suite and GiottoData Source: https://giottosuite.com/articles/filtering Code to ensure the necessary Giotto Suite and GiottoData packages are installed for running the examples. ```APIDOC ## Install Giotto Suite and GiottoData ### Description This code block checks if the Giotto and GiottoData packages are installed and installs them if they are not. This is a prerequisite for running the subsequent Giotto Suite examples. ### Method `if` condition with `pak::pkg_install()` ### Parameters None ### Request Example ```R # Ensure Giotto Suite is installed. if(!"Giotto" %in% installed.packages()) { pak::pkg_install("drieslab/Giotto") } # Ensure GiottoData is installed. if(!"GiottoData" %in% installed.packages()) { pak::pkg_install("drieslab/GiottoData") } library(Giotto) ``` ### Response #### Success Response (Installation) Packages are installed and loaded successfully. #### Response Example (No specific output, successful installation and library load) ``` -------------------------------- ### Install Giotto Suite Development Branch using devtools Source: https://giottosuite.com/articles/installation Installs development versions of Giotto Suite modules using `devtools::install_github()`. It first ensures 'devtools' is installed and then installs from a specified development branch path. Users should avoid updating other Giotto modules if prompted. ```r if(!"devtools" %in% installed.packages()) { install.packages("devtools") } devtools::install_github("[dev branch path]") ``` -------------------------------- ### Install and Load Giotto Suite Source: https://giottosuite.com/articles/core_functions Installs the Giotto Suite if not already present and ensures the necessary Python environment is set up. It then loads a mini example dataset for visualization. ```r # Ensure Giotto Suite is installed. if(!"Giotto" %in% installed.packages()) { pak::pkg_install("drieslab/Giotto") } # Ensure the Python environment for Giotto has been installed. genv_exists <- Giotto::checkGiottoEnvironment() if(!genv_exists){ # The following command need only be run once to install the Giotto environment. Giotto::installGiottoEnvironment() } library(Giotto) g <- GiottoData::loadGiottoMini("vizgen") # drop pre-computed information (these steps can be ignored) data_list <- c(g[["images"]], g[["spatial_info"]], g[["feat_info"]]) g <- giotto() g <- setGiotto(g, data_list) ``` -------------------------------- ### Install and Setup Giotto Suite Environment Source: https://giottosuite.com/articles/general_workflow Ensures the Giotto Suite R package and its Python environment are installed. This is a prerequisite for using Giotto functionalities. It checks for existing installations and installs them if necessary. ```R if(!"Giotto" %in% installed.packages()) { pak::pkg_install("drieslab/Giotto") } genv_exists <- Giotto::checkGiottoEnvironment() if(!genv_exists){ # The following command need only be run once to install the Giotto environment. Giotto::installGiottoEnvironment() } ``` -------------------------------- ### Setup Giotto and Load Data Source: https://giottosuite.com/articles/dimension_reduction Installs and loads the Giotto Suite and GiottoData packages, checks and installs the Giotto R environment, and loads a mini visium dataset. Ensure R is updated and the environment is configured for package installation. ```R # Ensure Giotto Suite is installed if(!"Giotto" %in% installed.packages()) { pak::pkg_install("drieslab/Giotto") } # Ensure Giotto Data is installed if(!"GiottoData" %in% installed.packages()) { pak::pkg_install("drieslab/GiottoData") } library(Giotto) # Ensure the Python environment for Giotto has been installed genv_exists <- checkGiottoEnvironment() if(!genv_exists){ # The following command need only be run once to install the Giotto environment installGiottoEnvironment() } ``` ```R # load the object g <- GiottoData::loadGiottoMini("visium") ``` -------------------------------- ### Setup Giotto Environment and Dependencies Source: https://giottosuite.com/articles/VisiumHD_Human_Colorectal_Cancer Ensures the Giotto Suite is installed and its Python environment is set up. It checks for the 'Giotto' package and installs it if missing, then verifies and installs the Giotto Python environment if necessary. ```r # Verify that the Giotto Suite is installed. if(!"Giotto" %in% installed.packages()) { pak::pkg_install("drieslab/Giotto") } # check if the Python environment for Giotto has been installed. genv_exists <- Giotto::checkGiottoEnvironment() if(!genv_exists){ # The following command need only be run once to install the Giotto environment. Giotto::installGiottoEnvironment() } ``` -------------------------------- ### Setup and Load Giotto Suite Source: https://giottosuite.com/articles/kriging Installs and loads the Giotto Suite R package, including checking and installing the required Python environment for Giotto functionality. This is a prerequisite for all subsequent analyses. ```R if(!'Giotto' %in% installed.packages()) { pak::pkg_install("drieslab/Giotto") } library(Giotto) # Ensure the Python environment for Giotto has been installed genv_exists <- checkGiottoEnvironment() if(!genv_exists){ # The following command need only be run once to install the Giotto environment installGiottoEnvironment() } ``` -------------------------------- ### Example: Running and Loading HMRF (R) Source: https://giottosuite.com/reference/loadHMRF Demonstrates the process of running an HMRF analysis using `doHMRF` and then loading the results with `loadHMRF`. This example highlights the necessary arguments for both functions, including spatial genes, output folder, betas, and the Python path. Note that `smfishHmrf` package installation might be required. ```r g <- GiottoData::loadGiottoMini("visium") x <- tempdir() doHMRF(g, spatial_genes = c("Gna12", "Ccnd2"), output_folder = x, betas = c(0, 2, 50) ) loadHMRF( output_folder_used = x, betas_used = c(0, 2, 50), python_path_used = NULL ) ``` -------------------------------- ### Install and Setup Giotto Suite and Environment (R) Source: https://giottosuite.com/articles/hmrf Installs the Giotto and GiottoData packages if they are not already installed. It also checks and installs the necessary Python environment for Giotto, which is crucial for its functionality. This setup is a prerequisite for using Giotto's spatial analysis tools. ```R if(!"Giotto" %in% installed.packages()) { pak::pkg_install("drieslab/Giotto") } if(!"GiottoData" %in% installed.packages()) { pak::pkg_install("drieslab/GiottoData") } library(Giotto) # Ensure the Python environment for Giotto has been installed genv_exists <- checkGiottoEnvironment() if(!genv_exists){ # The following command need only be run once to install the Giotto environment installGiottoEnvironment() } ``` -------------------------------- ### Install and Load Giotto Suite and Dependencies Source: https://giottosuite.com/articles/interactive_selection Ensures Giotto Suite and GiottoData are installed and loaded, along with checking and installing the Giotto Python environment. This is a prerequisite for running the tutorial. ```R if(!"Giotto" %in% installed.packages()) { pak::pkg_install("drieslab/Giotto") } if(!"GiottoData" %in% installed.packages()) { pak::pkg_install("drieslab/GiottoData") } library(Giotto) genv_exists <- checkGiottoEnvironment() if(!genv_exists){ installGiottoEnvironment() } ``` -------------------------------- ### Install and Setup Giotto Suite Environment Source: https://giottosuite.com/articles/singlecell_lung_adenocarcinoma Ensures the Giotto Suite and its Python environment are installed. It checks for existing installations and installs them if necessary. This is a prerequisite for running the vignette. ```R if(!"Giotto" %in% installed.packages()) { pak::pkg_install("drieslab/Giotto") } genv_exists <- Giotto::checkGiottoEnvironment() if(!genv_exists){ # The following command need only be run once to install the Giotto environment. Giotto::installGiottoEnvironment() } ``` -------------------------------- ### Install Giotto Suite and Helper Packages Source: https://giottosuite.com/articles/osmfish_mouse_ss_cortex Installs the Giotto package and the GiottoData helper module if they are not already installed. It also ensures the Python environment required by Giotto is set up. ```r # Ensure Giotto Suite and GiottoData, a small, helper module for tutorials, are installed. pkgs <- c("Giotto", "GiottoData") need_install <- pkgs[sapply(pkgs, function(pkg) !requireNamespace(pkg, quietly = TRUE))] if (length(need_install) > 0L) { if (!requireNamespace("pak", quietly = TRUE)) install.packages("pak") pak::pak(sprintf("drieslab/%s", need_install)) } # Ensure the Python environment for Giotto has been installed. genv_exists <- Giotto::checkGiottoEnvironment() if(!genv_exists){ # The following command need only be run once to install the Giotto environment. Giotto::installGiottoEnvironment() } ``` -------------------------------- ### Install Specific Matrix Package Version for R < 4.4.0 Source: https://giottosuite.com/articles/installation Installs version '1.6-5' of the 'Matrix' R package. This is crucial for R versions older than 4.4.0 when installing Giotto with {pak} to avoid potential installation conflicts. ```r # devtools::install_version("Matrix", version = "1.6-5") ``` -------------------------------- ### Install and Initialize Giotto Suite and Data Source: https://giottosuite.com/articles/visualizations Ensures that the Giotto and GiottoData R packages are installed and that the necessary Python environment for Giotto is set up. This is a prerequisite for using Giotto's functionalities. ```r if(!"Giotto" %in% installed.packages()) { pak::pkg_install("drieslab/Giotto") } # Ensure Giotto Data is installed if(!"GiottoData" %in% installed.packages()) { pak::pkg_install("drieslab/GiottoData") } # Ensure the Python environment for Giotto has been installed genv_exists <- Giotto::checkGiottoEnvironment() if(!genv_exists){ # The following command need only be run once to install the Giotto environment Giotto::installGiottoEnvironment() } ``` -------------------------------- ### Configure Giotto Instructions and Prepare Data Source: https://giottosuite.com/articles/seqfish_cortex Sets up Giotto instructions for saving and displaying plots, and creates a Giotto object from expression, location, and metadata files. It also handles stitching of multiple fields of view by creating an offset file and merging location data with annotations. ```r # set Giotto instructions results_folder <- "/path/to/results/" instructions <- createGiottoInstructions( save_plot = TRUE, show_plot = FALSE, return_plot = FALSE, save_dir = results_folder, python_path = NULL ) # create giotto object from provided paths #### expr_path <- paste0(data_path, "cortex_svz_expression.txt") loc_path <- paste0(data_path, "cortex_svz_centroids_coord.txt") meta_path <- paste0(data_path, "cortex_svz_centroids_annot.txt") # This dataset contains multiple field of views which need to be stitched together # first merge location and additional metadata SS_locations <- data.table::fread(loc_path) cortex_fields <- data.table::fread(meta_path) SS_loc_annot <- data.table::merge.data.table(SS_locations, cortex_fields, by = "ID") SS_loc_annot[, ID := factor(ID, levels = paste0("cell_", 1:913))] data.table::setorder(SS_loc_annot, ID) # create file with offset information my_offset_file <- data.table::data.table( field = c(0, 1, 2, 3, 4, 5, 6), x_offset = c(0, 1654.97, 1750.75, 1674.35, 675.5, 2048, 675), y_offset = c(0, 0, 0, 0, -1438.02, -1438.02, 0) ) # create a stitch file stitch_file <- stitchFieldCoordinates( location_file = SS_loc_annot, offset_file = my_offset_file, cumulate_offset_x = TRUE, cumulate_offset_y = FALSE, field_col = "FOV", reverse_final_x = FALSE, reverse_final_y = TRUE ) stitch_file <- stitch_file[, .(ID, X_final, Y_final)] stitch_file$ID <- as.character(stitch_file$ID) my_offset_file <- my_offset_file[, .(field, x_offset_final, y_offset_final)] ``` -------------------------------- ### Install Giotto Suite and Dependencies Source: https://giottosuite.com/articles/spatial_genomics_mouse_kidney Installs the Giotto Suite, GiottoData, and ensures the necessary Python environment for Giotto is set up. This is a prerequisite for running the tutorial. ```R # Ensure Giotto Suite is installed if (!"Giotto" %in% installed.packages()) { pak::pkg_install("drieslab/Giotto") } # Ensure Giotto Data is installed if (!"GiottoData" %in% installed.packages()) { pak::pkg_install("drieslab/GiottoData") } # Ensure the Python environment for Giotto has been installed genv_exists <- Giotto::checkGiottoEnvironment() if (!genv_exists) { # The following command need only be run once to install the Giotto environment Giotto::installGiottoEnvironment() } ``` -------------------------------- ### Install GiottoUtils R Package Source: https://giottosuite.com/articles/installation Installs the 'GiottoUtils' R package, a prerequisite for using the `suite_install()` function. This command can also specify a particular branch using the `@branch` tag. ```r devtools::install_github("drieslab/GiottoUtils") # you can add the `@branch` desired tag here ``` -------------------------------- ### Install Giotto Suite and Dependencies Source: https://giottosuite.com/articles/mini_seqfish Installs the Giotto package, GiottoData helper module, and ensures the necessary Python environment for Giotto is set up. This is a prerequisite for running the analysis. ```r # Ensure Giotto Suite is installed. if(!"Giotto" %in% installed.packages()) { pak::pkg_install("drieslab/Giotto") } # Ensure GiottoData, a small, helper module for tutorials, is installed. if(!"GiottoData" %in% installed.packages()) { pak::pkg_install("drieslab/GiottoData") } # Ensure the Python environment for Giotto has been installed. genv_exists <- Giotto::checkGiottoEnvironment() if(!genv_exists){ # The following command need only be run once to install the Giotto environment. Giotto::installGiottoEnvironment() } ``` -------------------------------- ### Increase R Installation Timeout Source: https://giottosuite.com/articles/troubleshooting Increases the maximum download time limit for R packages to prevent installation timeouts. This is useful when installing large packages like Giotto. It checks the current timeout and sets it to at least 1000 seconds. ```r options(timeout = max(1000, getOption("timeout"))) ``` -------------------------------- ### Minimal Reproducible Example (R) Source: https://giottosuite.com/articles/github_issues Demonstrates how to create a minimal reproducible example in R, as recommended for GitHub issues. It shows basic code structure and how to format code snippets. ```R `x <- "hello world" print(x)` ``` -------------------------------- ### Install terra R Package Source: https://giottosuite.com/articles/installation Installs the 'terra' R package, a major dependency for Giotto Suite. This command is typically used on Windows and Mac systems. Linux users may require additional prerequisite installations like GDAL, GEOS, PROJ, and sqlite3. ```r install.packages("terra") ``` -------------------------------- ### Example: Load and Visualize CosMx Data with R Source: https://giottosuite.com/reference/importCosMx Demonstrates creating a CosmxReader, setting the directory and FOVs, and plotting the fields of view. It also shows how to load polygons, transcripts, and images, then integrate them into a Giotto object. ```R # Create a `CosmxReader` object reader <- importCosMx() if (FALSE) { # \dontrun{ # Set the cosmx_dir and fov parameters path <- "path/to/cosmx/dir" reader$cosmx_dir <- path reader$fov <- c(1, 4) plot(reader) # displays FOVs (top left corner) in px scale. # Load polygons, transcripts, and images polys <- reader$load_polys() tx <- reader$load_transcripts() imgs <- reader$load_images() # polygons (mask) and images loading supports multiple filepaths # This can be useful when loading AtoMx outputs polys <- reader$load_polys(path = list.files(path, pattern = "CellLabels_F", recursive = TRUE, full.names = TRUE )) imgs <- reader$load_images(path = list.files(path, pattern = "Composite_F", recursive = TRUE, full.names = TRUE )) # Create a `giotto` object and add the loaded data g <- giotto() g <- setGiotto(g, tx[["rna"]]) g <- setGiotto(g, polys) g <- addGiottoLargeImage(g, largeImages = imgs) force(g) } # } ``` -------------------------------- ### Example Usage of doLeidenCluster (R) Source: https://giottosuite.com/reference/doLeidenCluster An example demonstrating the usage of the doLeidenCluster function with a sample Giotto object. This example showcases loading a Giotto object and then applying the clustering function. Note that this specific example may produce an error if the 'igraph' Python module is not installed. ```R g <- GiottoData::loadGiottoMini("visium") #> 1. read Giotto object #> 2. read Giotto feature information #> 3. read Giotto spatial information #> 3.1 read Giotto spatial shape information #> 3.2 read Giotto spatial centroid information #> 3.3 read Giotto spatial overlap information #> 4. read Giotto image information #> python already initialized in this session #> active environment : '/usr/bin/python3' #> python version : 3.12 doLeidenCluster(g) #> Error in py_run_file_impl(file, local, convert): ModuleNotFoundError: No module named 'igraph' #> Run `reticulate::py_last_error()` for details. ``` -------------------------------- ### Install and Initialize Giotto Suite and Environment Source: https://giottosuite.com/articles/obj_create_mod Ensures the Giotto Suite and GiottoData packages are installed and the necessary Python environment for Giotto is set up. This involves checking for installed packages and conditionally installing them using `pak::pkg_install`. It also checks and installs the Giotto environment if it does not exist. ```r # Ensure Giotto Suite is installed. if(!"Giotto" %in% installed.packages()) { pak::pkg_install("drieslab/Giotto") } # Ensure the Python environment for Giotto has been installed. genv_exists <- Giotto::checkGiottoEnvironment() if(!genv_exists){ # The following command need only be run once to install the Giotto environment. Giotto::installGiottoEnvironment() } # Ensure Giotto Suite is installed. if(!"GiottoData" %in% installed.packages()) { pak::pkg_install("drieslab/GiottoData") } library(Giotto) ``` -------------------------------- ### Download Sample Data Source: https://giottosuite.com/articles/affine_registration Downloads the necessary 10x Genomics Visium v1 mouse brain datasets for two serial sections. These files are required for the spatial registration tutorial. ```bash wget https://cf.10xgenomics.com/samples/spatial-exp/1.0.0/V1_Mouse_Brain_Sagittal_Posterior/V1_Mouse_Brain_Sagittal_Posterior_spatial.tar.gz wget https://cf.10xgenomics.com/samples/spatial-exp/1.0.0/V1_Mouse_Brain_Sagittal_Posterior/V1_Mouse_Brain_Sagittal_Posterior_raw_feature_bc_matrix.h5 wget https://cf.10xgenomics.com/samples/spatial-exp/1.0.0/V1_Mouse_Brain_Sagittal_Posterior_Section_2/V1_Mouse_Brain_Sagittal_Posterior_Section_2_spatial.tar.gz wget https://cf.10xgenomics.com/samples/spatial-exp/1.0.0/V1_Mouse_Brain_Sagittal_Posterior_Section_2/V1_Mouse_Brain_Sagittal_Posterior_Section_2_raw_feature_bc_matrix.h5 ``` -------------------------------- ### Load Giotto Libraries and Set Working Directory Source: https://giottosuite.com/articles/osmfish_mouse_ss_cortex Loads the Giotto and GiottoData libraries and defines the directory where results will be saved. It also includes an option to specify a custom Python path. ```r library(Giotto) library(GiottoData) # 1. set working directory results_folder <- "/path/to/results/" # Optional: Specify a path to a Python executable within a conda or miniconda # environment. If set to NULL (default), the Python executable within the previously # installed Giotto environment will be used. python_path <- NULL # alternatively, "/local/python/path/python" if desired. ``` -------------------------------- ### Initialize Giotto Package and Instructions Source: https://giottosuite.com/articles/nemo_slideseq Loads the Giotto library and sets up analysis instructions, including specifying the results directory, Python path for Giotto, and plot saving options. The Python path can be set to NULL for automatic installation. ```R library(Giotto) # 1. set results directory results_folder <- "/path/to/results/" # 2. set giotto python path # set python path to your preferred python version path # set python path to NULL if you want to automatically install (only the 1st time) and use the giotto miniconda environment python_path <- NULL # 3. create giotto instructions instructions <- createGiottoInstructions(save_dir = results_folder, save_plot = TRUE, show_plot = FALSE, return_plot = FALSE, python_path = python_path) ``` -------------------------------- ### Example Usage of silhouetteRank in R Source: https://giottosuite.com/reference/silhouetteRank Demonstrates how to load a Giotto object and apply the silhouetteRank function. Note that this example may produce an error if the 'scipy' Python module is not installed. ```R g <- GiottoData::loadGiottoMini("visium") # 1. read Giotto object # 2. read Giotto feature information # 3. read Giotto spatial information # 3.1 read Giotto spatial shape information # 3.2 read Giotto spatial centroid information # 3.3 read Giotto spatial overlap information # 4. read Giotto image information # python already initialized in this session # active environment : '/usr/bin/python3' # python version : 3.12 silhouetteRank(g) # Error in py_run_file_impl(file, local, convert): ModuleNotFoundError: No module named 'scipy' # Run `reticulate::py_last_error()` for details. ``` -------------------------------- ### Install Giotto Suite Source: https://giottosuite.com/articles/affine_registration Ensures the Giotto package is installed and available for use. This is a prerequisite for running the subsequent registration steps. ```r # Ensure Giotto Suite is installed if(!"Giotto" %in% installed.packages()) { pak::pkg_install("drieslab/Giotto") } ``` -------------------------------- ### Initialization Strategies Source: https://giottosuite.com/reference/runUMAP Details on spectral and PCA-based initialization methods, including handling of connected components and parameter scaling. ```APIDOC ## Initialization Strategies ### Spectral Initialization Spectral initializations (`"spectral"`, `"normlaplacian"`, `"laplacian"`, `"agspectral"`) attempt to initialize embeddings. If multiple connected components are detected, spectral initialization is skipped in favor of a PCA-based approach. - **`verbose = TRUE`**: Logs the number of connected components to the console. - **`init_sdev`**: Scales initialized coordinates to a specified standard deviation. Defaults to `NULL` (no scaling), unless `init = "spca"` (defaulting to `0.0001`). Scaling can help with large inter-point distances or outliers, improving gradient flow during optimization. - For `init = "spectral"`, setting `init_sdev = "range"` scales columns to the range [0-10] for compatibility with the Python UMAP package. This is not the default to maintain backward compatibility. ### PCA-based Initialization Used as a fallback when spectral initialization fails due to multiple connected components. ``` -------------------------------- ### Troubleshoot Conda UnsatisfiableError: List Environments Source: https://giottosuite.com/articles/troubleshooting This command lists all Conda environments available on the system, which is the first step in diagnosing 'UnsatisfiableError' related to conflicting Conda installations. ```shell (base) PS > conda info --envs ``` -------------------------------- ### Setup Environment and Initialize Libraries (R) Source: https://giottosuite.com/articles/integrate_misty_analysis Configures the Python environment for Giotto and loads essential R libraries for spatial analysis, MISTy integration, parallel processing, data manipulation, and pathway analysis. Ensures all necessary packages are available for the analysis. ```R # Configure Python environment for Giotto library(reticulate) use_python("C:/Users/your_username/anaconda3/envs/giotto_env/python.exe", required = TRUE) # Load core libraries library(Giotto) library(mistyR) # Parallel processing library(future) plan(multisession) # Data manipulation libraries library(data.table) library(janitor) library(Matrix) library(dplyr) library(tidyverse) # Pathway analysis libraries library(msigdbr) library(decoupleR) library(SummarizedExperiment) ``` -------------------------------- ### Setup and Install Giotto Suite and Dependencies Source: https://giottosuite.com/articles/spatial_coexpression_modules This code block ensures that the Giotto Suite and GiottoData packages are installed and loaded. It also checks and installs the necessary Python environment for Giotto, which is crucial for its functionality. This is a prerequisite for all subsequent steps. ```r # Ensure Giotto Suite is installed if(!"Giotto" %in% installed.packages()) { pak::pkg_install("drieslab/Giotto") } # Ensure Giotto Data is installed if(!"GiottoData" %in% installed.packages()) { pak::pkg_install("drieslab/GiottoData") } library(Giotto) # Ensure the Python environment for Giotto has been installed genv_exists <- checkGiottoEnvironment() if(!genv_exists){ # The following command need only be run once to install the Giotto environment installGiottoEnvironment() } ``` -------------------------------- ### Set up Giotto Environment Source: https://giottosuite.com/articles/create_simulated_object Ensures that the Giotto Suite and its Python environment are installed and accessible. This is a prerequisite for using Giotto functionalities. ```R # Ensure Giotto Suite is installed. if(!"Giotto" %in% installed.packages()) { pak::pkg_install("drieslab/Giotto") } # Ensure the Python environment for Giotto has been installed. genv_exists <- Giotto::checkGiottoEnvironment() if(!genv_exists){ # The following command need only be run once to install the Giotto environment. Giotto::installGiottoEnvironment() } ``` -------------------------------- ### Install Giotto Python Environment Source: https://giottosuite.com/articles/installation Installs a default Python 3.10.2 environment named 'giotto_env' using the `installGiottoEnvironment()` function from the 'Giotto' R package. This environment includes packages commonly used by Giotto. Users can also create their own Python environments. ```r library(Giotto) installGiottoEnvironment() ``` -------------------------------- ### Manage Giotto Instructions Source: https://giottosuite.com/articles/mini_seqfish Demonstrates how to interact with Giotto's instruction set, including displaying current instructions, modifying specific parameters like save directories and plot visibility, and replacing all instructions. ```r # show instructions associated with giotto object (seqfish_mini) showGiottoInstructions(seqfish_mini) # Change one or more instructions # to automatically save figures in save_dir, set save_plot to TRUE results_folder <- "/path/to/results/" seqfish_mini <- changeGiottoInstructions(seqfish_mini, params = c("save_dir", "save_plot", "show_plot"), new_values = c(results_folder,TRUE, TRUE)) ``` -------------------------------- ### Install GiottoData Package Source: https://giottosuite.com/articles/ecosystem Installs the GiottoData package, providing example 'giotto' objects for testing and tutorials. It also includes functions for downloading and importing public datasets from SODB or curated for Giotto. ```r pak::pkg_install("drieslab/GiottoData") ``` -------------------------------- ### Load Mini Giotto Objects Source: https://giottosuite.com/articles/interactive_giotto_vitessceR Loads two pre-defined mini Giotto objects, 'visium' and 'vizgen', using the GiottoData package. These objects serve as example datasets for the tutorial. ```R visium_object <- GiottoData::loadGiottoMini("visium") vizgen_object <- GiottoData::loadGiottoMini("vizgen") ``` -------------------------------- ### Example Usage of spatialAEH (R) Source: https://giottosuite.com/reference/spatialAEH Demonstrates how to use the spatialAEH function with a sample Giotto object. This example initializes a Giotto object and then calls spatialAEH. Note that this example may result in an error if required Python modules like 'pandas' are not installed or accessible. ```r g <- GiottoData::loadGiottoMini("visium") #> 1. read Giotto object #> 2. read Giotto feature information #> 3. read Giotto spatial information #> 3.1 read Giotto spatial shape information #> 3.2 read Giotto spatial centroid information #> 3.3 read Giotto spatial overlap information #> 4. read Giotto image information #> python already initialized in this session #> active environment : '/usr/bin/python3' #> python version : 3.12 spatialAEH(g) #> Error in py_run_file_impl(file, local, convert): ModuleNotFoundError: No module named 'pandas' #> Run `reticulate::py_last_error()` for details. ``` -------------------------------- ### R: Example Usage of filterICFSpot Source: https://giottosuite.com/reference/filterICFSpot Demonstrates how to use the filterICFSpot function with a Giotto object. This example first loads mini Giotto data, finds interaction changed features, and then applies the filterICFSpot function. Note: This example requires the 'future' package to be installed. ```r g <- GiottoData::loadGiottoMini("visium") icfObject <- findInteractionChangedFeats(g, cluster_column = "leiden_clus") filterICFSpot(icfObject = icfObject) ``` -------------------------------- ### Install and Initialize Giotto Suite Source: https://giottosuite.com/articles/slideseq_mouse_brain This R code checks for the presence of the Giotto package and installs it if necessary using `pak`. It also verifies and installs the required Python environment for Giotto's functionality. This setup is essential before proceeding with data analysis. ```r # Ensure Giotto Suite is installed if(!"Giotto" %in% installed.packages()) { pak::pkg_install("drieslab/Giotto") } # Ensure the Python environment for Giotto has been installed genv_exists <- Giotto::checkGiottoEnvironment() if(!genv_exists){ # The following command need only be run once to install the Giotto environment Giotto::installGiottoEnvironment() } ``` -------------------------------- ### Install and Load Giotto Package Source: https://giottosuite.com/articles/instructions Ensures the Giotto package is installed and then loads it into the current R session. This is a prerequisite for using Giotto functionalities. ```r # Ensure Giotto Suite is installed if(!"Giotto" %in% installed.packages()) { pak::pkg_install("drieslab/Giotto") } library(Giotto) ``` -------------------------------- ### Troubleshoot Conda UnsatisfiableError: Remove Conda Environment Source: https://giottosuite.com/articles/troubleshooting This command removes a specified Conda environment (e.g., 'giotto_env' or a path to an r-miniconda installation) from the system. This is useful for cleaning up conflicting or outdated environments. ```shell (base) PS > conda env remove --name giotto_env (base) PS > conda env remove /path/to/r-miniconda/ ``` -------------------------------- ### Prepare Ligand-Receptor Data for Analysis (R) Source: https://giottosuite.com/articles/seqfish_cortex Loads and prepares a dataset of mouse ligand-receptor pairs for cell-cell communication analysis. It checks for the presence of ligands and receptors within the Giotto object's feature IDs and filters for detected pairs. ```r ## LR expression ## LR activity changes LR_data <- data.table::fread(system.file("extdata", "mouse_ligand_receptors.txt", package = "GiottoData")) LR_data[, ligand_det := ifelse(LR_data$mouseLigand %in% SS_seqfish@feat_ID$rna, TRUE, FALSE)] LR_data[, receptor_det := ifelse(LR_data$mouseReceptor %in% SS_seqfish@feat_ID$rna, TRUE, FALSE)] LR_data_det <- LR_data[ligand_det == TRUE & receptor_det == TRUE] select_ligands <- LR_data_det$mouseLigand select_receptors <- LR_data_det$mouseReceptor ``` -------------------------------- ### Example: Using doGiottoClustree (R) Source: https://giottosuite.com/reference/doGiottoClustree An example demonstrating how to use the doGiottoClustree function. It loads a mini Giotto dataset and calls the function to perform clustering with specified resolutions, while disabling plot display and saving. Note: The 'clustree' package needs to be installed for this example to run successfully. ```R g <- GiottoData::loadGiottoMini("visium") #> 1. read Giotto object #> 2. read Giotto feature information #> 3. read Giotto spatial information #> 3.1 read Giotto spatial shape information #> 3.2 read Giotto spatial centroid information #> 3.3 read Giotto spatial overlap information #> 4. read Giotto image information #> python already initialized in this session #> active environment : '/usr/bin/python3' #> python version : 3.12 doGiottoClustree( gobject = g, res_vector = c(0.5, 0.8), return_plot = FALSE, show_plot = FALSE, save_plot = FALSE ) #> Error: package 'clustree' is not yet installed #> #> To install: #> install.packages(c("clustree")) ``` -------------------------------- ### R: Example Usage of findMastMarkers_one_vs_all Source: https://giottosuite.com/reference/findMastMarkers_one_vs_all An example demonstrating the usage of the findMastMarkers_one_vs_all function in R. It first loads a mini Giotto dataset and then calls the function to find marker features based on a specified cluster column. Note that the example includes an error message indicating that the MAST package may not be installed. ```R g <- GiottoData::loadGiottoMini("visium") #> 1. read Giotto object #> 2. read Giotto feature information #> 3. read Giotto spatial information #> 3.1 read Giotto spatial shape information #> 3.2 read Giotto spatial centroid information #> 3.3 read Giotto spatial overlap information #> 4. read Giotto image information #> python already initialized in this session #> active environment : '/usr/bin/python3' #> python version : 3.12 findMastMarkers_one_vs_all(gobject = g, cluster_column = "leiden_clus") #> Error: package 'MAST' is not yet installed #> #> To install: #> if(!requireNamespace('BiocManager', quietly = TRUE)) install.packages('BiocManager'); #> BiocManager::install(c("MAST")) ``` -------------------------------- ### R: Example Usage of plotCellProximityFeatSpot Source: https://giottosuite.com/reference/plotCellProximityFeatSpot An example demonstrating how to use the plotCellProximityFeatSpot function. It first loads a Giotto object and finds interaction changed features, then plots the results with specified parameters. Note that this example may require installation of the 'future' package and might encounter errors if 'icfObject' is not properly generated. ```R g <- GiottoData::loadGiottoMini("visium") #> 1. read Giotto object #> 2. read Giotto feature information #> 3. read Giotto spatial information #> 3.1 read Giotto spatial shape information #> 3.2 read Giotto spatial centroid information #> 3.3 read Giotto spatial overlap information #> 4. read Giotto image information #> python already initialized in this session #> active environment : '/usr/bin/python3' #> python version : 3.12 icfObject <- findInteractionChangedFeats(g, cluster_column = "leiden_clus") #> Error: package 'future' is not yet installed #> #> To install: #> install.packages(c("future")) plotCellProximityFeatSpot( gobject = g, icfObject = icfObject, show_plot = TRUE, save_plot = FALSE, return_plot = FALSE, min_pcc_diff = 0.01 ) #> Error: object 'icfObject' not found ``` -------------------------------- ### Set R Environment Variable for Timeout (Linux) Source: https://giottosuite.com/articles/troubleshooting Sets the R default internet timeout directly in the R environment file on Linux systems. This change persists across sessions and helps prevent installation timeouts. ```bash echo "R_DEFAULT_INTERNET_TIMEOUT = 1000" >> .Renviron ```