# 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)

1 Download data to use

The example dataset used here is from 10X link

link <- "https://cf.10xgenomics.com/samples/cell-exp/8.0.1/Human_PBMCs_Next_GEM_Flex_GEM-X_Flex_Comparison/Human_PBMCs_Next_GEM_Flex_GEM-X_Flex_Comparison_count_filtered_feature_bc_matrix.h5"

# Specify path from which data may be retrieved/stored
data_path <- "/path/to/data/"
save_path <- file.path(data_path, "pbmc_matrix.h5")

utils::download.file(link, destfile = save_path, method = "wget")

2 Read the data

Read the expression matrix, which is provided from 10X as an h5 format. get10Xmatrix_h5() is a convenience function from Giotto that will import this format as a Matrix dgCMatrix sparse matrix.

pbmc_mat <- get10Xmatrix_h5(save_path)

3 Load into Giotto as a single cell analysis

Single cell datasets should be loaded in through createGiottoObject(). During the load, a set of dummy spatial locations that can be safely ignored will also be generated.

pbmc <- createGiottoObject(expression = pbmc_mat)
force(pbmc)
An object of class giotto 
>Active spat_unit:  cell 
>Active feat_type:  rna 
dimensions    : 15146, 8703 (features, cells)
[SUBCELLULAR INFO]
[AGGREGATE INFO]
expression -----------------------
  [cell][rna] Gene Expression
spatial locations ----------------
  [cell] raw


Use objHistory() to see steps and params used

4 Session Info

R version 4.4.1 (2024-06-14)
Platform: aarch64-apple-darwin20
Running under: macOS 15.0.1

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] Giotto_4.1.5      GiottoClass_0.4.3

loaded via a namespace (and not attached):
 [1] tidyselect_1.2.1            viridisLite_0.4.2           dplyr_1.1.4                
 [4] GiottoVisuals_0.2.7         fastmap_1.2.0               SingleCellExperiment_1.26.0
 [7] lazyeval_0.2.2              digest_0.6.37               lifecycle_1.0.4            
[10] terra_1.7-78                magrittr_2.0.3              compiler_4.4.1             
[13] rlang_1.1.4                 tools_4.4.1                 igraph_2.1.1               
[16] utf8_1.2.4                  yaml_2.3.10                 data.table_1.16.2          
[19] knitr_1.48                  S4Arrays_1.4.0              htmlwidgets_1.6.4          
[22] bit_4.5.0                   reticulate_1.39.0           DelayedArray_0.30.0        
[25] abind_1.4-8                 withr_3.0.1                 purrr_1.0.2                
[28] BiocGenerics_0.50.0         grid_4.4.1                  stats4_4.4.1               
[31] fansi_1.0.6                 colorspace_2.1-1            progressr_0.14.0           
[34] ggplot2_3.5.1               scales_1.3.0                gtools_3.9.5               
[37] SummarizedExperiment_1.34.0 cli_3.6.3                   rmarkdown_2.28             
[40] crayon_1.5.3                generics_0.1.3              rstudioapi_0.16.0          
[43] httr_1.4.7                  rjson_0.2.21                zlibbioc_1.50.0            
[46] parallel_4.4.1              XVector_0.44.0              matrixStats_1.4.1          
[49] vctrs_0.6.5                 Matrix_1.7-0                jsonlite_1.8.9             
[52] IRanges_2.38.0              S4Vectors_0.42.0            bit64_4.5.2                
[55] ggrepel_0.9.6               scattermore_1.2             hdf5r_1.3.10               
[58] magick_2.8.5                GiottoUtils_0.2.1           plotly_4.10.4              
[61] tidyr_1.3.1                 glue_1.8.0                  codetools_0.2-20           
[64] cowplot_1.1.3               gtable_0.3.5                GenomeInfoDb_1.40.0        
[67] GenomicRanges_1.56.0        UCSC.utils_1.0.0            munsell_0.5.1              
[70] tibble_3.2.1                pillar_1.9.0                htmltools_0.5.8.1          
[73] GenomeInfoDbData_1.2.12     R6_2.5.1                    evaluate_1.0.0             
[76] lattice_0.22-6              Biobase_2.64.0              png_0.1-8                  
[79] backports_1.5.0             SpatialExperiment_1.14.0    Rcpp_1.0.13                
[82] SparseArray_1.4.1           checkmate_2.3.2             colorRamp2_0.1.0           
[85] xfun_0.47                   MatrixGenerics_1.16.0       pkgconfig_2.0.3