# 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)
Piecewise creation is most convenient when assembling a fully custom
giotto
analysis object. This method requires first loading
the data in as Giotto-compatible subobjects, after which they can be
directly appended to an empty giotto
object.
For a more complete introduction to the data and Giotto subobjects used here, see the point data Giotto object creation tutorial
# function to get a filepath from GiottoData
mini_viz_raw <- function(x) {
system.file(
package = "GiottoData",
file.path("Mini_datasets", "Vizgen", "Raw", x)
)
}
mini_viz_poly_path <- mini_viz_raw(file.path("cell_boundaries", "z0_polygons.gz"))
mini_viz_tx_path <- mini_viz_raw("vizgen_transcripts.gz")
poly_dt <- data.table::fread(mini_viz_poly_path)
viz_gpoly <- createGiottoPolygon(poly_dt)
tx_dt <- data.table::fread(mini_viz_tx_path)
tx_dt[, global_y := -global_y] # flip values to match polys
viz_gpoints <- createGiottoPoints(tx_dt)
giotto
object through appending subobjects
g <- giotto() # initialize empty gobject
g <- setGiotto(g, viz_gpoly)
g <- setGiotto(g, viz_gpoints)
force(g)
An object of class giotto
>Active spat_unit: cell
>Active feat_type: rna
dimensions : 559, 498 (features, cells)
[SUBCELLULAR INFO]
polygons : cell
features : rna
[AGGREGATE INFO]
Use objHistory() to see steps and params used
This is essentially the same object as the one created through
createGiottoObjectSubcellular()
as shown in the previously
mentioned tutorial.
Appending additional information in this manner can be used both when
objects are created from scratch using giotto()
and when
they are created through more guided approaches such as
createGiottoObject()
and technology-specific convenience
functions. This method of object creation and modification can be
helpful for editing the object, adding additional modalities, or setting
up objects for custom workflows.
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 R.utils_2.12.3 fastmap_1.2.0
[7] SingleCellExperiment_1.26.0 lazyeval_0.2.2 digest_0.6.37
[10] lifecycle_1.0.4 terra_1.7-78 magrittr_2.0.3
[13] compiler_4.4.1 rlang_1.1.4 tools_4.4.1
[16] yaml_2.3.10 igraph_2.1.1 utf8_1.2.4
[19] data.table_1.16.2 knitr_1.48 S4Arrays_1.4.0
[22] htmlwidgets_1.6.4 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 R.oo_1.26.0 grid_4.4.1
[31] stats4_4.4.1 fansi_1.0.6 colorspace_2.1-1
[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 ggrepel_0.9.6
[55] scattermore_1.2 magick_2.8.5 GiottoUtils_0.2.1
[58] plotly_4.10.4 tidyr_1.3.1 glue_1.8.0
[61] codetools_0.2-20 cowplot_1.1.3 gtable_0.3.5
[64] GenomeInfoDb_1.40.0 GenomicRanges_1.56.0 UCSC.utils_1.0.0
[67] munsell_0.5.1 tibble_3.2.1 pillar_1.9.0
[70] htmltools_0.5.8.1 GenomeInfoDbData_1.2.12 R6_2.5.1
[73] evaluate_1.0.0 lattice_0.22-6 Biobase_2.64.0
[76] png_0.1-8 R.methodsS3_1.8.2 backports_1.5.0
[79] SpatialExperiment_1.14.0 Rcpp_1.0.13 SparseArray_1.4.1
[82] checkmate_2.3.2 colorRamp2_0.1.0 xfun_0.47
[85] MatrixGenerics_1.16.0 pkgconfig_2.0.3