diff --git a/.Rbuildignore b/.Rbuildignore index 86f1b62e9..167d94250 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -15,3 +15,4 @@ .Rbuildignore.save ^\.github$ ^codecov\.yml$ +^vignettes$ diff --git a/NEWS.md b/NEWS.md index 727e32b52..d4f724c0e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,234 +3,254 @@ ## Breaking Changes ## Added -- New File `spatial_enrichment_visuals.R` -- New function `findCellTypesFromEnrichment()` within `spatial_enrichment_visuals.R` to show most probable cell types based on a provided enrichment -- New function `plotCellTypesFromEnrichment()` within `spatial_enrichment_visuals.R` that generates a bar plot of cell types vs frequency based on a provided enrichment -- New function `pieCellTypesFromEnrichment()` within `spatial_enrichment_visuals.R` that generates a pie chart of cell types based on a provided enrichment -- New function `addVisiumPolygons()` within `convenience.R` (along with its requisite internal functions) that adds circular polygons centered at the spatial locations of a Giotto Object made with Visium data. Takes a Giotto Object and a path to the Visium output file `scalefactors_json.json` as input arguments. -- Add `addVisiumPolygons()` to `createGiottoVisiumObject()` workflow. -- Add `cell_ids` param to `calculateHVF()` to allow calculation of HVFs on a subset of cells + +* New File `spatial_enrichment_visuals.R` +* New function `findCellTypesFromEnrichment()` within `spatial_enrichment_visuals.R` to show most probable cell types based on a provided enrichment +* New function `plotCellTypesFromEnrichment()` within `spatial_enrichment_visuals.R` that generates a bar plot of cell types vs frequency based on a provided enrichment +* New function `pieCellTypesFromEnrichment()` within `spatial_enrichment_visuals.R` that generates a pie chart of cell types based on a provided enrichment +* New function `addVisiumPolygons()` within `convenience.R` (along with its requisite internal functions) that adds circular polygons centered at the spatial locations of a Giotto Object made with Visium data. Takes a Giotto Object and a path to the Visium output file `scalefactors_json.json` as input arguments. +* Added `addVisiumPolygons()` to `createGiottoVisiumObject()` workflow. +* Add `cell_ids` param to `calculateHVF()` to allow calculation of HVFs on a subset of cells + ## Changes -- Improved performance of gefToGiotto() +* Improved performance of gefToGiotto() -# Giotto Suite 3.3.1 (2023-08-02) + +# Giotto Suite 3.3.1 (2023*08*02) ## Breaking Changes -- Change `checkGiottoEnvironment()`. Downgrade from error to message and return FALSE when a provided directory does not exist + +* Change `checkGiottoEnvironment()`. Downgrade from error to message and return FALSE when a provided directory does not exist ## Added -- New file `poly_influence.R` -- New function `showPolygonSizeInfluence()` within `poly_influence.R` to show if cells switch clusters when across resized polygon annotations -- New function `showCellProportionSwitchedPie()` within `poly_influence.R` to visualize results from `showPolygonSizeInfluence()` in a pie chart -- New function `showCellProportionSwitchedSankey()` within `poly_influence.R` to visualize results from `showPolygonSizeInfluence()` in a Sankey diagram -- New function `makePseudoVisium()` within `giotto_structure.R` to generate a pseudo visium grid of circular spots -- New function `tessellate()` within `giotto_structure.R` to generate a grid of hexagons or squares for spatial binning -- New file `feature_set_enrichment.R` -- New function `doFeatureSetEnrichment()` within `feature_set_enrichment.R` for GSEA analysis -- New function `doGiottoClustree()` within `clustering.R` for visualizations of leiden clusters at varying resolutions -- New `createArchRProj()` and `CreateGiottoObjectFromArchR()` functions to create a `giotto` object with ATAC or epigenetic features using the *ArchR* pipeline. -- New `giottoMasterToSuite()` function to convert a `giotto` object created with the master version to a Giotto suite object. -- New `readPolygonVizgenParquet()` for updated parquet outputs -- Add *checkmate* to Imports for assertions checking -- Add exported `create` function for `exprObj` creation -- New file `spatial_manipulation.R` -- Add `ext()` methods for `giottoPolygon`, `giottoPoints`, `spatialNetworkObj`, `spatLocsObj`, `giottoLargeImage` -- Add `flip()` methods for `giottoPolygon`, `giottoPoints`, `spatialNetworkObj`, `spatLocsObj`, `SpatExtent`, `giottoLargeImage` -- Add access to terra plotting params for `giottoLargeImage` `plot()` method. + +* New file `poly_influence.R` +* New function `showPolygonSizeInfluence()` within `poly_influence.R` to show if cells switch clusters when across resized polygon annotations +* New function `showCellProportionSwitchedPie()` within `poly_influence.R` to visualize results from `showPolygonSizeInfluence()` in a pie chart +* New function `showCellProportionSwitchedSankey()` within `poly_influence.R` to visualize results from `showPolygonSizeInfluence()` in a Sankey diagram +* New function `makePseudoVisium()` within `giotto_structure.R` to generate a pseudo visium grid of circular spots +* New function `tessellate()` within `giotto_structure.R` to generate a grid of hexagons or squares for spatial binning +* New file `feature_set_enrichment.R` +* New function `doFeatureSetEnrichment()` within `feature_set_enrichment.R` for GSEA analysis +* New function `doGiottoClustree()` within `clustering.R` for visualizations of leiden clusters at varying resolutions +* New `createArchRProj()` and `CreateGiottoObjectFromArchR()` functions to create a `giotto` object with ATAC or epigenetic features using the *ArchR* pipeline. +* New `giottoMasterToSuite()` function to convert a `giotto` object created with the master version to a Giotto suite object. +* New `readPolygonVizgenParquet()` for updated parquet outputs +* Add *checkmate* to Imports for assertions checking +* Add exported `create` function for `exprObj` creation +* New file `spatial_manipulation.R` +* Add `ext()` methods for `giottoPolygon`, `giottoPoints`, `spatialNetworkObj`, `spatLocsObj`, `giottoLargeImage` +* Add `flip()` methods for `giottoPolygon`, `giottoPoints`, `spatialNetworkObj`, `spatLocsObj`, `SpatExtent`, `giottoLargeImage` +* Add access to terra plotting params for `giottoLargeImage` `plot()` method. ## Changes -- Fix bug in `combine_matrices()` -- Fix bug in `createGiottoObject()` that will not allow object creation without supplied expression information -- Updated `polyStamp()` to replace an apply function with a crossjoin for better performance. -- Updated `spatInSituPlotPoints()` with `plot_last` parameter. Default output now plots polygons above points for better visibility. -- Add check for spatLocsObj for spatlocs in polyStamp() -- Removed various print() and cat() statements throughout. -- Changed default verbose argument to FALSE for createGiottoObject -- Changed default verbose argument to FALSE for joinGiottoObjects -- Changed default verbose argument to FALSE for createGiottoObjectSubcellular -- Default verbose = FALSE argument added to cellProximityEnrichmentSpots -- Default verbose = FALSE argument added to specific_CCCScores_spots -- Default verbose = FALSE argument added to runWNN -- Default verbose = FALSE argument added to subset_giotto_points_object -- Default verbose = FALSE argument added to subset_feature_info_data -- Default verbose = FALSE argument added to subsetGiotto -- Default verbose = FALSE argument added to subsetGiottoLocsSubcellular -- Default verbose = FALSE argument added to createGiottoXeniumObject_subcellular -- Update `readPolygonFilesVizgenHDF5()` add option to return as `data.table` and skip `giottoPolygon` creation. Downstream `giottoPolygon` creation refactored as new internal function -- Update cell segmentation workflow to check for *deepcell* and *PIL* python packages -- Update cell segmentation workflow to return grayscale mask images instead of RGB -- Update `createGiottoVisiumObject()` image h5 scalefactors reading to use partial matching for whether hi or lowres image is supplied -- Update `giottoLargeImage` `plot()` method to use `terra::plot()` instead of `terra::plotRGB()` for grayscale images -- Remove unnecessary prints from `subsetGiotto()` -- Fix bug in `readCellMetadata()` and `readFeatMetadata()` - - -# Giotto Suite 3.3.0 (2023-04-18) + +* Fix bug in `combine_matrices()` +* Fix bug in `createGiottoObject()` that will not allow object creation without supplied expression information +* Updated `polyStamp()` to replace an apply function with a crossjoin for better performance. +* Updated `spatInSituPlotPoints()` with `plot_last` parameter. Default output now plots polygons above points for better visibility. +* Add check for spatLocsObj for spatlocs in polyStamp() +* Removed various print() and cat() statements throughout. +* Changed default verbose argument to FALSE for createGiottoObject +* Changed default verbose argument to FALSE for joinGiottoObjects +* Changed default verbose argument to FALSE for createGiottoObjectSubcellular +* Default verbose = FALSE argument added to cellProximityEnrichmentSpots +* Default verbose = FALSE argument added to specific_CCCScores_spots +* Default verbose = FALSE argument added to runWNN +* Default verbose = FALSE argument added to subset_giotto_points_object +* Default verbose = FALSE argument added to subset_feature_info_data +* Default verbose = FALSE argument added to subsetGiotto +* Default verbose = FALSE argument added to subsetGiottoLocsSubcellular +* Default verbose = FALSE argument added to createGiottoXeniumObject_subcellular +* Update `readPolygonFilesVizgenHDF5()` add option to return as `data.table` and skip `giottoPolygon` creation. Downstream `giottoPolygon` creation refactored as new internal function +* Update cell segmentation workflow to check for *deepcell* and *PIL* python packages +* Update cell segmentation workflow to return grayscale mask images instead of RGB +* Update `createGiottoVisiumObject()` image h5 scalefactors reading to use partial matching for whether hi or lowres image is supplied +* Update `giottoLargeImage` `plot()` method to use `terra::plot()` instead of `terra::plotRGB()` for grayscale images +* Remove unnecessary prints from `subsetGiotto()` +* Fix bug in `readCellMetadata()` and `readFeatMetadata()` + + +# Giotto Suite 3.3.0 (2023*04*18) ## Breaking Changes -- Set Suite as default branch -- Removed all deprecated accessors from `accessors.R` -- `set_default_feat_type()` error downgraded to warning when no `feat_type`s exist for given `spat_unit` -- update `loadGiotto()` and `saveGiotto()` to allow using long strings as column names in the spatVector objects -- `'active_spat_unit'` and `'active_feat_type'` params that can be set through `instructions()` are now used instead of 'giotto.spat_unit' and 'giotto.feat_type' global options -- removed duplicate `create_dimObject()` internal function. Keeping `create_dim_obj()` + +* Set Suite as default branch +* Removed all deprecated accessors from `accessors.R` +* `set_default_feat_type()` error downgraded to warning when no `feat_type`s exist for given `spat_unit` +* update `loadGiotto()` and `saveGiotto()` to allow using long strings as column names in the spatVector objects +* `'active_spat_unit'` and `'active_feat_type'` params that can be set through `instructions()` are now used instead of 'giotto.spat_unit' and 'giotto.feat_type' global options +* removed duplicate `create_dimObject()` internal function. Keeping `create_dim_obj()` ## Added -- New implementations of `anndataToGiotto()` and `giottoToAnnData()` for Nearest Neighbor and Spatial Networks -- New `check_py_for_scanpy()` function, shifting code around in `anndataToGiotto()` -- Add `initialize()` method for `giotto` -- Add exported `create` constructor functions for Giotto S4 subobjects -- Add `activeSpatUnit()` and `activeFeatType()` for getting and setting active defaults on gobject -- New `get_*_list()` internal functions for retrieving list of all objects of a particular class for a spat_unit and feat_type -- Add `instructions()` generic for `giotto` to access and edit `giottoInstructions` -- Add `centroids()` method for `giottoPolygon` to get centroid info -- Add `overlaps()` generic for accessing `overlaps` slot of `giottoPolygon` -- Add `[` and `[<-` (empty) access generics to get the data from main slots of `giottoPolygon` and `giottoPoints` -- Add cores detection to run on package attach. (`getOption('giotto.cores')`) -- Add option to return as `giottoPoints` from `getFeatureInfo` (default is still `SpatVector`) -- Add `spatVector_to_dt2` internal as a barebones alternative to `spatVector_to_dt()` -- Add `getRainbowColors()` color palette -- New `assign_objnames_2_list()` and `assign_listnames_2_obj()` internals for passing list names to object `@name` slots and vice versa -- New test_that `test_createObject.R` script for `read` functions/S4 subobject creation -- New test_that `test_accessors.R` script for `accessor` functions -- New test_that `test_gobject.R` script for gobject consistency checks + +* New implementations of `anndataToGiotto()` and `giottoToAnnData()` for Nearest Neighbor and Spatial Networks +* New `check_py_for_scanpy()` function, shifting code around in `anndataToGiotto()` +* Add `initialize()` method for `giotto` +* Add exported `create` constructor functions for Giotto S4 subobjects +* Add `activeSpatUnit()` and `activeFeatType()` for getting and setting active defaults on gobject +* New `get_*_list()` internal functions for retrieving list of all objects of a particular class for a spat_unit and feat_type +* Add `instructions()` generic for `giotto` to access and edit `giottoInstructions` +* Add `centroids()` method for `giottoPolygon` to get centroid info +* Add `overlaps()` generic for accessing `overlaps` slot of `giottoPolygon` +* Add `[` and `[<*` (empty) access generics to get the data from main slots of `giottoPolygon` and `giottoPoints` +* Add cores detection to run on package attach. (`getOption('giotto.cores')`) +* Add option to return as `giottoPoints` from `getFeatureInfo` (default is still `SpatVector`) +* Add `spatVector_to_dt2` internal as a barebones alternative to `spatVector_to_dt()` +* Add `getRainbowColors()` color palette +* New `assign_objnames_2_list()` and `assign_listnames_2_obj()` internals for passing list names to object `@name` slots and vice versa +* New test_that `test_createObject.R` script for `read` functions/S4 subobject creation +* New test_that `test_accessors.R` script for `accessor` functions +* New test_that `test_gobject.R` script for gobject consistency checks ## Changes -- Update `installGiottoEnvironment()` and downstream internal functions to allow custom python installation with a new argument, `mini_install_path`. -- Update `checkGiottoEnvironment()` to account for custom python installations with a new argument, `mini_install_path`. -- Update `removeGiottoEnvironment()` to account for custom python installations with a new argument, `mini_path`. -- Update `createGiottoObject()` with new data ingestion pipeline -- Modify `cell_ID`, `feat_ID`, `cell_metadata`, `feat_metadata` slot initialization -- Update `read_expression_data()` and `evaluate_expr_matrix()` to be compatible with `exprObj` -- Change `changeGiottoInstructions()` to allow addition of new params and enforce logical class of known params -- Update and fix bugs in `createGiottoCosMxObject()` associated with polygon placement and generation -- Update `plot()` for `giottoPoints` with faster rasterized plotting option. (Now used by default) -- Fix bug in `doLouvainCluster()` (sub)functions and made them compatible with new Giotto Suite framework. -- Fix bug in `gefToGiotto()` bin_size arguments. -- Update `loadGiotto()` and `saveGiotto()` with path.expand to expand provided file/directory paths -- Organize new and refactored slot `check` functions in `giotto.R` for checking gobject consistency during `initialize()` -- Organize new and refactored `evaluate` functions in `data_evaluation.R` for data wrangling of external data -- Organize new and refactored `read` functions in `data_input.R` for ingesting data and converting to list of Giotto native S4 subobjects -- Organize dummy documentation in `dd.R` for inheriting commonly used documentation -- Moved `create_featureNetwork_object()`, `create_giotto_points_object()`, `create_giotto_polygon_object()` to classes.R -- Moved `depth()` from giotto.R to utilities.R - - -# Giotto Suite 3.2.0 (2023-02-02) + +* Update `installGiottoEnvironment()` and downstream internal functions to allow custom python installation with a new argument, `mini_install_path`. +* Update `checkGiottoEnvironment()` to account for custom python installations with a new argument, `mini_install_path`. +* Update `removeGiottoEnvironment()` to account for custom python installations with a new argument, `mini_path`. +* Update `createGiottoObject()` with new data ingestion pipeline +* Modify `cell_ID`, `feat_ID`, `cell_metadata`, `feat_metadata` slot initialization +* Update `read_expression_data()` and `evaluate_expr_matrix()` to be compatible with `exprObj` +* Change `changeGiottoInstructions()` to allow addition of new params and enforce logical class of known params +* Update and fix bugs in `createGiottoCosMxObject()` associated with polygon placement and generation +* Update `plot()` for `giottoPoints` with faster rasterized plotting option. (Now used by default) +* Fix bug in `doLouvainCluster()` (sub)functions and made them compatible with new Giotto Suite framework. +* Fix bug in `gefToGiotto()` bin_size arguments. +* Update `loadGiotto()` and `saveGiotto()` with path.expand to expand provided file/directory paths +* Organize new and refactored slot `check` functions in `giotto.R` for checking gobject consistency during `initialize()` +* Organize new and refactored `evaluate` functions in `data_evaluation.R` for data wrangling of external data +* Organize new and refactored `read` functions in `data_input.R` for ingesting data and converting to list of Giotto native S4 subobjects +* Organize dummy documentation in `dd.R` for inheriting commonly used documentation +* Moved `create_featureNetwork_object()`, `create_giotto_points_object()`, `create_giotto_polygon_object()` to classes.R +* Moved `depth()` from giotto.R to utilities.R + + +# Giotto Suite 3.2.0 (2023*02*02) ## Breaking Changes -- Removed support for deprecated nesting in `@nn_network` slot -- `createSpatialNetwork()` will now output a `spatialNetworkObj` by default when `return_gobject = FALSE`. It is possible to change this back to the data.table output by setting `output = 'data.table'` -- Set incomplete classes in classes.R as virtual to prevent their instantiation -- Removed `createGiottoCosMxObject()` `aggregate` and `all` workflows until they are updated + +* Removed support for deprecated nesting in `@nn_network` slot +* `createSpatialNetwork()` will now output a `spatialNetworkObj` by default when `return_gobject = FALSE`. It is possible to change this back to the data.table output by setting `output = 'data.table'` +* Set incomplete classes in classes.R as virtual to prevent their instantiation +* Removed `createGiottoCosMxObject()` `aggregate` and `all` workflows until they are updated ## Added -- New `gefToGiotto()` interoperability function to convert gef object from Stereo-seq to giotto -- New `giottoToAnnData()` interoperability function to convert giotto object to squidpy flavor anndata .h5ad file(s) -- New `giottoToSpatialExperiment()` and `spatialExperimentToGiotto()` to convert between Giotto and SpatialExperiment -- New `spatialAutoCorLocal()` and `spatialAutoCorGlobal()` functions to find spatial autocorrelations from expression and cell metadata information -- New `createSpatialWeightMatrix()` function to generate spatial weight matrix from spatial networks for autocorrelation -- Add spatial_interaction_spot.R with functions adapted from master branch for working with the Giotto suite object. -- New exported accessors for slots (experimental) -- New `multiomics` slot in `giotto` -- Add `coord_fix_ratio` param to `spatFeatPlot2D()` and `spatFeatPlot2D_single()` -- Add `order` parameter to `dimFeatPlot2D` and `spatDimFeatPlot2d` to plot and order cells according to the levels of the selected feature ([#477](https://github.com/drieslab/Giotto/issues/477)) -- Add `plot()` method for `spatialNetworkObj` -- New `set_row_order_dt()` internal for setting `data.table` to a specific row order by reference -- New `fread_colmatch()` internal for fread loading a subset of rows based on matches in a specified column -- Add missing `create_nn_net_obj()` internal constructor function for S4 `nnNetObj` -- Add `id_col`, `x_col`, `y_col` params to `polyStamp()` to make stamp location input more flexible -- Add `optional` and `custom_msg` params to `package_check()` -- New `wrap()` and `vect()` generics for `giotto`, `giottoPoints`, and `giottoPolygons` -- New `rotate()`, `t()`, and `spatShift` generics for giotto subobject spatial manipulation -- New `spatIDs()` and `featIDs()` generics -- New `objName()` and `objName` generics for setting the names of relevant S4 subobjects -- New `rbind()` generic to append `giottoPolygon` objects -- Add packages `exactextractr` and `sf` to "suggests" packages -- Add package `progressr` to "imports" packages + +* New `gefToGiotto()` interoperability function to convert gef object from Stereo*seq to giotto +* New `giottoToAnnData()` interoperability function to convert giotto object to squidpy flavor anndata .h5ad file(s) +* New `giottoToSpatialExperiment()` and `spatialExperimentToGiotto()` to convert between Giotto and SpatialExperiment +* New `spatialAutoCorLocal()` and `spatialAutoCorGlobal()` functions to find spatial autocorrelations from expression and cell metadata information +* New `createSpatialWeightMatrix()` function to generate spatial weight matrix from spatial networks for autocorrelation +* Add spatial_interaction_spot.R with functions adapted from master branch for working with the Giotto suite object. +* New exported accessors for slots (experimental) +* New `multiomics` slot in `giotto` +* Add `coord_fix_ratio` param to `spatFeatPlot2D()` and `spatFeatPlot2D_single()` +* Add `order` parameter to `dimFeatPlot2D` and `spatDimFeatPlot2d` to plot and order cells according to the levels of the selected feature ([#477](https://github.com/drieslab/Giotto/issues/477)) +* Add `plot()` method for `spatialNetworkObj` +* New `set_row_order_dt()` internal for setting `data.table` to a specific row order by reference +* New `fread_colmatch()` internal for fread loading a subset of rows based on matches in a specified column +* Add missing `create_nn_net_obj()` internal constructor function for S4 `nnNetObj` +* Add `id_col`, `x_col`, `y_col` params to `polyStamp()` to make stamp location input more flexible +* Add `optional` and `custom_msg` params to `package_check()` +* New `wrap()` and `vect()` generics for `giotto`, `giottoPoints`, and `giottoPolygons` +* New `rotate()`, `t()`, and `spatShift` generics for giotto subobject spatial manipulation +* New `spatIDs()` and `featIDs()` generics +* New `objName()` and `objName` generics for setting the names of relevant S4 subobjects +* New `rbind()` generic to append `giottoPolygon` objects +* Add packages `exactextractr` and `sf` to "suggests" packages +* Add package `progressr` to "imports" packages ## Changes -- Move giotto object method-specific creation functions from `giotto.R` to `convenience.R` -- Update `addFeatMetadata()` to handle replacement of existing columns -- Update `show()` method for `giotto` -- Update `show()` method for `spatEnrObj` -- Deprecate older snake_case accessors -- Deprecate `polygon_feat_names` param in favor of `z_indices` in `readPolygonFilesVizgenHDF5()` -- Deprecate `xy_translate_spatial_locations()` in favor of `shift_spatial_locations()` -- Optimize `readPolygonFilesVizgen()` -- Fix bug in `replaceGiottoInstructions()` where instructions with more slots than previous are not allowed -- Fix bug in `loadGiotto()` that prevents proper parsing of filenames when spat_unit or feat_type contains '_' characters -- Fix `loadGiotto()` loss of over-allocation for data.tables-based objects after loading from disk - - -# Giotto Suite 3.1.0 (2022-12-01) + +* Move giotto object method*specific creation functions from `giotto.R` to `convenience.R` +* Update `addFeatMetadata()` to handle replacement of existing columns +* Update `show()` method for `giotto` +* Update `show()` method for `spatEnrObj` +* Deprecate older snake_case accessors +* Deprecate `polygon_feat_names` param in favor of `z_indices` in `readPolygonFilesVizgenHDF5()` +* Deprecate `xy_translate_spatial_locations()` in favor of `shift_spatial_locations()` +* Optimize `readPolygonFilesVizgen()` +* Fix bug in `replaceGiottoInstructions()` where instructions with more slots than previous are not allowed +* Fix bug in `loadGiotto()` that prevents proper parsing of filenames when spat_unit or feat_type contains '_' characters +* Fix `loadGiotto()` loss of over*allocation for data.tables*based objects after loading from disk + + +# Giotto Suite 3.1.0 (2022*12*01) ## Added -- New `initialize()` generic that calls `setalloccol()` for data.table-based S4 subobjects to allow setting by reference -- New `spatUnit`, `spatUnit<-`, `featType`, and `featType<-` feat type generics for S4 subobjects for setting the relevant slots -- Add `hexVertices()` to polygon shape array generation functionality +* New `initialize()` generic that calls `setalloccol()` for data.table*based S4 subobjects to allow setting by reference +* New `spatUnit`, `spatUnit<*`, `featType`, and `featType<*` feat type generics for S4 subobjects for setting the relevant slots +* Add `hexVertices()` to polygon shape array generation functionality ## Changes -- Update `createGiottoCosMxObject()` for 3.0 and modularization of functions. 'subcellular' workflow has been tested to work along with an updated tutorial. -- Update grid plotting behavior to set a default number columns to use based on number of elements to plot. Can be overridden by explicitly providing input to `cow_n_col` param -- Fix bug in `annotateGiotto()` after 3.0 update ([#433](https://github.com/drieslab/Giotto/issues/433#issuecomment-1324211224)) -- Fix bug in `joinGiottoObjects()` metadata processing -- Update seed setting behavior in [dimension_reduction.R](https://github.com/drieslab/Giotto/blob/suite/R/dimension_reduction.R) and [clustering.R](https://github.com/drieslab/Giotto/blob/suite/R/clustering.R) + +* Update `createGiottoCosMxObject()` for 3.0 and modularization of functions. 'subcellular' workflow has been tested to work along with an updated tutorial. +* Update grid plotting behavior to set a default number columns to use based on number of elements to plot. Can be overridden by explicitly providing input to `cow_n_col` param +* Fix bug in `annotateGiotto()` after 3.0 update ([#433](https://github.com/drieslab/Giotto/issues/433#issuecomment*1324211224)) +* Fix bug in `joinGiottoObjects()` metadata processing +* Update seed setting behavior in [dimension_reduction.R](https://github.com/drieslab/Giotto/blob/suite/R/dimension_reduction.R) and [clustering.R](https://github.com/drieslab/Giotto/blob/suite/R/clustering.R) -# Giotto Suite 3.0.1 (2022-11-20) +# Giotto Suite 3.0.1 (2022*11*20) ## Added -- New system color support detection (based on crayon package logic) -- Add ability to turn off colored text in `show` functions with `options("giotto.color_show" = FALSE)` + +* New system color support detection (based on crayon package logic) +* Add ability to turn off colored text in `show` functions with `options("giotto.color_show" = FALSE)` ## Changes -- Fix bug in `extract_polygon_list()` ([#433](https://github.com/drieslab/Giotto/issues/433#issuecomment-1321221382)) -- Update Unicode character printing with `show` functions for Latin1 systems +* Fix bug in `extract_polygon_list()` ([#433](https://github.com/drieslab/Giotto/issues/433#issuecomment*1321221382)) +* Update Unicode character printing with `show` functions for Latin1 systems -# Giotto Suite 3.0.0 (2022-11-18) + +# Giotto Suite 3.0.0 (2022*11*18) ## Breaking Changes -- S4 subobjects framework will require giotto objects to be remade + +* S4 subobjects framework will require giotto objects to be remade ## Added -- New `createGiottoXeniumObject()` for loading 10x Xenium data -- New S4 subobjects. Details can be found in [classes.R](https://github.com/drieslab/Giotto/blob/suite/R/classes.R) -- New basic generics for S4 subobjects. Mainly the use of `[]` and `[]<-` to get or set information into the main data slot -- New `@provenance` slot in S4 subobjects to track provenance of aggregated information (z_layers used for example) -- New `calculateOverlapPolygonImages()` for calculating overlapped intensities from image-based information (e.g. IMC, IF, MIBI, ...) and polygon data (e.g. cell) -- New `overlapImagesToMatrix()` converts intensity-polygon overlap info into an expression matrix (e.g. cell by protein) -- New `aggregateStacks()` set of functions work with multiple subcellular layers when generating aggregated expression matrices + +* New `createGiottoXeniumObject()` for loading 10x Xenium data +* New S4 subobjects. Details can be found in [classes.R](https://github.com/drieslab/Giotto/blob/suite/R/classes.R) +* New basic generics for S4 subobjects. Mainly the use of `[]` and `[]<*` to get or set information into the main data slot +* New `@provenance` slot in S4 subobjects to track provenance of aggregated information (z_layers used for example) +* New `calculateOverlapPolygonImages()` for calculating overlapped intensities from image*based information (e.g. IMC, IF, MIBI, ...) and polygon data (e.g. cell) +* New `overlapImagesToMatrix()` converts intensity*polygon overlap info into an expression matrix (e.g. cell by protein) +* New `aggregateStacks()` set of functions work with multiple subcellular layers when generating aggregated expression matrices ## Changes -- Update `setter` functions to read the `@spat_unit` and `@feat_type` slots of subobjects to determine nesting -- Update of `show` functions to display color coded nesting names and tree structure +* Update `setter` functions to read the `@spat_unit` and `@feat_type` slots of subobjects to determine nesting +* Update of `show` functions to display color coded nesting names and tree structure -# Giotto Suite 2.1.0 (2022-11-09) + +# Giotto Suite 2.1.0 (2022*11*09) ## Breaking Changes -- Update of python version to **3.10.2** [details](https://giottosuite.readthedocs.io/en/latest/additionalinformation.html#giotto-suite-2-1-0-2202-11-09) + +* Update of python version to **3.10.2** [details](https://giottosuite.readthedocs.io/en/latest/additionalinformation.html#giotto*suite*2*1*0*2202*11*09) ## Added -- New `anndataToGiotto()` to convert scanpy anndata to Giotto + +* New `anndataToGiotto()` to convert scanpy anndata to Giotto @@ -240,27 +260,30 @@ # Giotto Suite 2.0.0.998 ## Added -- New `GiottoData` package to work with spatial datasets associated with Giotto - - Stores the minidatasets: preprocessed giotto objects that are ready to be used in any function - - Moved: `getSpatialDataset()` and `loadGiottoMini()` functions to this package -- New `saveGiotto()` and `loadGiotto()` for preserving memory-pointer based objects. In [general_help.R](https://github.com/drieslab/Giotto/blob/suite/R/general_help.R) - - It saves a Giotto object into a folder using a specific structure. Essentially a wrapper around `saveRDS()` that also works with spatVector and spatRaster pointers. -- New `plotInteractivePolygon()` for plot-interactive polygonal selection of points. -- New polygon shape array creation through `polyStamp()`, `circleVertices`, `rectVertices`. In [giotto_structures.R](https://github.com/drieslab/Giotto/blob/suite/R/giotto_structures.R) -- Add accessor functions `get_CellMetadata` (alias of `pDataDT()`), `set_CellMetadata`, `get_FeatMetadata` (alias of `fDataDT()`), `set_FeatMetadata`. See [accessors.R](https://github.com/drieslab/Giotto/blob/suite/R/accessors.R) -- New `filterDistributions()` to generate histogram plots from expression statistics + +* New `GiottoData` package to work with spatial datasets associated with Giotto + * Stores the minidatasets: preprocessed giotto objects that are ready to be used in any function + * Moved: `getSpatialDataset()` and `loadGiottoMini()` functions to this package +* New `saveGiotto()` and `loadGiotto()` for preserving memory*pointer based objects. In [general_help.R](https://github.com/drieslab/Giotto/blob/suite/R/general_help.R) + * It saves a Giotto object into a folder using a specific structure. Essentially a wrapper around `saveRDS()` that also works with spatVector and spatRaster pointers. +* New `plotInteractivePolygon()` for plot*interactive polygonal selection of points. +* New polygon shape array creation through `polyStamp()`, `circleVertices`, `rectVertices`. In [giotto_structures.R](https://github.com/drieslab/Giotto/blob/suite/R/giotto_structures.R) +* Add accessor functions `get_CellMetadata` (alias of `pDataDT()`), `set_CellMetadata`, `get_FeatMetadata` (alias of `fDataDT()`), `set_FeatMetadata`. See [accessors.R](https://github.com/drieslab/Giotto/blob/suite/R/accessors.R) +* New `filterDistributions()` to generate histogram plots from expression statistics ## Changes -- Deprecate `plotInteractionChangedGenes()` ,`plotICG()`, `plotCPG()` in favor of `plotInteractionChangedFeatures()` and `plotICF()` and `plotCPF()` -- Deprecate `plotCellProximityGenes()`, in favor of `plotCellProximityFeatures()` -- Deprecate `plotCombineInteractionChangedGenes()`, `plotCombineICG()`, `plotCombineCPG()` in favor of `plotCombineInteractionChangedFeatures()` and `plotCombineICF()` -- Deprecate `findInteractionChangedGenes()`, `findICG()`, `findCPG()` in favor of `findInteractionChangedFeats()` and `findICF` -- Deprecate `filterInteractionChangedGenes()`, `filterICG()`, `filterCPG()` in favor of `filterInteractionChangedFeats()` and `filterICF()` -- Deprecate `combineInteractionChangedGenes()`, `combineICG()`, `combineCPG()` in favor of `combineInteractionChangedFeats()` and `combineICF()` -- Deprecate `combineCellProximityGenes_per_interaction()` in favor of `combineCellProximityFeatures_per_interaction()` + +* Deprecate `plotInteractionChangedGenes()` ,`plotICG()`, `plotCPG()` in favor of `plotInteractionChangedFeatures()` and `plotICF()` and `plotCPF()` +* Deprecate `plotCellProximityGenes()`, in favor of `plotCellProximityFeatures()` +* Deprecate `plotCombineInteractionChangedGenes()`, `plotCombineICG()`, `plotCombineCPG()` in favor of `plotCombineInteractionChangedFeatures()` and `plotCombineICF()` +* Deprecate `findInteractionChangedGenes()`, `findICG()`, `findCPG()` in favor of `findInteractionChangedFeats()` and `findICF` +* Deprecate `filterInteractionChangedGenes()`, `filterICG()`, `filterCPG()` in favor of `filterInteractionChangedFeats()` and `filterICF()` +* Deprecate `combineInteractionChangedGenes()`, `combineICG()`, `combineCPG()` in favor of `combineInteractionChangedFeats()` and `combineICF()` +* Deprecate `combineCellProximityGenes_per_interaction()` in favor of `combineCellProximityFeatures_per_interaction()` ## Breaking Changes -- ICF output internal object structure names have changed to use feats instead of genes + +* ICF output internal object structure names have changed to use feats instead of genes diff --git a/_pkgdown.yml b/_pkgdown.yml index f37929ae9..a8f5b27ca 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -13,22 +13,89 @@ template: primary: "#7E69AE" code_font: {google: "JetBrains Mono"} +development: + mode: auto + navbar: bg: dark structure: left: - intro - reference - right: github + - articles + - news + right: + - search + - github components: reference: text: Documentation href: reference/index.html + articles: + text: Tutorials + menu: + - text: Stereo-seq + - text: MOSTA E12.5_E1S3 + href: articles/stereoseq_mosta.html + - text: ------- + - text: Seq-Scope + - text: Mouse liver + href: articles/seqscope_mouse_liver.html + - text: ------- + - text: Visium + - text: Visium Mouse Kidney + href: articles/visium_mouse_kidney.html + - text: Visium Mouse Brain + href: articles/visium_mouse_brain.html + - text: Visium Prostate Integration + href: articles/visium_prostate_integration.html + - text: CytAssist Human Lung Cancer + href: articles/visium_cytassist_lungcancer.html + - text: CytAssist Multi-omics Human Glioblastoma + href: articles/visium_cytassist_human_glioblastoma.html + - text: ------- + - text: Single Cell RNA Sequencing + - text: Prostate + href: articles/singlecell_prostate_standard.html + - text: Prostate Integration + href: articles/singlecell_prostate_integration.html + news: + text: News + href: news/index.html github: icon: fab fa-github fa-lg href: https://github.com/drieslab/Giotto/ aria-label: github +articles: +- title: Stereo-seq + navbar: ~ + contents: + - stereoseq_mosta +- title: Seq-Scope + navbar: ~ + contents: + - seqscope_mouse_liver +- title: Visium + navbar: ~ + contents: + - visium_mouse_kidney + - visium_mouse_brain + - visium_prostate_integration + - visium_cytassist_lungcancer + - visium_cytassist_human_glioblastoma +- title: Single Cell RNA Sequencing + navbar: ~ + contents: + - singlecell_prostate_standard + - singlecell_prostate_integration + + + +news: + cran_dates: false + + home: sidebar: structure: [links, license, community, citation, authors, dev] diff --git a/vignettes/images/general_figs/CODEX_spleen_image_summary.png b/vignettes/images/general_figs/CODEX_spleen_image_summary.png new file mode 100644 index 000000000..4a06b59ef Binary files /dev/null and b/vignettes/images/general_figs/CODEX_spleen_image_summary.png differ diff --git a/vignettes/images/general_figs/Giotto_to_suite.png b/vignettes/images/general_figs/Giotto_to_suite.png new file mode 100644 index 000000000..3cc5802bc Binary files /dev/null and b/vignettes/images/general_figs/Giotto_to_suite.png differ diff --git a/vignettes/images/general_figs/Visium_FFPE_Human_Normal_Prostate_image.png b/vignettes/images/general_figs/Visium_FFPE_Human_Normal_Prostate_image.png new file mode 100644 index 000000000..ac3a91528 Binary files /dev/null and b/vignettes/images/general_figs/Visium_FFPE_Human_Normal_Prostate_image.png differ diff --git a/vignettes/images/general_figs/Visium_FFPE_Human_Prostate_Cancer_image.png b/vignettes/images/general_figs/Visium_FFPE_Human_Prostate_Cancer_image.png new file mode 100644 index 000000000..b95142309 Binary files /dev/null and b/vignettes/images/general_figs/Visium_FFPE_Human_Prostate_Cancer_image.png differ diff --git a/vignettes/images/general_figs/coming_soon_summary.png b/vignettes/images/general_figs/coming_soon_summary.png new file mode 100644 index 000000000..369b477d1 Binary files /dev/null and b/vignettes/images/general_figs/coming_soon_summary.png differ diff --git a/vignettes/images/general_figs/construction-boy.png b/vignettes/images/general_figs/construction-boy.png new file mode 100644 index 000000000..bfb0a5205 Binary files /dev/null and b/vignettes/images/general_figs/construction-boy.png differ diff --git a/vignettes/images/general_figs/cortex_image_summary.png b/vignettes/images/general_figs/cortex_image_summary.png new file mode 100644 index 000000000..d000aada3 Binary files /dev/null and b/vignettes/images/general_figs/cortex_image_summary.png differ diff --git a/vignettes/images/general_figs/cortex_svz_location_fields.png b/vignettes/images/general_figs/cortex_svz_location_fields.png new file mode 100644 index 000000000..69b6c5306 Binary files /dev/null and b/vignettes/images/general_figs/cortex_svz_location_fields.png differ diff --git a/vignettes/images/general_figs/cyCIF_PDAC_image_summary.png b/vignettes/images/general_figs/cyCIF_PDAC_image_summary.png new file mode 100644 index 000000000..7966e53c4 Binary files /dev/null and b/vignettes/images/general_figs/cyCIF_PDAC_image_summary.png differ diff --git a/vignettes/images/general_figs/cycif_paper_figure.png b/vignettes/images/general_figs/cycif_paper_figure.png new file mode 100644 index 000000000..c6d0ce2b9 Binary files /dev/null and b/vignettes/images/general_figs/cycif_paper_figure.png differ diff --git a/vignettes/images/general_figs/diagram_giotto_workflow.png b/vignettes/images/general_figs/diagram_giotto_workflow.png new file mode 100644 index 000000000..10722560f Binary files /dev/null and b/vignettes/images/general_figs/diagram_giotto_workflow.png differ diff --git a/vignettes/images/general_figs/merFISH_hypoth_image_summary.png b/vignettes/images/general_figs/merFISH_hypoth_image_summary.png new file mode 100644 index 000000000..3da5fa6d3 Binary files /dev/null and b/vignettes/images/general_figs/merFISH_hypoth_image_summary.png differ diff --git a/vignettes/images/general_figs/mouse_brain_highres.png b/vignettes/images/general_figs/mouse_brain_highres.png new file mode 100644 index 000000000..b1debc72d Binary files /dev/null and b/vignettes/images/general_figs/mouse_brain_highres.png differ diff --git a/vignettes/images/general_figs/mouse_kidney_highres.png b/vignettes/images/general_figs/mouse_kidney_highres.png new file mode 100644 index 000000000..1ac2cb22c Binary files /dev/null and b/vignettes/images/general_figs/mouse_kidney_highres.png differ diff --git a/vignettes/images/general_figs/osmFISH_SS_cortex_image_summary.png b/vignettes/images/general_figs/osmFISH_SS_cortex_image_summary.png new file mode 100644 index 000000000..695f237fd Binary files /dev/null and b/vignettes/images/general_figs/osmFISH_SS_cortex_image_summary.png differ diff --git a/vignettes/images/general_figs/osmfish_image_demo.png b/vignettes/images/general_figs/osmfish_image_demo.png new file mode 100644 index 000000000..163ed0e91 Binary files /dev/null and b/vignettes/images/general_figs/osmfish_image_demo.png differ diff --git a/vignettes/images/general_figs/overview_datasets.png b/vignettes/images/general_figs/overview_datasets.png new file mode 100644 index 000000000..6730727a8 Binary files /dev/null and b/vignettes/images/general_figs/overview_datasets.png differ diff --git a/vignettes/images/general_figs/overview_datasets2.png b/vignettes/images/general_figs/overview_datasets2.png new file mode 100644 index 000000000..1bd31f598 Binary files /dev/null and b/vignettes/images/general_figs/overview_datasets2.png differ diff --git a/vignettes/images/general_figs/resolve_bioscience_cancer_summary.png b/vignettes/images/general_figs/resolve_bioscience_cancer_summary.png new file mode 100644 index 000000000..7e653283a Binary files /dev/null and b/vignettes/images/general_figs/resolve_bioscience_cancer_summary.png differ diff --git a/vignettes/images/general_figs/starmap_cortex_image_summary.png b/vignettes/images/general_figs/starmap_cortex_image_summary.png new file mode 100644 index 000000000..feb7b9b93 Binary files /dev/null and b/vignettes/images/general_figs/starmap_cortex_image_summary.png differ diff --git a/vignettes/images/general_figs/temp_workflow.png b/vignettes/images/general_figs/temp_workflow.png new file mode 100644 index 000000000..1266db7ea Binary files /dev/null and b/vignettes/images/general_figs/temp_workflow.png differ diff --git a/vignettes/images/general_figs/visium_brain_image_summary.png b/vignettes/images/general_figs/visium_brain_image_summary.png new file mode 100644 index 000000000..ff5a93011 Binary files /dev/null and b/vignettes/images/general_figs/visium_brain_image_summary.png differ diff --git a/vignettes/images/general_figs/visium_kidney_image_summary.png b/vignettes/images/general_figs/visium_kidney_image_summary.png new file mode 100644 index 000000000..487a2e2f4 Binary files /dev/null and b/vignettes/images/general_figs/visium_kidney_image_summary.png differ diff --git a/vignettes/images/general_figs/visium_prostate_summary.png b/vignettes/images/general_figs/visium_prostate_summary.png new file mode 100644 index 000000000..946b4c4c5 Binary files /dev/null and b/vignettes/images/general_figs/visium_prostate_summary.png differ diff --git a/vignettes/images/general_figs/visium_technology.png b/vignettes/images/general_figs/visium_technology.png new file mode 100644 index 000000000..cc3bb159f Binary files /dev/null and b/vignettes/images/general_figs/visium_technology.png differ diff --git a/vignettes/images/general_figs/vizgen_brain_summary.png b/vignettes/images/general_figs/vizgen_brain_summary.png new file mode 100644 index 000000000..6cdc55ba0 Binary files /dev/null and b/vignettes/images/general_figs/vizgen_brain_summary.png differ diff --git a/vignettes/images/seqscope_mouse_liver/HDMI_scatter.png b/vignettes/images/seqscope_mouse_liver/HDMI_scatter.png new file mode 100644 index 000000000..a105b8910 Binary files /dev/null and b/vignettes/images/seqscope_mouse_liver/HDMI_scatter.png differ diff --git a/vignettes/images/seqscope_mouse_liver/feature_distribution.png b/vignettes/images/seqscope_mouse_liver/feature_distribution.png new file mode 100644 index 000000000..1c206e808 Binary files /dev/null and b/vignettes/images/seqscope_mouse_liver/feature_distribution.png differ diff --git a/vignettes/images/seqscope_mouse_liver/leiden_spat.png b/vignettes/images/seqscope_mouse_liver/leiden_spat.png new file mode 100644 index 000000000..4f532741b Binary files /dev/null and b/vignettes/images/seqscope_mouse_liver/leiden_spat.png differ diff --git a/vignettes/images/seqscope_mouse_liver/leiden_umap.png b/vignettes/images/seqscope_mouse_liver/leiden_umap.png new file mode 100644 index 000000000..e837a3315 Binary files /dev/null and b/vignettes/images/seqscope_mouse_liver/leiden_umap.png differ diff --git a/vignettes/images/seqscope_mouse_liver/polygon.png b/vignettes/images/seqscope_mouse_liver/polygon.png new file mode 100644 index 000000000..0a4744f43 Binary files /dev/null and b/vignettes/images/seqscope_mouse_liver/polygon.png differ diff --git a/vignettes/images/seqscope_mouse_liver/spatgenes.png b/vignettes/images/seqscope_mouse_liver/spatgenes.png new file mode 100644 index 000000000..7ee3ef882 Binary files /dev/null and b/vignettes/images/seqscope_mouse_liver/spatgenes.png differ diff --git a/vignettes/images/seqscope_mouse_liver/top200.png b/vignettes/images/seqscope_mouse_liver/top200.png new file mode 100644 index 000000000..901eae72b Binary files /dev/null and b/vignettes/images/seqscope_mouse_liver/top200.png differ diff --git a/vignettes/images/seqscope_mouse_liver/total_expr.png b/vignettes/images/seqscope_mouse_liver/total_expr.png new file mode 100644 index 000000000..02abd4d4a Binary files /dev/null and b/vignettes/images/seqscope_mouse_liver/total_expr.png differ diff --git a/vignettes/images/singlecell_prostate_integration/4_cluster_with_integration.png b/vignettes/images/singlecell_prostate_integration/4_cluster_with_integration.png new file mode 100644 index 000000000..126da6056 Binary files /dev/null and b/vignettes/images/singlecell_prostate_integration/4_cluster_with_integration.png differ diff --git a/vignettes/images/singlecell_prostate_integration/4_cluster_without_integration.png b/vignettes/images/singlecell_prostate_integration/4_cluster_without_integration.png new file mode 100644 index 000000000..f751a3802 Binary files /dev/null and b/vignettes/images/singlecell_prostate_integration/4_cluster_without_integration.png differ diff --git a/vignettes/images/singlecell_prostate_integration/4_list_with_integration.png b/vignettes/images/singlecell_prostate_integration/4_list_with_integration.png new file mode 100644 index 000000000..8465f8dc7 Binary files /dev/null and b/vignettes/images/singlecell_prostate_integration/4_list_with_integration.png differ diff --git a/vignettes/images/singlecell_prostate_integration/4_list_without_integration.png b/vignettes/images/singlecell_prostate_integration/4_list_without_integration.png new file mode 100644 index 000000000..ae5ea022e Binary files /dev/null and b/vignettes/images/singlecell_prostate_integration/4_list_without_integration.png differ diff --git a/vignettes/images/singlecell_rna_seq/3_scree_plot.png b/vignettes/images/singlecell_rna_seq/3_scree_plot.png new file mode 100644 index 000000000..ba099380e Binary files /dev/null and b/vignettes/images/singlecell_rna_seq/3_scree_plot.png differ diff --git a/vignettes/images/singlecell_rna_seq/4_Cluster.png b/vignettes/images/singlecell_rna_seq/4_Cluster.png new file mode 100644 index 000000000..b3624ffdd Binary files /dev/null and b/vignettes/images/singlecell_rna_seq/4_Cluster.png differ diff --git a/vignettes/images/singlecell_rna_seq/5_a_metaheatmap.png b/vignettes/images/singlecell_rna_seq/5_a_metaheatmap.png new file mode 100644 index 000000000..f0edb8207 Binary files /dev/null and b/vignettes/images/singlecell_rna_seq/5_a_metaheatmap.png differ diff --git a/vignettes/images/singlecell_rna_seq/5_b_violinplot_scran.png b/vignettes/images/singlecell_rna_seq/5_b_violinplot_scran.png new file mode 100644 index 000000000..e563ff0f8 Binary files /dev/null and b/vignettes/images/singlecell_rna_seq/5_b_violinplot_scran.png differ diff --git a/vignettes/images/singlecell_rna_seq/6_featureplot.png b/vignettes/images/singlecell_rna_seq/6_featureplot.png new file mode 100644 index 000000000..28820bc6f Binary files /dev/null and b/vignettes/images/singlecell_rna_seq/6_featureplot.png differ diff --git a/vignettes/images/singlecell_rna_seq/7_Annotation.png b/vignettes/images/singlecell_rna_seq/7_Annotation.png new file mode 100644 index 000000000..6157bf520 Binary files /dev/null and b/vignettes/images/singlecell_rna_seq/7_Annotation.png differ diff --git a/vignettes/images/singlecell_rna_seq/8_c_metaheatmap.png b/vignettes/images/singlecell_rna_seq/8_c_metaheatmap.png new file mode 100644 index 000000000..a1f23243f Binary files /dev/null and b/vignettes/images/singlecell_rna_seq/8_c_metaheatmap.png differ diff --git a/vignettes/images/singlecell_rna_seq/8a_scree_plot.png b/vignettes/images/singlecell_rna_seq/8a_scree_plot.png new file mode 100644 index 000000000..57993be71 Binary files /dev/null and b/vignettes/images/singlecell_rna_seq/8a_scree_plot.png differ diff --git a/vignettes/images/singlecell_rna_seq/8b_Cluster.png b/vignettes/images/singlecell_rna_seq/8b_Cluster.png new file mode 100644 index 000000000..bcb0c4de2 Binary files /dev/null and b/vignettes/images/singlecell_rna_seq/8b_Cluster.png differ diff --git a/vignettes/images/singlecell_rna_seq/8d_Annotation.png b/vignettes/images/singlecell_rna_seq/8d_Annotation.png new file mode 100644 index 000000000..ebda7bc09 Binary files /dev/null and b/vignettes/images/singlecell_rna_seq/8d_Annotation.png differ diff --git a/vignettes/images/stereoseq_mosta/1.png b/vignettes/images/stereoseq_mosta/1.png new file mode 100644 index 000000000..ff8ebddf2 Binary files /dev/null and b/vignettes/images/stereoseq_mosta/1.png differ diff --git a/vignettes/images/stereoseq_mosta/2.png b/vignettes/images/stereoseq_mosta/2.png new file mode 100644 index 000000000..ec7f88020 Binary files /dev/null and b/vignettes/images/stereoseq_mosta/2.png differ diff --git a/vignettes/images/stereoseq_mosta/3.png b/vignettes/images/stereoseq_mosta/3.png new file mode 100644 index 000000000..321e9288f Binary files /dev/null and b/vignettes/images/stereoseq_mosta/3.png differ diff --git a/vignettes/images/stereoseq_mosta/4.png b/vignettes/images/stereoseq_mosta/4.png new file mode 100644 index 000000000..ab3d0a265 Binary files /dev/null and b/vignettes/images/stereoseq_mosta/4.png differ diff --git a/vignettes/images/stereoseq_mosta/5.png b/vignettes/images/stereoseq_mosta/5.png new file mode 100644 index 000000000..9fb9c7e39 Binary files /dev/null and b/vignettes/images/stereoseq_mosta/5.png differ diff --git a/vignettes/images/stereoseq_mosta/6.png b/vignettes/images/stereoseq_mosta/6.png new file mode 100644 index 000000000..be130ebc4 Binary files /dev/null and b/vignettes/images/stereoseq_mosta/6.png differ diff --git a/vignettes/images/stereoseq_mosta/7.png b/vignettes/images/stereoseq_mosta/7.png new file mode 100644 index 000000000..ad43bcd46 Binary files /dev/null and b/vignettes/images/stereoseq_mosta/7.png differ diff --git a/vignettes/images/stereoseq_mosta/8.png b/vignettes/images/stereoseq_mosta/8.png new file mode 100644 index 000000000..7b53514e7 Binary files /dev/null and b/vignettes/images/stereoseq_mosta/8.png differ diff --git a/vignettes/images/stereoseq_mosta/9.png b/vignettes/images/stereoseq_mosta/9.png new file mode 100644 index 000000000..be241c1bd Binary files /dev/null and b/vignettes/images/stereoseq_mosta/9.png differ diff --git a/vignettes/images/visium_cytassist_human_glioblastoma/1-spatPlot2D.png b/vignettes/images/visium_cytassist_human_glioblastoma/1-spatPlot2D.png new file mode 100644 index 000000000..614dc7d98 Binary files /dev/null and b/vignettes/images/visium_cytassist_human_glioblastoma/1-spatPlot2D.png differ diff --git a/vignettes/images/visium_cytassist_human_glioblastoma/10-UMAP.png b/vignettes/images/visium_cytassist_human_glioblastoma/10-UMAP.png new file mode 100644 index 000000000..286286201 Binary files /dev/null and b/vignettes/images/visium_cytassist_human_glioblastoma/10-UMAP.png differ diff --git a/vignettes/images/visium_cytassist_human_glioblastoma/11-rna_spatPlot2D.png b/vignettes/images/visium_cytassist_human_glioblastoma/11-rna_spatPlot2D.png new file mode 100644 index 000000000..bbb73d2d7 Binary files /dev/null and b/vignettes/images/visium_cytassist_human_glioblastoma/11-rna_spatPlot2D.png differ diff --git a/vignettes/images/visium_cytassist_human_glioblastoma/12-protein_spatPlot2D.png b/vignettes/images/visium_cytassist_human_glioblastoma/12-protein_spatPlot2D.png new file mode 100644 index 000000000..245cff8f1 Binary files /dev/null and b/vignettes/images/visium_cytassist_human_glioblastoma/12-protein_spatPlot2D.png differ diff --git a/vignettes/images/visium_cytassist_human_glioblastoma/13-UMAP.png b/vignettes/images/visium_cytassist_human_glioblastoma/13-UMAP.png new file mode 100644 index 000000000..3a65a9a6e Binary files /dev/null and b/vignettes/images/visium_cytassist_human_glioblastoma/13-UMAP.png differ diff --git a/vignettes/images/visium_cytassist_human_glioblastoma/14-integrated_spatPlot2D.png b/vignettes/images/visium_cytassist_human_glioblastoma/14-integrated_spatPlot2D.png new file mode 100644 index 000000000..988a35447 Binary files /dev/null and b/vignettes/images/visium_cytassist_human_glioblastoma/14-integrated_spatPlot2D.png differ diff --git a/vignettes/images/visium_cytassist_human_glioblastoma/2-spatPlot2D.png b/vignettes/images/visium_cytassist_human_glioblastoma/2-spatPlot2D.png new file mode 100644 index 000000000..7c9aa422c Binary files /dev/null and b/vignettes/images/visium_cytassist_human_glioblastoma/2-spatPlot2D.png differ diff --git a/vignettes/images/visium_cytassist_human_glioblastoma/3-spatPlot2D.png b/vignettes/images/visium_cytassist_human_glioblastoma/3-spatPlot2D.png new file mode 100644 index 000000000..f7847700c Binary files /dev/null and b/vignettes/images/visium_cytassist_human_glioblastoma/3-spatPlot2D.png differ diff --git a/vignettes/images/visium_cytassist_human_glioblastoma/4-HVFplot.png b/vignettes/images/visium_cytassist_human_glioblastoma/4-HVFplot.png new file mode 100644 index 000000000..c82c1ee36 Binary files /dev/null and b/vignettes/images/visium_cytassist_human_glioblastoma/4-HVFplot.png differ diff --git a/vignettes/images/visium_cytassist_human_glioblastoma/5-screePlot.png b/vignettes/images/visium_cytassist_human_glioblastoma/5-screePlot.png new file mode 100644 index 000000000..38a160c64 Binary files /dev/null and b/vignettes/images/visium_cytassist_human_glioblastoma/5-screePlot.png differ diff --git a/vignettes/images/visium_cytassist_human_glioblastoma/6-PCA.png b/vignettes/images/visium_cytassist_human_glioblastoma/6-PCA.png new file mode 100644 index 000000000..6ba10136d Binary files /dev/null and b/vignettes/images/visium_cytassist_human_glioblastoma/6-PCA.png differ diff --git a/vignettes/images/visium_cytassist_human_glioblastoma/7-screePlot.png b/vignettes/images/visium_cytassist_human_glioblastoma/7-screePlot.png new file mode 100644 index 000000000..21a30d2b4 Binary files /dev/null and b/vignettes/images/visium_cytassist_human_glioblastoma/7-screePlot.png differ diff --git a/vignettes/images/visium_cytassist_human_glioblastoma/8-PCA.png b/vignettes/images/visium_cytassist_human_glioblastoma/8-PCA.png new file mode 100644 index 000000000..81155d69c Binary files /dev/null and b/vignettes/images/visium_cytassist_human_glioblastoma/8-PCA.png differ diff --git a/vignettes/images/visium_cytassist_human_glioblastoma/9-UMAP.png b/vignettes/images/visium_cytassist_human_glioblastoma/9-UMAP.png new file mode 100644 index 000000000..2f99e37c1 Binary files /dev/null and b/vignettes/images/visium_cytassist_human_glioblastoma/9-UMAP.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/0-spatPlot2D.png b/vignettes/images/visium_cytassist_lungcancer/0-spatPlot2D.png new file mode 100644 index 000000000..192392b3b Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/0-spatPlot2D.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/1-spatPlot2D.png b/vignettes/images/visium_cytassist_lungcancer/1-spatPlot2D.png new file mode 100644 index 000000000..8c34a9f68 Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/1-spatPlot2D.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/10-spatDimPlot2D.png b/vignettes/images/visium_cytassist_lungcancer/10-spatDimPlot2D.png new file mode 100644 index 000000000..074a4d7fe Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/10-spatDimPlot2D.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/11-spatDimPlot2D.png b/vignettes/images/visium_cytassist_lungcancer/11-spatDimPlot2D.png new file mode 100644 index 000000000..1d035a661 Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/11-spatDimPlot2D.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/12-violinPlot.png b/vignettes/images/visium_cytassist_lungcancer/12-violinPlot.png new file mode 100644 index 000000000..f632fafe0 Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/12-violinPlot.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/13-plotMetaDataHeatmap.png b/vignettes/images/visium_cytassist_lungcancer/13-plotMetaDataHeatmap.png new file mode 100644 index 000000000..4c17b7e3a Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/13-plotMetaDataHeatmap.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/14-dimFeatPlot2D.png b/vignettes/images/visium_cytassist_lungcancer/14-dimFeatPlot2D.png new file mode 100644 index 000000000..93a110019 Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/14-dimFeatPlot2D.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/15-violinPlot.png b/vignettes/images/visium_cytassist_lungcancer/15-violinPlot.png new file mode 100644 index 000000000..bf4dbbb64 Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/15-violinPlot.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/16-plotMetaDataHeatmap.png b/vignettes/images/visium_cytassist_lungcancer/16-plotMetaDataHeatmap.png new file mode 100644 index 000000000..aa2613f77 Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/16-plotMetaDataHeatmap.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/17-metaheatmap.png b/vignettes/images/visium_cytassist_lungcancer/17-metaheatmap.png new file mode 100644 index 000000000..65025310a Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/17-metaheatmap.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/18-spatcellplot_1.png b/vignettes/images/visium_cytassist_lungcancer/18-spatcellplot_1.png new file mode 100644 index 000000000..cc94c6862 Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/18-spatcellplot_1.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/19-spatDimCellPlot.png b/vignettes/images/visium_cytassist_lungcancer/19-spatDimCellPlot.png new file mode 100644 index 000000000..7befe41b1 Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/19-spatDimCellPlot.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/2-spatPlot2D.png b/vignettes/images/visium_cytassist_lungcancer/2-spatPlot2D.png new file mode 100644 index 000000000..bc9ef414c Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/2-spatPlot2D.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/20-spatPlot2D.png b/vignettes/images/visium_cytassist_lungcancer/20-spatPlot2D.png new file mode 100644 index 000000000..c42a1802c Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/20-spatPlot2D.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/21-plotStatDelaunayNetwork.png b/vignettes/images/visium_cytassist_lungcancer/21-plotStatDelaunayNetwork.png new file mode 100644 index 000000000..b1f815a14 Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/21-plotStatDelaunayNetwork.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/22-spatPlot2D.png b/vignettes/images/visium_cytassist_lungcancer/22-spatPlot2D.png new file mode 100644 index 000000000..059ab4d23 Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/22-spatPlot2D.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/23-spatFeatPlot2D.png b/vignettes/images/visium_cytassist_lungcancer/23-spatFeatPlot2D.png new file mode 100644 index 000000000..c20df7d63 Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/23-spatFeatPlot2D.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/24-spatFeatPlot2D.png b/vignettes/images/visium_cytassist_lungcancer/24-spatFeatPlot2D.png new file mode 100644 index 000000000..a652f18d2 Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/24-spatFeatPlot2D.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/25-spatFeatPlot2D.png b/vignettes/images/visium_cytassist_lungcancer/25-spatFeatPlot2D.png new file mode 100644 index 000000000..59442ca60 Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/25-spatFeatPlot2D.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/26-heatmap_correlated_genes.png b/vignettes/images/visium_cytassist_lungcancer/26-heatmap_correlated_genes.png new file mode 100644 index 000000000..3141530f3 Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/26-heatmap_correlated_genes.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/27-rank_correlated_groups.png b/vignettes/images/visium_cytassist_lungcancer/27-rank_correlated_groups.png new file mode 100644 index 000000000..80fb29bb9 Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/27-rank_correlated_groups.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/28-spatCellPlot2D.png b/vignettes/images/visium_cytassist_lungcancer/28-spatCellPlot2D.png new file mode 100644 index 000000000..6d015b9ab Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/28-spatCellPlot2D.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/29-spatPlot2D.png b/vignettes/images/visium_cytassist_lungcancer/29-spatPlot2D.png new file mode 100644 index 000000000..f2bbf3f02 Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/29-spatPlot2D.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/3-HVFplot.png b/vignettes/images/visium_cytassist_lungcancer/3-HVFplot.png new file mode 100644 index 000000000..76ddfc0bd Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/3-HVFplot.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/30-spatPlot2D.png b/vignettes/images/visium_cytassist_lungcancer/30-spatPlot2D.png new file mode 100644 index 000000000..21d4410b9 Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/30-spatPlot2D.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/4-screePlot.png b/vignettes/images/visium_cytassist_lungcancer/4-screePlot.png new file mode 100644 index 000000000..0d866fa07 Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/4-screePlot.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/5-PCA.png b/vignettes/images/visium_cytassist_lungcancer/5-PCA.png new file mode 100644 index 000000000..737c208a6 Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/5-PCA.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/6-UMAP.png b/vignettes/images/visium_cytassist_lungcancer/6-UMAP.png new file mode 100644 index 000000000..6c088fa8b Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/6-UMAP.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/7-tSNE.png b/vignettes/images/visium_cytassist_lungcancer/7-tSNE.png new file mode 100644 index 000000000..3c83aa6e5 Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/7-tSNE.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/8-UMAP.png b/vignettes/images/visium_cytassist_lungcancer/8-UMAP.png new file mode 100644 index 000000000..8613f73d0 Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/8-UMAP.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/9-tSNE.png b/vignettes/images/visium_cytassist_lungcancer/9-tSNE.png new file mode 100644 index 000000000..b40e2bd09 Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/9-tSNE.png differ diff --git a/vignettes/images/visium_cytassist_lungcancer/CytAssist_Visium_workflow.png b/vignettes/images/visium_cytassist_lungcancer/CytAssist_Visium_workflow.png new file mode 100644 index 000000000..15272314d Binary files /dev/null and b/vignettes/images/visium_cytassist_lungcancer/CytAssist_Visium_workflow.png differ diff --git a/vignettes/images/visium_mouse_brain/0-spatPlot2D.png b/vignettes/images/visium_mouse_brain/0-spatPlot2D.png new file mode 100644 index 000000000..9ba92eaa7 Binary files /dev/null and b/vignettes/images/visium_mouse_brain/0-spatPlot2D.png differ diff --git a/vignettes/images/visium_mouse_brain/1-spatPlot2D.png b/vignettes/images/visium_mouse_brain/1-spatPlot2D.png new file mode 100644 index 000000000..5bf8fed7f Binary files /dev/null and b/vignettes/images/visium_mouse_brain/1-spatPlot2D.png differ diff --git a/vignettes/images/visium_mouse_brain/10-spatPlot2D.png b/vignettes/images/visium_mouse_brain/10-spatPlot2D.png new file mode 100644 index 000000000..9a396f016 Binary files /dev/null and b/vignettes/images/visium_mouse_brain/10-spatPlot2D.png differ diff --git a/vignettes/images/visium_mouse_brain/11-spatPlot2D.png b/vignettes/images/visium_mouse_brain/11-spatPlot2D.png new file mode 100644 index 000000000..bce001448 Binary files /dev/null and b/vignettes/images/visium_mouse_brain/11-spatPlot2D.png differ diff --git a/vignettes/images/visium_mouse_brain/12-spatPlot2D.png b/vignettes/images/visium_mouse_brain/12-spatPlot2D.png new file mode 100644 index 000000000..07cc1f7d8 Binary files /dev/null and b/vignettes/images/visium_mouse_brain/12-spatPlot2D.png differ diff --git a/vignettes/images/visium_mouse_brain/13-spatDimPlot2D.png b/vignettes/images/visium_mouse_brain/13-spatDimPlot2D.png new file mode 100644 index 000000000..cc5c9b483 Binary files /dev/null and b/vignettes/images/visium_mouse_brain/13-spatDimPlot2D.png differ diff --git a/vignettes/images/visium_mouse_brain/14-violinPlot.png b/vignettes/images/visium_mouse_brain/14-violinPlot.png new file mode 100644 index 000000000..9e8441ec7 Binary files /dev/null and b/vignettes/images/visium_mouse_brain/14-violinPlot.png differ diff --git a/vignettes/images/visium_mouse_brain/15-plotMetaDataHeatmap.png b/vignettes/images/visium_mouse_brain/15-plotMetaDataHeatmap.png new file mode 100644 index 000000000..0911c3a08 Binary files /dev/null and b/vignettes/images/visium_mouse_brain/15-plotMetaDataHeatmap.png differ diff --git a/vignettes/images/visium_mouse_brain/16-dimFeatPlot2D.png b/vignettes/images/visium_mouse_brain/16-dimFeatPlot2D.png new file mode 100644 index 000000000..6120587fb Binary files /dev/null and b/vignettes/images/visium_mouse_brain/16-dimFeatPlot2D.png differ diff --git a/vignettes/images/visium_mouse_brain/17-violinPlot.png b/vignettes/images/visium_mouse_brain/17-violinPlot.png new file mode 100644 index 000000000..830ef0de8 Binary files /dev/null and b/vignettes/images/visium_mouse_brain/17-violinPlot.png differ diff --git a/vignettes/images/visium_mouse_brain/18-plotMetaDataHeatmap.png b/vignettes/images/visium_mouse_brain/18-plotMetaDataHeatmap.png new file mode 100644 index 000000000..2caec5e92 Binary files /dev/null and b/vignettes/images/visium_mouse_brain/18-plotMetaDataHeatmap.png differ diff --git a/vignettes/images/visium_mouse_brain/19-dimFeatPlot2D.png b/vignettes/images/visium_mouse_brain/19-dimFeatPlot2D.png new file mode 100644 index 000000000..eb902e31a Binary files /dev/null and b/vignettes/images/visium_mouse_brain/19-dimFeatPlot2D.png differ diff --git a/vignettes/images/visium_mouse_brain/2-HVFplot.png b/vignettes/images/visium_mouse_brain/2-HVFplot.png new file mode 100644 index 000000000..ce695fa9d Binary files /dev/null and b/vignettes/images/visium_mouse_brain/2-HVFplot.png differ diff --git a/vignettes/images/visium_mouse_brain/20-plotMetaDataCellsHeatmap.png b/vignettes/images/visium_mouse_brain/20-plotMetaDataCellsHeatmap.png new file mode 100644 index 000000000..69e81149f Binary files /dev/null and b/vignettes/images/visium_mouse_brain/20-plotMetaDataCellsHeatmap.png differ diff --git a/vignettes/images/visium_mouse_brain/21-spatCellPlot2D.png b/vignettes/images/visium_mouse_brain/21-spatCellPlot2D.png new file mode 100644 index 000000000..d10638a49 Binary files /dev/null and b/vignettes/images/visium_mouse_brain/21-spatCellPlot2D.png differ diff --git a/vignettes/images/visium_mouse_brain/22-spatDimCellPlot2D.png b/vignettes/images/visium_mouse_brain/22-spatDimCellPlot2D.png new file mode 100644 index 000000000..a736a38c3 Binary files /dev/null and b/vignettes/images/visium_mouse_brain/22-spatDimCellPlot2D.png differ diff --git a/vignettes/images/visium_mouse_brain/23-spatCellPlot2D.png b/vignettes/images/visium_mouse_brain/23-spatCellPlot2D.png new file mode 100644 index 000000000..10d1b8c01 Binary files /dev/null and b/vignettes/images/visium_mouse_brain/23-spatCellPlot2D.png differ diff --git a/vignettes/images/visium_mouse_brain/24-spatPlot2D.png b/vignettes/images/visium_mouse_brain/24-spatPlot2D.png new file mode 100644 index 000000000..e3cbfb187 Binary files /dev/null and b/vignettes/images/visium_mouse_brain/24-spatPlot2D.png differ diff --git a/vignettes/images/visium_mouse_brain/25-spatPlot2D.png b/vignettes/images/visium_mouse_brain/25-spatPlot2D.png new file mode 100644 index 000000000..47eab2dc7 Binary files /dev/null and b/vignettes/images/visium_mouse_brain/25-spatPlot2D.png differ diff --git a/vignettes/images/visium_mouse_brain/26-spatFeatPlot2D.png b/vignettes/images/visium_mouse_brain/26-spatFeatPlot2D.png new file mode 100644 index 000000000..ecaddeba2 Binary files /dev/null and b/vignettes/images/visium_mouse_brain/26-spatFeatPlot2D.png differ diff --git a/vignettes/images/visium_mouse_brain/27-spatFeatPlot2D.png b/vignettes/images/visium_mouse_brain/27-spatFeatPlot2D.png new file mode 100644 index 000000000..eeb9ff32a Binary files /dev/null and b/vignettes/images/visium_mouse_brain/27-spatFeatPlot2D.png differ diff --git a/vignettes/images/visium_mouse_brain/28-heatmSpatialCorFeats.png b/vignettes/images/visium_mouse_brain/28-heatmSpatialCorFeats.png new file mode 100644 index 000000000..95b92a5b7 Binary files /dev/null and b/vignettes/images/visium_mouse_brain/28-heatmSpatialCorFeats.png differ diff --git a/vignettes/images/visium_mouse_brain/29-rankSpatialCorGroups.png b/vignettes/images/visium_mouse_brain/29-rankSpatialCorGroups.png new file mode 100644 index 000000000..c06c1cee8 Binary files /dev/null and b/vignettes/images/visium_mouse_brain/29-rankSpatialCorGroups.png differ diff --git a/vignettes/images/visium_mouse_brain/3-screePlot.png b/vignettes/images/visium_mouse_brain/3-screePlot.png new file mode 100644 index 000000000..b49e8cd7f Binary files /dev/null and b/vignettes/images/visium_mouse_brain/3-screePlot.png differ diff --git a/vignettes/images/visium_mouse_brain/30-spatCellPlot2D.png b/vignettes/images/visium_mouse_brain/30-spatCellPlot2D.png new file mode 100644 index 000000000..a975cbc23 Binary files /dev/null and b/vignettes/images/visium_mouse_brain/30-spatCellPlot2D.png differ diff --git a/vignettes/images/visium_mouse_brain/31-spatPlot2D.png b/vignettes/images/visium_mouse_brain/31-spatPlot2D.png new file mode 100644 index 000000000..8aa3f8c87 Binary files /dev/null and b/vignettes/images/visium_mouse_brain/31-spatPlot2D.png differ diff --git a/vignettes/images/visium_mouse_brain/32-UMAP.png b/vignettes/images/visium_mouse_brain/32-UMAP.png new file mode 100644 index 000000000..1b6896cdd Binary files /dev/null and b/vignettes/images/visium_mouse_brain/32-UMAP.png differ diff --git a/vignettes/images/visium_mouse_brain/33-spatPlot2D.png b/vignettes/images/visium_mouse_brain/33-spatPlot2D.png new file mode 100644 index 000000000..e86e53305 Binary files /dev/null and b/vignettes/images/visium_mouse_brain/33-spatPlot2D.png differ diff --git a/vignettes/images/visium_mouse_brain/4-PCA.png b/vignettes/images/visium_mouse_brain/4-PCA.png new file mode 100644 index 000000000..0351fae7d Binary files /dev/null and b/vignettes/images/visium_mouse_brain/4-PCA.png differ diff --git a/vignettes/images/visium_mouse_brain/5-UMAP.png b/vignettes/images/visium_mouse_brain/5-UMAP.png new file mode 100644 index 000000000..726fd476f Binary files /dev/null and b/vignettes/images/visium_mouse_brain/5-UMAP.png differ diff --git a/vignettes/images/visium_mouse_brain/6-tSNE.png b/vignettes/images/visium_mouse_brain/6-tSNE.png new file mode 100644 index 000000000..8f4a5500b Binary files /dev/null and b/vignettes/images/visium_mouse_brain/6-tSNE.png differ diff --git a/vignettes/images/visium_mouse_brain/7-UMAP.png b/vignettes/images/visium_mouse_brain/7-UMAP.png new file mode 100644 index 000000000..43f7cf073 Binary files /dev/null and b/vignettes/images/visium_mouse_brain/7-UMAP.png differ diff --git a/vignettes/images/visium_mouse_brain/8-spatDimPlot2D.png b/vignettes/images/visium_mouse_brain/8-spatDimPlot2D.png new file mode 100644 index 000000000..124487a5a Binary files /dev/null and b/vignettes/images/visium_mouse_brain/8-spatDimPlot2D.png differ diff --git a/vignettes/images/visium_mouse_brain/9-spatDimPlot2D.png b/vignettes/images/visium_mouse_brain/9-spatDimPlot2D.png new file mode 100644 index 000000000..2bff2be1c Binary files /dev/null and b/vignettes/images/visium_mouse_brain/9-spatDimPlot2D.png differ diff --git a/vignettes/images/visium_mouse_brain/DWLS_plot.png b/vignettes/images/visium_mouse_brain/DWLS_plot.png new file mode 100644 index 000000000..ba85e44c9 Binary files /dev/null and b/vignettes/images/visium_mouse_brain/DWLS_plot.png differ diff --git a/vignettes/images/visium_mouse_brain/spat_DWLS_pie_plot.png b/vignettes/images/visium_mouse_brain/spat_DWLS_pie_plot.png new file mode 100644 index 000000000..ed2b05630 Binary files /dev/null and b/vignettes/images/visium_mouse_brain/spat_DWLS_pie_plot.png differ diff --git a/vignettes/images/visium_mouse_brain/spat_enr_Rank_plot.png b/vignettes/images/visium_mouse_brain/spat_enr_Rank_plot.png new file mode 100644 index 000000000..3f5234e9b Binary files /dev/null and b/vignettes/images/visium_mouse_brain/spat_enr_Rank_plot.png differ diff --git a/vignettes/images/visium_mouse_kidney/0-spatPlot2D.png b/vignettes/images/visium_mouse_kidney/0-spatPlot2D.png new file mode 100644 index 000000000..0368b5dcc Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/0-spatPlot2D.png differ diff --git a/vignettes/images/visium_mouse_kidney/1-spatPlot2D.png b/vignettes/images/visium_mouse_kidney/1-spatPlot2D.png new file mode 100644 index 000000000..afbf04dba Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/1-spatPlot2D.png differ diff --git a/vignettes/images/visium_mouse_kidney/10-spatDimPlot2D.png b/vignettes/images/visium_mouse_kidney/10-spatDimPlot2D.png new file mode 100644 index 000000000..8047503bc Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/10-spatDimPlot2D.png differ diff --git a/vignettes/images/visium_mouse_kidney/11-violinPlot.png b/vignettes/images/visium_mouse_kidney/11-violinPlot.png new file mode 100644 index 000000000..0f7f24da6 Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/11-violinPlot.png differ diff --git a/vignettes/images/visium_mouse_kidney/11-z1-violinplot_gini.png b/vignettes/images/visium_mouse_kidney/11-z1-violinplot_gini.png new file mode 100644 index 000000000..1042be726 Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/11-z1-violinplot_gini.png differ diff --git a/vignettes/images/visium_mouse_kidney/12-plotMetaDataHeatmap.png b/vignettes/images/visium_mouse_kidney/12-plotMetaDataHeatmap.png new file mode 100644 index 000000000..5b545af1b Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/12-plotMetaDataHeatmap.png differ diff --git a/vignettes/images/visium_mouse_kidney/13-dimFeatPlot2D.png b/vignettes/images/visium_mouse_kidney/13-dimFeatPlot2D.png new file mode 100644 index 000000000..12fa03bd7 Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/13-dimFeatPlot2D.png differ diff --git a/vignettes/images/visium_mouse_kidney/14-violinPlot.png b/vignettes/images/visium_mouse_kidney/14-violinPlot.png new file mode 100644 index 000000000..b9691a4b4 Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/14-violinPlot.png differ diff --git a/vignettes/images/visium_mouse_kidney/15-plotMetaDataHeatmap.png b/vignettes/images/visium_mouse_kidney/15-plotMetaDataHeatmap.png new file mode 100644 index 000000000..aa15a4039 Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/15-plotMetaDataHeatmap.png differ diff --git a/vignettes/images/visium_mouse_kidney/16-dimFeatPlot2D.png b/vignettes/images/visium_mouse_kidney/16-dimFeatPlot2D.png new file mode 100644 index 000000000..ed1f65e69 Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/16-dimFeatPlot2D.png differ diff --git a/vignettes/images/visium_mouse_kidney/17-spatPlot2D.png b/vignettes/images/visium_mouse_kidney/17-spatPlot2D.png new file mode 100644 index 000000000..2399cd3f9 Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/17-spatPlot2D.png differ diff --git a/vignettes/images/visium_mouse_kidney/18-plotStatDelaunayNetwork.png b/vignettes/images/visium_mouse_kidney/18-plotStatDelaunayNetwork.png new file mode 100644 index 000000000..a487289b5 Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/18-plotStatDelaunayNetwork.png differ diff --git a/vignettes/images/visium_mouse_kidney/19-spatPlot2D.png b/vignettes/images/visium_mouse_kidney/19-spatPlot2D.png new file mode 100644 index 000000000..42b2c743f Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/19-spatPlot2D.png differ diff --git a/vignettes/images/visium_mouse_kidney/2-spatPlot2D.png b/vignettes/images/visium_mouse_kidney/2-spatPlot2D.png new file mode 100644 index 000000000..fc645fcb6 Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/2-spatPlot2D.png differ diff --git a/vignettes/images/visium_mouse_kidney/20-spatFeatPlot2D.png b/vignettes/images/visium_mouse_kidney/20-spatFeatPlot2D.png new file mode 100644 index 000000000..929aeafc6 Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/20-spatFeatPlot2D.png differ diff --git a/vignettes/images/visium_mouse_kidney/21-spatFeatPlot2D.png b/vignettes/images/visium_mouse_kidney/21-spatFeatPlot2D.png new file mode 100644 index 000000000..d0198a45d Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/21-spatFeatPlot2D.png differ diff --git a/vignettes/images/visium_mouse_kidney/22-spatFeatPlot2D.png b/vignettes/images/visium_mouse_kidney/22-spatFeatPlot2D.png new file mode 100644 index 000000000..71b6ac093 Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/22-spatFeatPlot2D.png differ diff --git a/vignettes/images/visium_mouse_kidney/22-z1-heatmap_correlated_genes.pdf b/vignettes/images/visium_mouse_kidney/22-z1-heatmap_correlated_genes.pdf new file mode 100644 index 000000000..12602fdf1 Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/22-z1-heatmap_correlated_genes.pdf differ diff --git a/vignettes/images/visium_mouse_kidney/22-z2-rank_correlated_groups.png b/vignettes/images/visium_mouse_kidney/22-z2-rank_correlated_groups.png new file mode 100644 index 000000000..c9545d1f3 Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/22-z2-rank_correlated_groups.png differ diff --git a/vignettes/images/visium_mouse_kidney/23-spatCellPlot2D.png b/vignettes/images/visium_mouse_kidney/23-spatCellPlot2D.png new file mode 100644 index 000000000..fcd174e15 Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/23-spatCellPlot2D.png differ diff --git a/vignettes/images/visium_mouse_kidney/24-spatPlot2D.png b/vignettes/images/visium_mouse_kidney/24-spatPlot2D.png new file mode 100644 index 000000000..85ffd3bdb Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/24-spatPlot2D.png differ diff --git a/vignettes/images/visium_mouse_kidney/25-spatPlot2D.png b/vignettes/images/visium_mouse_kidney/25-spatPlot2D.png new file mode 100644 index 000000000..0198eefcf Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/25-spatPlot2D.png differ diff --git a/vignettes/images/visium_mouse_kidney/3-HVFplot.png b/vignettes/images/visium_mouse_kidney/3-HVFplot.png new file mode 100644 index 000000000..cfff54b9b Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/3-HVFplot.png differ diff --git a/vignettes/images/visium_mouse_kidney/4-screePlot.png b/vignettes/images/visium_mouse_kidney/4-screePlot.png new file mode 100644 index 000000000..f964198da Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/4-screePlot.png differ diff --git a/vignettes/images/visium_mouse_kidney/5-PCA.png b/vignettes/images/visium_mouse_kidney/5-PCA.png new file mode 100644 index 000000000..37aacb7f5 Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/5-PCA.png differ diff --git a/vignettes/images/visium_mouse_kidney/6-UMAP.png b/vignettes/images/visium_mouse_kidney/6-UMAP.png new file mode 100644 index 000000000..d95cbf19a Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/6-UMAP.png differ diff --git a/vignettes/images/visium_mouse_kidney/7-tSNE.png b/vignettes/images/visium_mouse_kidney/7-tSNE.png new file mode 100644 index 000000000..25f44e6f5 Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/7-tSNE.png differ diff --git a/vignettes/images/visium_mouse_kidney/8-UMAP.png b/vignettes/images/visium_mouse_kidney/8-UMAP.png new file mode 100644 index 000000000..d850c4217 Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/8-UMAP.png differ diff --git a/vignettes/images/visium_mouse_kidney/9-spatDimPlot2D.png b/vignettes/images/visium_mouse_kidney/9-spatDimPlot2D.png new file mode 100644 index 000000000..e66b891e7 Binary files /dev/null and b/vignettes/images/visium_mouse_kidney/9-spatDimPlot2D.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-10-1.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-10-1.png new file mode 100644 index 000000000..847786139 Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-10-1.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-10-2.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-10-2.png new file mode 100644 index 000000000..847786139 Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-10-2.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-11-1.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-11-1.png new file mode 100644 index 000000000..fc6450d5a Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-11-1.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-11-2.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-11-2.png new file mode 100644 index 000000000..6f697e7ba Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-11-2.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-11-3.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-11-3.png new file mode 100644 index 000000000..6f697e7ba Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-11-3.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-12-1.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-12-1.png new file mode 100644 index 000000000..71e2ff68a Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-12-1.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-12-2.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-12-2.png new file mode 100644 index 000000000..d0920b910 Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-12-2.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-13-1.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-13-1.png new file mode 100644 index 000000000..eff0e3ceb Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-13-1.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-13-2.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-13-2.png new file mode 100644 index 000000000..eff0e3ceb Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-13-2.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-14-1.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-14-1.png new file mode 100644 index 000000000..4c7ec3caf Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-14-1.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-14-2.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-14-2.png new file mode 100644 index 000000000..716866e3d Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-14-2.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-15-1.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-15-1.png new file mode 100644 index 000000000..f76812842 Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-15-1.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-15-2.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-15-2.png new file mode 100644 index 000000000..faf89b10d Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-15-2.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-16-1.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-16-1.png new file mode 100644 index 000000000..a7ee53124 Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-16-1.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-16-2.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-16-2.png new file mode 100644 index 000000000..a7ee53124 Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-16-2.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-17-1.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-17-1.png new file mode 100644 index 000000000..fd6204a69 Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-17-1.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-17-2.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-17-2.png new file mode 100644 index 000000000..aa23431aa Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-17-2.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-18-1.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-18-1.png new file mode 100644 index 000000000..595f788cb Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-18-1.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-18-2.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-18-2.png new file mode 100644 index 000000000..595f788cb Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-18-2.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-18-3.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-18-3.png new file mode 100644 index 000000000..4bbd9ab1e Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-18-3.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-18-4.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-18-4.png new file mode 100644 index 000000000..4bbd9ab1e Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-18-4.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-21-1.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-21-1.png new file mode 100644 index 000000000..de15dd5d7 Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-21-1.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-21-2.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-21-2.png new file mode 100644 index 000000000..de15dd5d7 Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-21-2.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-22-1.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-22-1.png new file mode 100644 index 000000000..298097804 Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-22-1.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-22-2.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-22-2.png new file mode 100644 index 000000000..298097804 Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-22-2.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-23-1.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-23-1.png new file mode 100644 index 000000000..9aaeab7c4 Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-23-1.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-23-2.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-23-2.png new file mode 100644 index 000000000..9aaeab7c4 Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-23-2.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-24-1.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-24-1.png new file mode 100644 index 000000000..0430a7435 Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-24-1.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-24-2.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-24-2.png new file mode 100644 index 000000000..0430a7435 Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-24-2.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-5-1.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-5-1.png new file mode 100644 index 000000000..fe0a68bb4 Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-5-1.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-5-2.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-5-2.png new file mode 100644 index 000000000..fe0a68bb4 Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-5-2.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-6-1.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-6-1.png new file mode 100644 index 000000000..6ba6d6e63 Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-6-1.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-6-2.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-6-2.png new file mode 100644 index 000000000..6ba6d6e63 Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-6-2.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-7-1.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-7-1.png new file mode 100644 index 000000000..5187b93fd Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-7-1.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-7-2.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-7-2.png new file mode 100644 index 000000000..5187b93fd Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-7-2.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-9-1.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-9-1.png new file mode 100644 index 000000000..4a23dc0f0 Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-9-1.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-9-2.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-9-2.png new file mode 100644 index 000000000..4a23dc0f0 Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-9-2.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-9-3.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-9-3.png new file mode 100644 index 000000000..7bd638e7f Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-9-3.png differ diff --git a/vignettes/images/visium_prostate_integration/unnamed-chunk-9-4.png b/vignettes/images/visium_prostate_integration/unnamed-chunk-9-4.png new file mode 100644 index 000000000..7bd638e7f Binary files /dev/null and b/vignettes/images/visium_prostate_integration/unnamed-chunk-9-4.png differ diff --git a/vignettes/seqscope_mouse_liver.rmd b/vignettes/seqscope_mouse_liver.rmd new file mode 100644 index 000000000..520661ec0 --- /dev/null +++ b/vignettes/seqscope_mouse_liver.rmd @@ -0,0 +1,367 @@ +--- +title: "Seq-Scope Mouse liver" +date: 2022-11-15 +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Seq-Scope Mouse liver} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +# Dataset explanation + +[Seqscope](https://pubmed.ncbi.nlm.nih.gov/34115981/) is a illumina sequencing based spatial sequencing platform developed by [Jun Hee Lee Lab](https://lee.lab.medicine.umich.edu/seq-scope). The basic strategy is to use illumina sequencing by synthesis to generate the spatial barcodes and use the barcodes to capture mRNAs in tissue. + +## Example Raw Data needed for seqscope: + +1st-seq data (single-ended, for generating spatial barcodes) + +- SeqScope_1st.fastq.gz 2nd-seq data (pair-ended, for generating count matrix) +- SeqScope_2nd_R1.fastq.gz +- SeqScope_2nd_R2.fastq.gz + +Image (for seqmentation) + +- Tile_No_Segmented.png + +## Preprocessing to generate count matrix + +Seqscope has its own pipeline to generate the count matrix(Gene barcode). Please refer to their [github page](https://github.com/leeju-umich/Cho_Xi_Seqscope) or use customized methods to proceed. + + +```{r, eval=FALSE} +# Note you need to install seqtk, STARsolo and clone their github page first. All bash scripts are stored in script directory of their github. + +## First generate the whitelist of spatial barcodes: +bash extractCoord.sh [SeqScope_1st.fastq.gz] [SeqScope_2nd_R1.fastq.gz] [HDMI_length] +## Second, generating the count matrix via STAR.Solo: +bash align.sh [SeqScope_2nd_R1.fastq.gz] [abc_SeqScope_2nd_R2.fastq.gz] [HDMI_length] [whitelists.txt] [outprefix] [starpath] [seqtkpath] [geneIndex] +``` + + +You should now have the count matrix for Giotto Object. Note the Spatial Barcodes are typically at 0.6 um resolution. One way to analyze is to use the getSimpleGrid.R or getSlidingGrid.R provided by Lee Lab to bin the counts and simply follow the Giotto analysis steps of [Visium](https://giottosuite.readthedocs.io/en/latest/subsections/datasets/ouse_visium_brain.html) and [Integration of Visium](https://giottosuite.readthedocs.io/en/latest/subsections/datasets/visium_prostate_integration.html) + +# Start Giotto + + +```{r, eval=FALSE} +# Ensure Giotto Suite is installed. +if(!"Giotto" %in% installed.packages()) { + devtools::install_github("drieslab/Giotto@suite") +} + +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 + + +```{r, eval=FALSE} +# 1. set working directory +results_folder = 'path/to/result' + +# 2. set giotto python path +# set python path to your preferred python version path +# set python path to conda env/bin/ directory if manually installed Giotto python dependencies by conda +# python_path = '/path_to_conda/.conda/envs/giotto/bin/python' +# set python path to NULL if you want to automatically install (only the 1st time) and use the giotto miniconda environment +# python_path = NULL +#if(is.null(python_path)) { +# installGiottoEnvironment() +#} + +# 3. create giotto instructions +instrs = createGiottoInstructions(save_dir = results_folder, + save_plot = TRUE, + show_plot = FALSE) +``` + + +# 1. Create Giotto Subcellular Object + +In order to do single cell and subcellular analysis with Giotto, we suggest using the GiottoSubcellular Object. Giotto Subcellular objects take cell polygons and a Giotto Point file (a data.table contains Gene Name, Expression, x, y, etc). Therefore, first we need to do some transformation of the count matrix. + + +**Giotto Point file formatting** + +Unlike normal cell by gene matrix, a Giotto Point file is usually a data.table contains Gene Name, Expression, x, y, where each row represent a subcellular point. For Seqscope data, one HDMI typically have more than one subcellular point. + +Example Giotto Point file for **Seqscope** + + + HDMI Feat_ID Count sdimX sdimY + ------- --------- ------- ------- ------- + HDMI1 GeneA + HDMI1 GeneB + HDMI2 GeneA + HDMI3 GeneC + + + +## 1.1 Process Giotto Point file per tile + + +```{r, eval=FALSE} +##expression matrix +countDir = "/path/to/Solo.out/GeneFull/raw" +expr_matrix = Giotto::get10Xmatrix(path_to_data = countDir, gene_column_index = 2) + +##Spatial coordinates +spatial_coords_Dir = "/path/to/extractCoord.sh/results/spatialcoordinates.txt" +spatial_coords = fread("spatial_coords_Dir") +colnames(spatial_coords)<-c("HDMI","Lane","Tile","X","Y") + +##Prepare Giotto Point +# Subset expression and spatial info by tile +spatial_coords_tile = spatial_coords[Tile == '2104'] +expr_matrix_tile = expr_matrix[, as.character(colnames(expr_matrix)) %in% spatial_coords_tile$HDMI] + +# convert expression matrix to minimal data.table object +matrix_tile_dt = as.data.table(Matrix::summary(expr_matrix_tile)) +genes = expr_matrix_tile@Dimnames[[1]] +samples = expr_matrix_tile@Dimnames[[2]] +matrix_tile_dt[, gene := genes[i]] +matrix_tile_dt[, hdmi := samples[j]] + +# merge data.table matrix and spatial coordinates to create input for Giotto Polygons +gpoints = merge.data.table(matrix_tile_dt, spatial_coords_tile, by.x = 'hdmi', by.y = 'HDMI') +gpoints = gpoints[,.(hdmi, X, Y, gene, x)] +colnames(gpoints) = c('hdmi', 'x', 'y', 'gene', 'counts') +``` + + +## 1.2 Prepare the polygon mask file + +Giotto can read in a variety of different mask files provided by common segmentation tools. But first we need to check if we need to filp the x and y axis. + + +```{r, eval=FALSE} +# check total counts per hdmi +gpoints_aggr = gpoints[, sum(counts), by = .(hdmi, x, y)] +colnames(gpoints_aggr) = c("hdmi","x","y","total_counts") +setorder(gpoints_aggr, -total_counts) + +pl = ggplot() +pl = pl + geom_point(data = gpoints_aggr[total_counts < 1000 & total_counts > 8], aes(x = x, y = y, color = total_counts), size = 0.05) +pl = pl + scale_color_gradient2(midpoint = 15, low = 'blue', mid = 'yellow', high = 'red') +pl +``` + + +![](images/seqscope_mouse_liver/HDMI_scatter.png) + +Read polygon mask file + + +```{r, eval=FALSE} +segmentation_mask = "/path/to/segmentation.tif" +final_polygons = createGiottoPolygonsFromMask(segmentation_mask, + flip_vertical = FALSE, + flip_horizontal = FALSE) +plot(final_polygons) +``` + + +![](images/seqscope_mouse_liver/polygon.png) + + +**Polygon mask file manual formatting** + +However, sometimes Giotto does not read in the provided mask file and we will need a manual processing for the mask file and we will do that using terra and createGiottoPolygonsFromDfr. + + +```{r, eval=FALSE} +raster = terra::rast(x = segmentation_mask) +terra_polygon = terra::as.polygons(x = raster, value = T) + +# convert polygon to data.table and remove unwantedly detected polygons (e.g. canvas etc) +dt = GiottospatVector_to_dt(terra_polygon) +npolygons = length(levels(factor(dt$part))) - 1 +filter_dt = dt[geom == 1 & hole == 0 & part %in% c(0:npolygons), .(x,y,part)] +filter_dt[, part := as.factor(part)] + +# create new polygons from filtered data.table +final_polygons = createGiottoPolygonsFromDfr(segmdfr = filter_dt) + +# create giotto points first to get the extent of the points (hdmi) +original_points = createGiottoPoints(x = gpoints[,.(x, y, gene, hdmi, counts)]) +original_feat_ext = ext(original_points@spatVector) + + + +# convert polygon to spatRaster to change extent to that of original points +final_spatraster = Giottopolygon_to_raster(polygon = final_polygons@spatVector) +ext(final_spatraster$raster) = original_feat_ext +final_polygons@spatVector = as.polygons(final_spatraster$raster) +final_polygons@spatVector$poly_ID = final_spatraster$ID_vector[final_polygons@spatVector$poly_i] + +# flip and shift, if needed +#final_polygons@spatVector = flip(final_polygons@spatVector) +#yshift = ymin(original_feat_ext) - ymax(original_feat_ext) +#final_polygons@spatVector = terra::shift(final_polygons@spatVector, dy = -yshift) + +plot(final_polygons) +``` + + +## 1.3 Create Giotto Object + +Add a random jitter to the HDMI location to make a pseudo-in situ transcript file. + + +```{r, eval=FALSE} +# add giotto points class +gpoints_subset = gpoints[hdmi %in% gpoints_aggr[total_counts > 5]$hdmi] + +# multiply rows with multiple counts and add jitter +gpoints_extra = gpoints_subset[counts > 1] +gpoints_extra = gpoints_extra[,rep(counts, counts), by = .(hdmi, gene, x, y)] +gpoints_extra = rbind(gpoints_extra[,.(hdmi, gene, x, y)], gpoints_subset[counts == 1 ,.(hdmi, gene, x, y)]) +jitter_x = sample(1:3, size = nrow(gpoints_extra), replace = T) +jitter_y = sample(1:3, size = nrow(gpoints_extra), replace = T) +gpoints_extra[, x := x + jitter_x] +gpoints_extra[, y := y + jitter_y] +``` + + +```{r, eval=FALSE} +# add subcellular information +seqscope = createGiottoObjectSubcellular(gpoints = list(gpoints_extra[,.(x, y, gene, hdmi)]), + gpolygons = list(final_polygons), + instructions = instrs) + +# add centroids +seqscope = addSpatialCentroidLocations(seqscope, + poly_info = 'cell') + +#Overlap to Polygon information +seqscope = calculateOverlapRaster(seqscope) +seqscope = overlapToMatrix(seqscope) + +# Visualize top 200 expressed genes in situ +spatInSituPlotPoints(seqscope, show_legend = F, + show_image = FALSE, + feats = list('rna' = seqscope@feat_info$rna@spatVector$feat_ID[1:200]), + spat_unit = 'cell', + point_size = 1, + show_polygon = TRUE, + use_overlap = F, + polygon_feat_type = 'cell', + polygon_color = 'red', + polygon_bg_color = 'white', + polygon_line_size = 0.2, + coord_fix_ratio = TRUE, + background_color = 'white') +``` + + +![](images/seqscope_mouse_liver/top200.png) + +# 2. Process Giotto and Quality Control + +```{r, eval=FALSE} +# filter +seqscope <- filterGiotto(gobject = seqscope, + expression_threshold = 1, + feat_det_in_min_cells = 5, + min_det_feats_per_cell = 5) + +#normalize +seqscope <- normalizeGiotto(gobject = seqscope, scalefactor = 5000, verbose = T) +# add statistics +seqscope <- addStatistics(gobject = seqscope) + +# View cellular data +# pDataDT(seqscope) +# View rna data +# fDataDT(seqscope) + + +spatPlot2D(gobject = seqscope, + cell_color = 'total_expr', color_as_factor = F, + show_image = F, + point_size = 2.5, point_alpha = 0.75, coord_fix_ratio = T) +``` + + +![](images/seqscope_mouse_liver/total_expr.png) + + +```{r, eval=FALSE} +cellmeta = pDataDT(seqscope, feat_type = 'rna') +hist(cellmeta$nr_feats, 100) +``` + + +![](images/seqscope_mouse_liver/feature_distribution.png) + +# 3. Dimention Reduction + + +```{r, eval=FALSE} +# cluster cells +seqscope <- calculateHVF(gobject = seqscope, HVFname = 'hvg_orig') + +seqscope <- runPCA(gobject = seqscope, + expression_values = 'normalized', + scale_unit = T, center = T) + +seqscope <- runUMAP(seqscope, dimensions_to_use = 1:100) +``` + + +# 4. Cluster + + +```{r, eval=FALSE} +seqscope <- createNearestNetwork(gobject = seqscope, dimensions_to_use = 1:100, k = 5) +seqscope <- doLeidenCluster(gobject = seqscope, resolution = 0.9, n_iterations = 1000) + +# visualize UMAP cluster results + + +plotUMAP(gobject = seqscope, cell_color = 'leiden_clus', + show_NN_network = F, point_size = 3.5) +``` + + +![](images/seqscope_mouse_liver/leiden_umap.png) + + +```{r, eval=FALSE} +spatInSituPlotPoints(seqscope, + show_polygon = TRUE, + polygon_color = 'white', + polygon_line_size = 0.1, + polygon_fill = 'leiden_clus', + polygon_fill_as_factor = T, + coord_fix_ratio = T) +``` + + +![](images/seqscope_mouse_liver/leiden_spat.png) + +# 5. Find spatial genes + + +```{r, eval=FALSE} +seqscope<-createSpatialNetwork(gobject = seqscope, minimum_k = 2, maximum_distance_delaunay = 100) + +km_spatialgenes = binSpect(seqscope, subset_feats = seqscope@feat_ID$rna) +spatFeatPlot2D(seqscope, expression_values = 'scaled', + feats = km_spatialgenes$feats[1:2], + cell_color_gradient = c('blue', 'white', 'red'), + point_shape = 'border', point_border_stroke = 0.01, + show_network = T, network_color = 'lightgrey', point_size = 1.2, + cow_n_col = 1) +``` + + +![](images/seqscope_mouse_liver/spatgenes.png) diff --git a/vignettes/singlecell_prostate_integration.Rmd b/vignettes/singlecell_prostate_integration.Rmd new file mode 100644 index 000000000..c2cbc2eb7 --- /dev/null +++ b/vignettes/singlecell_prostate_integration.Rmd @@ -0,0 +1,235 @@ +--- +title: "Integration of single cell datasets" +date: 2022-09-16 +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Integration of single cell datasets} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +``` {r, eval=FALSE} +# Ensure Giotto Suite is installed. +if(!"Giotto" %in% installed.packages()) { + devtools::install_github("drieslab/Giotto@suite") +} + +# Ensure GiottoData, a small, helper module for tutorials, is installed. +if(!"GiottoData" %in% installed.packages()) { + devtools::install_github("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 + + +``` {r, eval=FALSE} +library(Giotto) +library(GiottoData) + +# 1. set working directory +results_folder = 'path/to/result' + +# 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. +my_python_path = NULL # alternatively, "/local/python/path/python" if desired. + +# 2. create giotto instructions +instrs = createGiottoInstructions(save_dir = results_folder, + save_plot = TRUE, + show_plot = FALSE, + python_path = my_python_path) +``` + + +# Dataset explanation + +This is a tutorial for Harmony integration of different single cell +RNAseq datasets using two prostate cancer patient datasets. [Ma et +al.](https:/pubmed.ncbi.nlm.nih.gov/33032611/) Processed 10X Single +Cell RNAseq from two prostate cancer patients. The raw dataset can be +found +[here](https:/www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE157703) + +# Part 1: Create Giotto object from 10X dataset and join + + +``` {r, eval=FALSE} +giotto_P1<-createGiottoObject(expression = get10Xmatrix("path/to/P1_result/outs/filtered_feature_bc_matrix", + gene_column_index = 2, + remove_zero_rows = TRUE), + instructions = instrs) + +giotto_P2<-createGiottoObject(expression = get10Xmatrix("path/to/P2_result/outs/filtered_feature_bc_matrix", + gene_column_index = 2, + remove_zero_rows = TRUE), + instructions = instrs) + +giotto_SC_join = joinGiottoObjects(gobject_list = list(giotto_P1, giotto_P2), + gobject_names = c('P1', 'P2'), + join_method = "z_stack") +``` + + +# Part 2: Process Joined object + + +``` {r, eval=FALSE} +giotto_SC_join <- filterGiotto(gobject = giotto_SC_join, + expression_threshold = 1, + feat_det_in_min_cells = 50, + min_det_feats_per_cell = 500, + expression_values = c('raw'), + verbose = T) + +## normalize +giotto_SC_join <- normalizeGiotto(gobject = giotto_SC_join, + scalefactor = 6000) + +## add gene & cell statistics +giotto_SC_join <- addStatistics(gobject = giotto_SC_join, + expression_values = 'raw') +``` + + +# Part 3: Dimension reduction and clustering + + +``` {r, eval=FALSE} +## PCA ## +giotto_SC_join <- calculateHVF(gobject = giotto_SC_join) +giotto_SC_join <- runPCA(gobject = giotto_SC_join, + center = TRUE, + scale_unit = TRUE) +# Check screeplot to select number of PCs for clustering +# screePlot(giotto_SC_join, ncp = 30, save_param = list(save_name = '3_scree_plot')) + +## WITHOUT INTEGRATION ## +# --------------------- # + +## cluster and run UMAP ## +# sNN network (default) +showGiottoDimRed(giotto_SC_join) +giotto_SC_join <- createNearestNetwork(gobject = giotto_SC_join, + dim_reduction_to_use = 'pca', + dim_reduction_name = 'pca', + dimensions_to_use = 1:10, + k = 15) + +# Leiden clustering +giotto_SC_join <- doLeidenCluster(gobject = giotto_SC_join, + resolution = 0.2, + n_iterations = 1000) + +# UMAP +giotto_SC_join = runUMAP(giotto_SC_join) + +plotUMAP(gobject = giotto_SC_join, + cell_color = 'leiden_clus', + show_NN_network = T, + point_size = 1.5, + save_param = list(save_name = "4_cluster_without_integration")) +``` + + +![](images/singlecell_prostate_integration/4_cluster_without_integration.png){width="50.0%"} + + +``` {r, eval=FALSE} +dimPlot2D(gobject = giotto_SC_join, + dim_reduction_name = 'umap', + point_shape = 'no_border', + cell_color = "leiden_clus", + group_by = "list_ID", + show_NN_network = F, + point_size = 0.5, + show_center_label = F, + show_legend =F, + save_param = list(save_name = "4_list_without_integration")) +``` + + +![](images/singlecell_prostate_integration/4_list_without_integration.png){width="50.0%"} + +Harmony is a integration algorithm developed by [Korsunsky, I. et +al.](https:/www.nature.com/articles/s41592-019-0619-0). It was designed +for integration of single cell data but also work well on spatial +datasets. + + +``` {r, eval=FALSE} +## WITH INTEGRATION ## +# --------------------- # + +## data integration, cluster and run UMAP ## + +# harmony +#library(devtools) +#install_github("immunogenomics/harmony") +library(harmony) + +#pDataDT(giotto_SC_join) +giotto_SC_join = runGiottoHarmony(giotto_SC_join, + vars_use = 'list_ID', + do_pca = F) + + +## sNN network (default) +#showGiottoDimRed(giotto_SC_join) +giotto_SC_join <- createNearestNetwork(gobject = giotto_SC_join, + dim_reduction_to_use = 'harmony', + dim_reduction_name = 'harmony', + name = 'NN.harmony', + dimensions_to_use = 1:10, + k = 15) + +## Leiden clustering +giotto_SC_join <- doLeidenCluster(gobject = giotto_SC_join, + network_name = 'NN.harmony', + resolution = 0.2, + n_iterations = 1000, + name = 'leiden_harmony') + +# UMAP dimension reduction +#showGiottoDimRed(giotto_SC_join) +giotto_SC_join = runUMAP(giotto_SC_join, + dim_reduction_name = 'harmony', + dim_reduction_to_use = 'harmony', + name = 'umap_harmony') + +plotUMAP(gobject = giotto_SC_join, + dim_reduction_name = 'umap_harmony', + cell_color = 'leiden_harmony', + show_NN_network = T, + point_size = 1.5, + save_param = list(save_name = "4_cluster_with_integration")) +``` + + +![](images/singlecell_prostate_integration/4_cluster_with_integration.png){width="50.0%"} + + +``` {r, eval=FALSE} +dimPlot2D(gobject = giotto_SC_join, + dim_reduction_name = 'umap_harmony', + point_shape = 'no_border', + cell_color = "leiden_harmony", + group_by = "list_ID", + show_NN_network = F, + point_size = 0.5, + show_center_label = F, + show_legend =F , + save_param = list(save_name = "4_list_with_integration")) +``` + + +![](images/singlecell_prostate_integration/4_list_with_integration.png){width="50.0%"} diff --git a/vignettes/singlecell_prostate_standard.Rmd b/vignettes/singlecell_prostate_standard.Rmd new file mode 100644 index 000000000..f95a4a5f6 --- /dev/null +++ b/vignettes/singlecell_prostate_standard.Rmd @@ -0,0 +1,256 @@ +--- +title: "10X Single Cell RNA Sequencing" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{10X Single Cell RNA Sequencing} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + + +```{r, eval=FALSE} +# Ensure Giotto Suite is installed. +if(!"Giotto" %in% installed.packages()) { + devtools::install_github("drieslab/Giotto@suite") +} + +# Ensure GiottoData, a small, helper module for tutorials, is installed. +if(!"GiottoData" %in% installed.packages()) { + devtools::install_github("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 + +``` {r, eval=FALSE} +library(Giotto) +library(GiottoData) + +# 1. set working directory +results_folder = 'path/to/result' + +# 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. +my_python_path = NULL # alternatively, "/local/python/path/python" if desired. + +# 3. create giotto instructions +instrs = createGiottoInstructions(save_dir = results_folder, + save_plot = TRUE, + show_plot = FALSE, + python_path = my_python_path) +``` + +## Dataset Explanation + +[Ma et al.](https://pubmed.ncbi.nlm.nih.gov/33032611/) Processed 10X Single Cell RNAseq from two prostate cancer patients. The raw dataset can be found +[here](https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE157703) + +## Part 1: Create Giotto object from 10X dataset + +Note that you will need an input directory for barcodes.tsv(.gz) features.tsv(.gz) matrix.mtx(.gz) + +``` {r, eval=FALSE} +giotto_SC <- createGiottoObject(expression = get10Xmatrix("/path/to/filtered_feature_bc_matrix", + gene_column_index = 2, + remove_zero_rows = TRUE), + instructions = instrs) +``` + +## Part 2: Process Giotto Object + +``` {r, eval=FALSE} +giotto_SC <- filterGiotto(gobject = giotto_SC, + expression_threshold = 1, + feat_det_in_min_cells = 50, + min_det_feats_per_cell = 500, + expression_values = c('raw'), + verbose = T) + +## normalize +giotto_SC <- normalizeGiotto(gobject = giotto_SC, scalefactor = 6000) + +## add mitochondria gene percentage and filter giotto object by percent mito +library(rtracklayer) +gtf <- import("Homo_sapiens.GRCh38.105.gtf.gz") +gtf <- gtf[gtf$gene_name!="" & !is.na(gtf$gene_name)] +mito <- gtf$gene_name[as.character(seqnames(gtf)) %in% "MT"] +mito <- unique(mito) + +giotto_SC <- addFeatsPerc(giotto_SC, + feats = mito, + vector_name = 'perc_mito') + +giotto_SC <- subsetGiotto(giotto_SC, + cell_ids = pDataDT(giotto_SC)[which(pDataDT(giotto_SC)$perc_mito < 15),]$cell_ID) + + +## add gene & cell statistics +giotto_SC <- addStatistics(gobject = giotto_SC, expression_values = 'raw') +``` + +## Part 3: Dimention Reduction + +``` {r, eval=FALSE} +## PCA ## +giotto_SC <- calculateHVF(gobject = giotto_SC) +giotto_SC <- runPCA(gobject = giotto_SC, center = TRUE, scale_unit = TRUE) +screePlot(giotto_SC, ncp = 30, save_param = list(save_name = '3_scree_plot')) +``` + +![](images/singlecell_rna_seq/3_scree_plot.png) + +## Part 4: Cluster + +``` {r, eval=FALSE} +## cluster and run UMAP ## +# sNN network (default) +showGiottoDimRed(giotto_SC) +giotto_SC <- createNearestNetwork(gobject = giotto_SC, + dim_reduction_to_use = 'pca', dim_reduction_name = 'pca', + dimensions_to_use = 1:10, k = 15) + +# UMAP +giotto_SC = runUMAP(giotto_SC, dimensions_to_use = 1:10) + +# Leiden clustering +giotto_SC <- doLeidenCluster(gobject = giotto_SC, resolution = 0.2, n_iterations = 1000) + + +plotUMAP(gobject = giotto_SC, + cell_color = 'leiden_clus', show_NN_network = T, point_size = 1.5, + save_param = list(save_name = "4_Cluster")) +``` + +![](images/singlecell_rna_seq/4_Cluster.png) + +## Part 5: Differential Expression + +``` {r, eval=FALSE} +markers_scran = findMarkers_one_vs_all(gobject=giotto_SC, method="scran", + expression_values="normalized", cluster_column='leiden_clus', min_feats=3) +markergenes_scran = unique(markers_scran[, head(.SD, 3), by="cluster"][["feats"]]) + +plotMetaDataHeatmap(giotto_SC, expression_values = "normalized", metadata_cols = 'leiden_clus', + selected_feats = markergenes_scran, + y_text_size = 8, show_values = 'zscores_rescaled', + save_param = list(save_name = '5_a_metaheatmap')) +``` + +![](images/singlecell_rna_seq/5_a_metaheatmap.png) + +``` {r, eval=FALSE} +topgenes_scran = markers_scran[, head(.SD, 1), by = 'cluster']$feats +# violinplot +violinPlot(giotto_SC, feats = unique(topgenes_scran), cluster_column = 'leiden_clus', + strip_text = 10, strip_position = 'right', + save_param = list(save_name = '5_b_violinplot_scran', base_width = 5)) +``` + +![](images/singlecell_rna_seq/5_b_violinplot_scran.png) + +## Part 6: FeaturePlot + +``` {r, eval=FALSE} +# Plot known marker genes across different cell types. EPCAM for epithelial cells, +# DPP4(CD26) for Epithelial luminal cells, PECAM1(CD31) for Endothelial cells and CD3D for T cells +dimFeatPlot2D(giotto_SC, feats = c("EPCAM","DPP4","PECAM1","CD3D"), cow_n_col = 2, save_param = list(save_name = "6_featureplot")) +``` + +![](images/singlecell_rna_seq/6_featureplot.png) + +## Part 7: Cell type Annotation + +``` {r, eval=FALSE} +prostate_labels<-c("Endothelial cells",#1 + "T cells",#2 + "Epithelial_basal",#3 + "Epithelial_luminal",#4 + "Fibroblasts",#5 + "T cells",#6 + "Epithelial_luminal",#7 + "Smooth muscle cells",#8 + "Macrophage & B cells",#9 + "Fibroblasts",#10 + "Mast cells",#11 + "Mesenchymal cells",#12 + "Neural Progenitor cells")#13 +names(prostate_labels)<-1:13 +giotto_SC<-annotateGiotto(gobject = giotto_SC, annotation_vector = prostate_labels , + cluster_column = 'leiden_clus', name = 'prostate_labels') +dimPlot2D(gobject = giotto_SC, dim_reduction_name = 'umap', + cell_color = "prostate_labels", show_NN_network = T, point_size = 1.5, + save_param = list(save_name = "7_Annotation")) +``` + +![](images/singlecell_rna_seq/7_Annotation.png) + +## Part 8: Subset and Recluster + +``` {r, eval=FALSE} +Subset_giotto_T<-subsetGiotto(giotto_SC, + cell_ids = pDataDT(giotto_SC)[which(pDataDT(giotto_SC)$prostate_labels == "T cells"),]$cell_ID) +## PCA + +Subset_giotto_T <- calculateHVF(gobject = Subset_giotto_T) +Subset_giotto_T <- runPCA(gobject = Subset_giotto_T, center = TRUE, scale_unit = TRUE) +screePlot(Subset_giotto_T, ncp = 20, save_param = list(save_name = '8a_scree_plot')) +``` + +![](images/singlecell_rna_seq/8a_scree_plot.png) + +``` {r, eval=FALSE} +Subset_giotto_T <- createNearestNetwork(gobject = Subset_giotto_T, + dim_reduction_to_use = 'pca', dim_reduction_name = 'pca', + dimensions_to_use = 1:20, k = 10) + +# UMAP +Subset_giotto_T = runUMAP(Subset_giotto_T, dimensions_to_use = 1:8) + +# Leiden clustering +Subset_giotto_T <- doLeidenCluster(gobject = Subset_giotto_T, resolution = 0.1, n_iterations = 1000) + + +plotUMAP(gobject = Subset_giotto_T, + cell_color = 'leiden_clus', show_NN_network = T, point_size = 1.5, + save_param = list(save_name = "8b_Cluster")) +``` + +![](images/singlecell_rna_seq/8b_Cluster.png) + +``` {r, eval=FALSE} +markers_scran_T = findMarkers_one_vs_all(gobject=Subset_giotto_T, method="scran", + expression_values="normalized", cluster_column='leiden_clus', min_feats=3) +markergenes_scran_T = unique(markers_scran_T[, head(.SD, 5), by="cluster"][["feats"]]) + +plotMetaDataHeatmap(Subset_giotto_T, expression_values = "normalized", metadata_cols = 'leiden_clus', + selected_feats = markergenes_scran_T, + y_text_size = 8, show_values = 'zscores_rescaled', + save_param = list(save_name = '8_c_metaheatmap')) +``` + +![](images/singlecell_rna_seq/8_c_metaheatmap.png) + +``` {r, eval=FALSE} +T_labels<-c("Naive T cells",#1 + "Tfh cells",#2 + "CD8 T cells",#3 + "NK T cells",#4 + "CD4 T cells")#5 +names(T_labels)<-1:5 +Subset_giotto_T<-annotateGiotto(gobject = Subset_giotto_T, annotation_vector = T_labels , + cluster_column = 'leiden_clus', name = 'subset_labels') +dimPlot2D(gobject = Subset_giotto_T, dim_reduction_name = 'umap', + cell_color = "subset_labels", show_NN_network = T, point_size = 1.5, + save_param = list(save_name = "8d_Annotation")) +``` + +![](images/singlecell_rna_seq/8d_Annotation.png) diff --git a/vignettes/stereoseq_mosta.Rmd b/vignettes/stereoseq_mosta.Rmd new file mode 100644 index 000000000..478f8f9cd --- /dev/null +++ b/vignettes/stereoseq_mosta.Rmd @@ -0,0 +1,307 @@ +--- +title: "Stereo-Seq MOSTA E12.5_E1S3" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Stereo-Seq MOSTA E12.5_E1S3} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +# Dataset explanation + +Stereo-seq is a sequencing-based spatial transcriptomics technology that was developed and used by [Chen et al. in 2022](https://doi.org/10.1016/j.cell.2022.04.003) to generate the Mouse Organogenesis Spatiotemporal Transcriptomic Atlas (MOSTA). This tutorial demonstrates how to interactively filter and analyze the third sagittal section of a mouse embryo at embryonic day 12.5 ("E12.5_E1S3") from MOSTA. + +# Pre-processing + +The necessary input files for sample E12.5_E1S3 are publicly available and were downloaded from the following original sources: + +1. FASTQ files () +2. barcodeToPos.h5 file () + +The STOMICS Analysis Workflow [SAW pipeline](https://github.com/BGIResearch/SAW) was used to process these files. The output of the SAW pipeline is an .h5ad file at a specific bin size. One bin of size n represents an n x n square of aggregated spatial barcodes. In this tutorial, a sample with a bin size of 200 was used. + +# Start Giotto + + +```{r, eval=FALSE} +# Ensure Giotto Suite is installed +if(!"Giotto" %in% installed.packages()) { + devtools::install_github("drieslab/Giotto@suite") +} + +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() +} +``` + +# 1. Create a Giotto object + +```{r, eval=FALSE} +# download E12.5_E1S3_bin200.h5ad output from SAW pipeline (509.4 MB) +# alternatively, specify path to *.h5ad output of SAW pipeline +anndata_download = "https://zenodo.org/record/7323947/files/E12.5_E1S3_bin200.h5ad?download=1" +anndata_file = "E12.5_E1S3_bin_200.h5ad" +download.file(anndata_download, anndata_file) + +# convert anndata file to giotto object +stereo_go <- Giotto::anndataToGiotto(anndata_file) + +# alternatively, specify path to *.gef output of SAW pipeline (requires Giotto v3.2.0 or higher) +# gef_file = "E12.5_E1S3.gef" +# stereo_go <- Giotto::gefToGiotto(gef_file, bin_size = "bin200") +``` + +# 2. Process Giotto object + +```{r, eval=FALSE} +# filter number of genes +# important to discard bins (aggregated barcodes) outside of embryo +stereo_go <- stereo_go %>% filterGiotto(expression_threshold = 1, + feat_det_in_min_cells = 5, + min_det_feats_per_cell = 750) +# normalize +stereo_go <- stereo_go %>% normalizeGiotto(scalefactor = 5000, verbose = T) + +# add statistics +stereo_go <- stereo_go %>% addStatistics() + +# make plot +# each dot here represents a 200x200 aggregation of spatial barcodes (bin size 200) +spatPlot2D(gobject = stereo_go, cell_color = "nr_feats", color_as_factor = F, point_size = 1.5, show_plot = T, save_plot = F) +``` + +![](images/stereoseq_mosta/1.png) + +# 3. Dimension reduction + +- Identify highly variable features (HVF) + +```{r, eval=FALSE} +stereo_go <- stereo_go %>% calculateHVF(zscore_threshold = 1, show_plot = F) +``` + +- Perform PCA +- Identify the number of significant principal components (PCs) + +```{r, eval=FALSE} +stereo_go <- stereo_go %>% runPCA(expression_values = 'scaled', feats_to_use = 'hvf') +screePlot(stereo_go, ncp = 30) +plotPCA(stereo_go) +``` + + +![](images/stereoseq_mosta/2.png) + +![](images/stereoseq_mosta/3.png) + +- Run UMAP and TSNE on PCs (or directly on matrix) + +```{r, eval=FALSE} +stereo_go <- stereo_go %>% runUMAP(dimensions_to_use = 1:30, n_threads = 4) + +# plot UMAP, coloring cells/points based on nr_feats +plotUMAP(gobject = stereo_go, + cell_color = 'nr_feats', color_as_factor = F, point_size = 2) +``` + +![](images/stereoseq_mosta/4.png) + +```{r, eval=FALSE} +stereo_go = stereo_go %>% runtSNE(dimensions_to_use = 1:30) +plotTSNE(gobject = stereo_go) +``` + +![](images/stereoseq_mosta/5.png) + +# 4. Clustering + +- Create a shared (default) nearest network in PCA space (or directly on matrix) +- Cluster on nearest network with Leiden or Louvan (kmeans and hclust are alternatives) + +```{r, eval=FALSE} +# sNN network (default) +stereo_go <- stereo_go %>% createNearestNetwork(dimensions_to_use = 1:30, k = 12) + +# leiden clustering +stereo_go <- stereo_go %>% doLeidenCluster(resolution = 1, n_iterations = 1000) + +plotUMAP(gobject = stereo_go, cell_color = 'leiden_clus', point_size = 2.5, + show_NN_network = F, edge_alpha = 0.05) + +# merge small groups based on similarity +leiden_similarities = stereo_go %>% getClusterSimilarity(expression_values = 'scaled', + cluster_column = 'leiden_clus') + +stereo_go = stereo_go %>% mergeClusters(expression_values = 'scaled', + cluster_column = 'leiden_clus', + new_cluster_name = 'leiden_clus_m', + max_group_size = 100, + force_min_group_size = 25, + max_sim_clusters = 10, + min_cor_score = 0.7) + +plotUMAP(gobject = stereo_go, cell_color = 'leiden_clus_m', point_size = 2.5, + show_NN_network = F, edge_alpha = 0.05) +``` + +![](images/stereoseq_mosta/6.png) + +![](images/stereoseq_mosta/7.png) + +# 5. Co-visualization + +- Co-visualize expression UMAP and spatial data clusters + +```{r, eval=FALSE} +spatDimPlot2D(gobject = stereo_go, cell_color = 'leiden_clus_m', + dim_point_size = 1.5, spat_point_size = 1.5, + show_plot = T, return_plot = F) +``` + +![](images/stereoseq_mosta/8.png) + +# 6. Spatial Genes + +- Find genes with spatially coherent expression patterns + +```{r, eval=FALSE} +# create knn +stereo_go <- stereo_go %>% createSpatialNetwork(method = "kNN", k = 8) + +# select 100 random genes +set.seed(144) +featureMetadata = fDataDT(stereo_go) +gene_list = featureMetadata[sample(length(featureMetadata$feat_ID), 100), "feat_ID"] + +# use binSpect method to find spatial genes +spat_genes <- stereo_go %>% binSpect(expression_values = "scaled", + subset_feats = gene_list$feat_ID, + spatial_network_name = "kNN_network") +``` + + +# 7. Subsetting/Filtering + +- Perform these steps to select an ROI using an interactive polygon selection tool. +- To draw a polygon on the interactive plot, click the mouse to start a line segment. Click again to draw the endpoint of the segment, which becomes the startpoint of the following segment. Click "Done" to close the app and save the polygon coordinates. +- See our tutorial on interactive selection/filtering in "Getting started" to learn more. + + +```{r, eval=FALSE} +my_spatPlot <- spatPlot2D(gobject = stereo_go, + cell_color = 'leiden_clus', + color_as_factor = T, + show_plot = FALSE, + point_size = 2, + save_plot = FALSE) + +# create a polygon mask around a ROI, coordinates will be saved after clicking 'Done' +library(shiny) +library(miniUI) +my_polygon_coordinates <- plotInteractivePolygons(my_spatPlot, height = 500) + +# create new giotto object from polygon coordinates +lasso_polygons <- createGiottoPolygonsFromDfr(my_polygon_coordinates, + name = "cell", + calc_centroids = FALSE) + +# store the polygons info within the giotto object +stereo_go <- addGiottoPolygons(gobject = stereo_go, + gpolygons = list(lasso_polygons)) + +# find intersection between original giotto object and polygon subset +my_intersect <- getCellsFromPolygon(stereo_go) + +# create new giotto roi subset +stereo_go_subset <- stereo_go %>% subsetGiotto(cell_ids = my_intersect$cell_ID) + +# visualize filtered ROI +# Your plot below will reflect the polygon(s) you constructed above in my_polygon_coordinates +spatPlot2D(gobject = stereo_go_subset, cell_color = 'leiden_clus', + color_as_factor = T, show_plot = FALSE, + point_size = 2,save_plot = FALSE) +``` + +![](images/stereoseq_mosta/9.png) + +```{r, eval=FALSE} +sessionInfo() + +R version 4.2.1 (2022-06-23) +Platform: x86_64-pc-linux-gnu (64-bit) +Running under: CentOS Linux 7 (Core) + +Matrix products: default +BLAS: /share/pkg.7/r/4.2.1/install/lib64/R/lib/libRblas.so +LAPACK: /share/pkg.7/r/4.2.1/install/lib64/R/lib/libRlapack.so + +locale: + [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 +[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 +[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C +[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C + +attached base packages: + [1] stats graphics grDevices utils datasets methods base + +other attached packages: + [1] miniUI_0.1.1.1 shiny_1.7.2 Giotto_2.1 + +loaded via a namespace (and not attached): + [1] systemfonts_1.0.4 plyr_1.8.8 igraph_1.3.5 +[4] lazyeval_0.2.2 sp_1.5-1 splines_4.2.1 +[7] BiocParallel_1.32.1 listenv_0.8.0 scattermore_0.8 +[10] ggplot2_3.4.0 digest_0.6.30 htmltools_0.5.3 +[13] fansi_1.0.3 memoise_2.0.1 magrittr_2.0.3 +[16] ScaledMatrix_1.6.0 tensor_1.5 cluster_2.1.3 +[19] ROCR_1.0-11 tzdb_0.3.0 remotes_2.4.2 +[22] globals_0.16.1 readr_2.1.2 matrixStats_0.62.0 +[25] spatstat.sparse_2.1-1 colorspace_2.1-0 rappdirs_0.3.3 +[28] ggrepel_0.9.1 textshaping_0.3.6 xfun_0.34 +[31] dplyr_1.0.10 crayon_1.5.2 jsonlite_1.8.3 +[34] progressr_0.10.1 spatstat.data_2.2-0 survival_3.3-1 +[37] zoo_1.8-10 glue_1.6.2 polyclip_1.10-0 +[40] gtable_0.3.1 leiden_0.4.2 DelayedArray_0.24.0 +[43] BiocSingular_1.14.0 future.apply_1.10.0 BiocGenerics_0.44.0 +[46] abind_1.4-7 scales_1.2.1 DBI_1.1.3 +[49] spatstat.random_2.2-0 Rcpp_1.0.9 viridisLite_0.4.1 +[52] xtable_1.8-6 rsthemes_0.3.1 reticulate_1.26 +[55] spatstat.core_2.4-4 rsvd_1.0.5 bit_4.0.4 +[58] stats4_4.2.1 htmlwidgets_1.5.4 httr_1.4.4 +[61] FNN_1.1.3.1 RColorBrewer_1.1-3 ellipsis_0.3.2 +[64] Seurat_4.1.1 ica_1.0-3 pkgconfig_2.0.3 +[67] farver_2.1.1 sass_0.4.2.9000 uwot_0.1.14 +[70] deldir_1.0-6 utf8_1.2.2 here_1.0.1 +[73] tidyselect_1.2.0 labeling_0.4.2 rlang_1.0.6 +[76] reshape2_1.4.4 later_1.3.0 cachem_1.0.6 +[79] munsell_0.5.0 tools_4.2.1 cli_3.4.1 +[82] dbscan_1.1-11 generics_0.1.3 ggridges_0.5.3 +[85] evaluate_0.18 stringr_1.4.1 fastmap_1.1.0 +[88] ragg_1.2.2 yaml_2.3.6 goftest_1.2-3 +[91] knitr_1.40 bit64_4.0.5 fitdistrplus_1.1-8 +[94] purrr_0.3.5 RANN_2.6.1 pbapply_1.5-0 +[97] future_1.29.0 nlme_3.1-158 mime_0.12 +[100] arrow_9.0.0 hdf5r_1.3.5 compiler_4.2.1 +[103] rstudioapi_0.14 plotly_4.10.1 png_0.1-7 +[106] spatstat.utils_2.3-1 tibble_3.1.8 bslib_0.4.1 +[109] stringi_1.7.8 rgeos_0.5-9 lattice_0.20-45 +[112] Matrix_1.5-1 SeuratDisk_0.0.0.9020 vctrs_0.5.0 +[115] pillar_1.8.1 lifecycle_1.0.3 jquerylib_0.1.4 +[118] spatstat.geom_2.4-0 lmtest_0.9-40 RcppAnnoy_0.0.20 +[121] data.table_1.14.4 cowplot_1.1.1 irlba_2.3.5.1 +[124] httpuv_1.6.6 patchwork_1.1.0.9000 R6_2.5.1 +[127] promises_1.2.0.1 KernSmooth_2.23-20 gridExtra_2.3 +[130] IRanges_2.32.0 parallelly_1.32.1 codetools_0.2-18 +[133] MASS_7.3-57 gtools_3.9.3 assertthat_0.2.1 +[136] rprojroot_2.0.3 withr_2.5.0 SeuratObject_4.1.0 +[139] sctransform_0.3.3 S4Vectors_0.36.0 mgcv_1.8-40 +[142] parallel_4.2.1 hms_1.1.1 terra_1.5-34 +[145] beachmat_2.14.0 grid_4.2.1 rpart_4.1.16 +[148] tidyr_1.2.1 rmarkdown_2.18 MatrixGenerics_1.10.0 +[151] Rtsne_0.16 +``` + diff --git a/vignettes/visium_cytassist_human_glioblastoma.Rmd b/vignettes/visium_cytassist_human_glioblastoma.Rmd new file mode 100644 index 000000000..3863bb9bb --- /dev/null +++ b/vignettes/visium_cytassist_human_glioblastoma.Rmd @@ -0,0 +1,477 @@ +--- +title: "Visium CytAssist Multi-omics Human Glioblastoma" +date: 9/7/23 +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Visium CytAssist Multi-omics Human Glioblastoma} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +# 1 Dataset explanation + +The [Human glioblastoma (FFPE) dataset](https://www.10xgenomics.com/resources/datasets/gene-and-protein-expression-library-of-human-glioblastoma-cytassist-ffpe-2-standard/) was obtained from 10x Genomics. The tissue was sectioned as described in Visium CytAssist Spatial Gene Expression for FFPE -- Tissue Preparation Guide Demonstrated Protocol (CG000518). 5 µm tissue sections were placed on Superfrost glass slides, then IF stained following deparaffinization, then hard coverslipped. Sections were imaged, decoverslipped, followed by Demonstrated Protocol (CG000494). + +More information about this dataset can be found [here](https://www.10xgenomics.com/resources/datasets/gene-and-protein-expression-library-of-human-glioblastoma-cytassist-ffpe-2-standard). + +# 2 Start Giotto + + +```{r, eval=FALSE} +# Ensure Giotto Suite is installed +if(!"Giotto" %in% installed.packages()) { + devtools::install_github("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() +} +``` + + + +```{r, eval=FALSE} +# 1. set results directory +results_directory = '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 +if(is.null(python_path)) { + installGiottoEnvironment() +} + +# 3. create giotto instructions +instrs = createGiottoInstructions(save_dir = results_directory, + save_plot = TRUE, + show_plot = TRUE, + python_path = python_path) +``` + + +# 3 Create Giotto object + +The minimum requirements are + +- matrix with expression information (or path to) +- x,y(,z) coordinates for cells or spots (or path to) + +createGiottoVisiumObject() will automatically detect both rna and protein modalities within the expression matrix creating a multi-omics Giotto object. + + +```{r, eval=FALSE} +# Provide path to visium folder +data_directory <- 'path/to/visium/data' + +# Create Giotto object +visium = createGiottoVisiumObject(visium_dir = data_directory, + expr_data = 'raw', + png_name = 'tissue_lowres_image.png', + gene_column_index = 2, + instructions = instrs) +``` + + +How to work with Giotto instructions that are part of your Giotto object: + +- Show the instructions associated with your Giotto object with showGiottoInstructions() +- Change one or more instructions with changeGiottoInstructions() +- Replace all instructions at once with replaceGiottoInstructions() +- Read or get a specific Giotto instruction with readGiottoInstructions() + + +```{r, eval=FALSE} +# show instructions associated with the giotto object + +showGiottoInstructions(visium) +``` + + +# 4 Processing + +- Filter features and cells based on detection frequencies +- Normalize expression matrix (log transformation, scaling factor and/or z-scores) +- Add cell and feature statistics (optional) +- Adjust expression matrix for technical covariates or batches (optional). + + +```{r, eval=FALSE} +# Subset on spots that were covered by tissue +metadata = pDataDT(visium) +in_tissue_barcodes = metadata[in_tissue == 1]$cell_ID +visium = subsetGiotto(visium, cell_ids = in_tissue_barcodes) + +## Visualize aligned tissue +spatPlot2D(gobject = visium, + point_alpha = 0.7) +``` + + +![](images/visium_cytassist_human_glioblastoma/1-spatPlot2D.png) + + +```{r, eval=FALSE} +# Filtering, normalization, and statistics + +## RNA feature +visium <- filterGiotto(gobject = visium, + expression_threshold = 1, + feat_det_in_min_cells = 50, + min_det_feats_per_cell = 1000, + expression_values = c('raw'), + verbose = TRUE) + +visium <- normalizeGiotto(gobject = visium, + scalefactor = 6000, + verbose = TRUE) + +visium <- addStatistics(gobject = visium) + +### Visualize number of features after processing +spatPlot2D(gobject = visium, + point_alpha = 0.7, + cell_color = 'nr_feats', + color_as_factor = FALSE) +``` + + +![](images/visium_cytassist_human_glioblastoma/2-spatPlot2D.png) + +```{r, eval=FALSE} +## Protein feature +visium <- filterGiotto(gobject = visium, + spat_unit = 'cell', + feat_type = 'protein', + expression_threshold = 1, + feat_det_in_min_cells = 50, + min_det_feats_per_cell = 1, + expression_values = 'raw', + verbose = TRUE) + +visium <- normalizeGiotto(gobject = visium, + spat_unit = 'cell', + feat_type = 'protein', + scalefactor = 6000, + verbose = TRUE) + +visium <- addStatistics(gobject = visium, + spat_unit = 'cell', + feat_type = 'protein') + +### Visualize number of features after processing +spatPlot2D(gobject = visium, + spat_unit = 'cell', + feat_type = 'protein', + point_alpha = 0.7, + cell_color = 'nr_feats', + color_as_factor = FALSE) +``` + +![](images/visium_cytassist_human_glioblastoma/3-spatPlot2D.png) + + +# 5 Dimention Reduction + + +```{r, eval=FALSE} +# Identify highly variable features (HVF) +visium <- calculateHVF(gobject = visium) +``` + + +![](images/visium_cytassist_human_glioblastoma/4-HVFplot.png) + + +```{r, eval=FALSE} +# PCA + +## RNA +visium <- runPCA(gobject = visium) + +screePlot(visium, ncp = 30) +``` + + +![](images/visium_cytassist_human_glioblastoma/5-screePlot.png) + + +```{r, eval=FALSE} +### Visualize RNA PCA +plotPCA(gobject = visium) +``` + + +![](images/visium_cytassist_human_glioblastoma/6-PCA.png) + + +```{r, eval=FALSE} +## Protein +visium <- runPCA(gobject = visium, + spat_unit = 'cell', + feat_type = 'protein') + +screePlot(visium, + spat_unit = 'cell', + feat_type = 'protein', + ncp = 30) +``` + + +![](images/visium_cytassist_human_glioblastoma/7-screePlot.png) + + +```{r, eval=FALSE} +### Visualize Protein PCA +plotPCA(gobject = visium, + spat_unit = 'cell', + feat_type = 'protein') +``` + + +![](images/visium_cytassist_human_glioblastoma/8-PCA.png) + + + +# 6 Clustering + + +```{r, eval=FALSE} +# cluster and run UMAP +# sNN network (default) + +## RNA feature +visium <- createNearestNetwork(gobject = visium, + dimensions_to_use = 1:10, + k = 30) + +## Protein feature +visium <- createNearestNetwork(gobject = visium, + spat_unit = 'cell', + feat_type = 'protein', + dimensions_to_use = 1:10, + k = 30) + +# Leiden clustering + +## RNA feature +visium <- doLeidenCluster(gobject = visium, + resolution = 1, + n_iterations = 1000) + +## Protein feature +visium <- doLeidenCluster(gobject = visium, + spat_unit = 'cell', + feat_type = 'protein', + resolution = 1, + n_iterations = 1000) + +# UMAP + +## RNA feature +visium <- runUMAP(visium, + dimensions_to_use = 1:10) + +plotUMAP(gobject = visium, + cell_color = 'leiden_clus', + show_NN_network = TRUE, + point_size = 2) +``` + + +![](images/visium_cytassist_human_glioblastoma/9-UMAP.png) + +```{r, eval=FALSE} +## Protein feature +visium <- runUMAP(visium, + spat_unit = 'cell', + feat_type = 'protein', + dimensions_to_use = 1:10) + +plotUMAP(gobject = visium, + spat_unit = 'cell', + feat_type = 'protein', + cell_color = 'leiden_clus', + show_NN_network = TRUE, + point_size = 2) +``` + +![](images/visium_cytassist_human_glioblastoma/10-UMAP.png) + + +```{r, eval=FALSE} +# Visualize spatial plot + +## RNA feature +spatPlot2D(gobject = visium, + show_image = TRUE, + cell_color = 'leiden_clus', + point_size = 2) +``` + + +![](images/visium_cytassist_human_glioblastoma/11-rna_spatPlot2D.png) + + +```{r, eval=FALSE} +## Protein feature +spatPlot2D(gobject = visium, + spat_unit = 'cell', + feat_type = 'protein', + show_image = TRUE, + cell_color = 'leiden_clus', + point_size = 2) +``` + + +![](images/visium_cytassist_human_glioblastoma/12-protein_spatPlot2D.png) + + + +# 7 Multi-omics integration + +The Weighted Nearest Neighbors allows to integrate two or more modalities acquired from the same sample. WNN will re-calculate the clustering to provide an integrated umap and leiden clustering. For running WNN, the Giotto object must contain the results of running PCA calculation for each modality. + + +```{r, eval=FALSE} +# Calculate kNN + +## RNA modality +visium <- createNearestNetwork(gobject = visium, + type = 'kNN', + dimensions_to_use = 1:10, + k = 20) + +## Protein modality +visium <- createNearestNetwork(gobject = visium, + spat_unit = 'cell', + feat_type = 'protein', + type = 'kNN', + dimensions_to_use = 1:10, + k = 20) + + +# Run WNN +visium <- runWNN(visium, + spat_unit = "cell", + modality_1 = "rna", + modality_2 = "protein", + pca_name_modality_1 = "pca", + pca_name_modality_2 = "protein.pca", + k = 20, + integrated_feat_type = NULL, + matrix_result_name = NULL, + w_name_modality_1 = NULL, + w_name_modality_2 = NULL, + verbose = TRUE) + +# Run Integrated umap +visium <- runIntegratedUMAP(visium, + modality1 = "rna", + modality2 = "protein", + spread = 5, + min_dist = 0.5, + force = FALSE) + +# Calculate integrated clusters +visium <- doLeidenCluster(gobject = visium, + spat_unit = "cell", + feat_type = "rna", + nn_network_to_use = "kNN", + network_name = "integrated_kNN", + name = "integrated_leiden_clus", + resolution = 1) + +# Visualize integrated umap +plotUMAP(gobject = visium, + spat_unit = "cell", + feat_type = "rna", + cell_color = 'integrated_leiden_clus', + dim_reduction_name = "integrated.umap", + point_size = 1.5, + title = "Integrated UMAP using Integrated Leiden clusters", + axis_title = 12, + axis_text = 10 ) +``` + +![](images/visium_cytassist_human_glioblastoma/13-UMAP.png) + + +```{r, eval=FALSE} +# Visualize spatial plot with integrated clusters +spatPlot2D(visium, + spat_unit = "cell", + feat_type = "rna", + cell_color = "integrated_leiden_clus", + point_size = 2, + show_image = FALSE, + title = "Integrated Leiden clustering") +``` + + +![](images/visium_cytassist_human_glioblastoma/14-integrated_spatPlot2D.png) + + +# 8 Session Info + +```{r, eval=FALSE} +sessionInfo() + +R version 4.3.1 (2023-06-16) +Platform: x86_64-apple-darwin20 (64-bit) +Running under: macOS Ventura 13.5.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.3-x86_64/Resources/lib /libRlapack.dylib; LAPACK version 3.11.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_3.3.2 GiottoVisuals_0.0.0.9002 +[3] GiottoClass_0.0.0.9003 GiottoUtils_0.0.0.9002 + +loaded via a namespace (and not attached): +[1] gtable_0.3.4 xfun_0.40 ggplot2_3.4.3 +[4] htmlwidgets_1.6.2 devtools_2.4.5 remotes_2.4.2.1 +[7] processx_3.8.2 lattice_0.21-8 callr_3.7.3 +[10] vctrs_0.6.3 tools_4.3.1 ps_1.7.5 +[13] generics_0.1.3 parallel_4.3.1 tibble_3.2.1 +[16] fansi_1.0.4 colorRamp2_0.1.0 pkgconfig_2.0.3 +[19] Matrix_1.6-1 data.table_1.14.8 checkmate_2.2.0 +[22] RColorBrewer_1.1-3 lifecycle_1.0.3 farver_2.1.1 +[25] compiler_4.3.1 stringr_1.5.0 textshaping_0.3.6 +[28] munsell_0.5.0 terra_1.7-39 codetools_0.2-19 +[31] httpuv_1.6.11 htmltools_0.5.6 usethis_2.2.2 +[34] yaml_2.3.7 later_1.3.1 pillar_1.9.0 +[37] crayon_1.5.2 urlchecker_1.0.1 ellipsis_0.3.2 +[40] cachem_1.0.8 magick_2.7.5 sessioninfo_1.2.2 +[43] mime_0.12 tidyselect_1.2.0 digest_0.6.33 +[46] stringi_1.7.12 dplyr_1.1.2 purrr_1.0.2 +[49] labeling_0.4.2 cowplot_1.1.1 fastmap_1.1.1 +[52] grid_4.3.1 colorspace_2.1-0 cli_3.6.1 +[55] magrittr_2.0.3 pkgbuild_1.4.2 utf8_1.2.3 +[58] withr_2.5.0 prettyunits_1.1.1 scales_1.2.1 +[61] promises_1.2.1 backports_1.4.1 rmarkdown_2.24 +[64] igraph_1.5.1 reticulate_1.31 ragg_1.2.5 +[67] png_0.1-8 memoise_2.0.1 shiny_1.7.5 +[70] evaluate_0.21 knitr_1.43 miniUI_0.1.1.1 +[73] profvis_0.3.8 rlang_1.1.1 Rcpp_1.0.11 +[76] xtable_1.8-4 glue_1.6.2 pkgload_1.3.2.1 +[79] jsonlite_1.8.7 rstudioapi_0.15.0 R6_2.5.1 +[82] systemfonts_1.0.4 fs_1.6.3 +``` + + + diff --git a/vignettes/visium_cytassist_lungcancer.Rmd b/vignettes/visium_cytassist_lungcancer.Rmd new file mode 100644 index 000000000..0dab4b186 --- /dev/null +++ b/vignettes/visium_cytassist_lungcancer.Rmd @@ -0,0 +1,677 @@ +--- +title: "Visium CytAssist Human Lung Cancer" +date: 2022-11-23 +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Visium CytAssist Human Lung Cancer} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + + +# Dataset Explanation + +The human lung cancer (FFPE) dataset was obtained from 10x Genomics using their CytAssist Visium technology that has been recently developed to allow users to perform standard histology workflows on two standard glass slides before transferring the transcriptional probes on the two-area capture visium slide. + +More information about this dataset can be found [here](https://www.10xgenomics.com/resources/datasets/human-lung-cancer-ffpe-2-standard/). + +![](images/visium_cytassist_lungcancer/CytAssist_Visium_workflow.png){width="90.0%"} + +# Start Giotto + +To run the current vignette you need to install the Giotto Suite branch. + +```{r, eval=FALSE} +# Ensure Giotto Suite and GiottoData packages are installed +if(!"Giotto" %in% installed.packages()) { + devtools::install_github("drieslab/Giotto@suite") +} + +if(!"Giotto" %in% installed.packages()) { + devtools::install_github("drieslab/GiottoData") +} + +library(Giotto) +library(GiottoData) + +# 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() +} + +# to automatically save figures in save_dir set save_plot to TRUE +temp_dir = getwd() +myinstructions = createGiottoInstructions(save_dir = temp_dir, + save_plot = TRUE, + show_plot = TRUE) +``` + + +# 1. Create a Giotto object + +The minimum requirements are + +- matrix with expression information (or path to) +- x,y(,z) coordinates for cells or spots (or path to) + + +```{r, eval=FALSE} +# Provide path to visium folder +data_path = paste0(temp_dir, '/data/') +getSpatialDataset(dataset = 'cytassist_lungcancer', directory = data_path, method = 'wget') + +# Create Giotto object + visium_lungcancer = createGiottoVisiumObject(visium_dir = data_path, + expr_data = 'raw', + png_name = 'tissue_lowres_image.png', + gene_column_index = 2, + instructions = myinstructions) + +# check metadata +pDataDT(visium_lungcancer) + +# check available image names +showGiottoImageNames(visium_lungcancer) # "image" is the default name + +# show aligned image +spatPlot(gobject = visium_lungcancer, cell_color = 'in_tissue', show_image = T, point_alpha = 0.7) +``` + + +![](images/visium_cytassist_lungcancer/0-spatPlot2D.png){width="50.0%"} + +How to work with Giotto instructions that are part of your Giotto object: + +- show the instructions associated with your Giotto object with **showGiottoInstructions()** +- change one or more instructions with **changeGiottoInstructions()** +- replace all instructions at once with **replaceGiottoInstructions()** +- read or get a specific Giotto instruction with **readGiottoInstructions()** + + +```{r, eval=FALSE} +# show instructions associated with giotto object (visium_lungcancer) +showGiottoInstructions(visium_lungcancer) +``` + + +# 2. Processing steps + +- filter genes and cells based on detection frequencies +- normalize expression matrix (log transformation, scaling factor and/or z-scores) +- add cell and gene statistics (optional) +- adjust expression matrix for technical covariates or batches (optional). These results will be stored in the *custom* slot. + + +```{r, eval=FALSE} +visium_lungcancer <- filterGiotto(gobject = visium_lungcancer, + expression_threshold = 1, + feat_det_in_min_cells = 50, + min_det_feats_per_cell = 1000, + expression_values = c('raw'), + verbose = T) +visium_lungcancer <- normalizeGiotto(gobject = visium_lungcancer, scalefactor = 6000, verbose = T) +visium_lungcancer <- addStatistics(gobject = visium_lungcancer) +``` + + +## Visualize aligned tissue with number of features after processing + + +```{r, eval=FALSE} +spatPlot2D(gobject = visium_lungcancer, show_image = T, point_alpha = 0.7) +``` + + +![](images/visium_cytassist_lungcancer/1-spatPlot2D.png){width="50.0%"} + + +```{r, eval=FALSE} +spatPlot2D(gobject = visium_lungcancer, show_image = T, point_alpha = 0.7, + cell_color = 'nr_feats', color_as_factor = F) +``` + + +![](images/visium_cytassist_lungcancer/2-spatPlot2D.png){width="50.0%"} + +# 3. Dimension Reduction + +- identify highly variable features (HVF) + + +```{r, eval=FALSE} +visium_lungcancer <- calculateHVF(gobject = visium_lungcancer) +``` + + +![](images/visium_cytassist_lungcancer/3-HVFplot.png){width="50.0%"} + +- perform PCA +- identify number of significant principal components (PCs) + + +```{r, eval=FALSE} +visium_lungcancer <- runPCA(gobject = visium_lungcancer) +screePlot(visium_lungcancer, ncp = 30) +``` + + +![](images/visium_cytassist_lungcancer/4-screePlot.png){width="50.0%"} + + +```{r, eval=FALSE} +plotPCA(gobject = visium_lungcancer) +``` + + +![](images/visium_cytassist_lungcancer/5-PCA.png){width="50.0%"} + +- run UMAP and/or t-SNE on PCs (or directly on matrix) + + +```{r, eval=FALSE} +visium_lungcancer <- runUMAP(visium_lungcancer, dimensions_to_use = 1:10) +plotUMAP(gobject = visium_lungcancer) +``` + + +![](images/visium_cytassist_lungcancer/6-UMAP.png){width="50.0%"} + + +```{r, eval=FALSE} +visium_lungcancer <- runtSNE(visium_lungcancer, dimensions_to_use = 1:10) +plotTSNE(gobject = visium_lungcancer) +``` + + +![](images/visium_cytassist_lungcancer/7-tSNE.png){width="50.0%"} + +# 4. Clustering + +- create a shared (default) nearest network in PCA space (or directly on matrix) +- cluster on nearest network with Leiden or Louvain (k-means and hclust are alternatives) + + +```{r, eval=FALSE} +# Create shared nearest network (SNN) and perform leiden clustering +visium_lungcancer <- createNearestNetwork(gobject = visium_lungcancer, dimensions_to_use = 1:10, k = 30) +visium_lungcancer <- doLeidenCluster(gobject = visium_lungcancer, spat_unit = 'cell', feat_type = 'rna', resolution = 0.4, n_iterations = 1000) + +# visualize UMAP cluster results +plotUMAP(gobject = visium_lungcancer, cell_color = 'leiden_clus', show_NN_network = T, point_size = 2) +``` + + +![](images/visium_cytassist_lungcancer/8-UMAP.png){width="50.0%"} + + +```{r, eval=FALSE} +# visualize tSNE cluster results +plotTSNE(gobject = visium_lungcancer, cell_color = 'leiden_clus', show_NN_network = T, point_size = 2) +``` + + +![](images/visium_cytassist_lungcancer/9-tSNE.png){width="50.0%"} + + +```{r, eval=FALSE} +# visualize expression and spatial results +spatDimPlot(gobject = visium_lungcancer, cell_color = 'leiden_clus', + dim_point_size = 2, spat_point_size = 2) +``` + + +![](images/visium_cytassist_lungcancer/10-spatDimPlot2D.png){width="50.0%"} + + +```{r, eval=FALSE} +spatDimPlot(gobject = visium_lungcancer, cell_color = 'nr_feats', color_as_factor = F, + dim_point_size = 2, dim_show_legend = T, spat_show_legend = T, spat_point_size = 2) +``` + + +![](images/visium_cytassist_lungcancer/11-spatDimPlot2D.png){width="50.0%"} + +# 5. Differential expression + + +```{r, eval=FALSE} +# Cell type marker detection +# Gini markers +gini_markers_subclusters = findMarkers_one_vs_all(gobject = visium_lungcancer, + method = 'gini', + expression_values = 'normalized', + cluster_column = 'leiden_clus', + min_featss = 20, + min_expr_gini_score = 0.5, + min_det_gini_score = 0.5) + +# get top 2 genes per cluster and visualize with violin plot +topgenes_gini = gini_markers_subclusters[, head(.SD, 2), by = 'cluster']$feats +violinPlot(visium_lungcancer, feats = unique(topgenes_gini), cluster_column = 'leiden_clus', + strip_text = 8, strip_position = 'right') +``` + + +![](images/visium_cytassist_lungcancer/12-violinPlot.png){width="50.0%"} + + +```{r, eval=FALSE} +# cluster heatmap +plotMetaDataHeatmap(visium_lungcancer, + selected_feats = topgenes_gini, + metadata_cols = c('leiden_clus'), + x_text_size = 10, y_text_size = 10) +``` + + +![](images/visium_cytassist_lungcancer/13-plotMetaDataHeatmap.png){width="50.0%"} + + +```{r, eval=FALSE} +# umap plots +dimFeatPlot2D(visium_lungcancer, + expression_values = 'scaled', + feats = gini_markers_subclusters[, head(.SD, 1), by = 'cluster']$feats, + cow_n_col = 3, point_size = 1) +``` + + +![](images/visium_cytassist_lungcancer/14-dimFeatPlot2D.png){width="50.0%"} + + +```{r, eval=FALSE} +# Cell type marker detection +# Scran markers +scran_markers_subclusters = findMarkers_one_vs_all(gobject = visium_lungcancer, + method = 'scran', + expression_values = 'normalized', + cluster_column = 'leiden_clus') + +# get top 2 genes per cluster and visualize with violin plot +topgenes_scran = scran_markers_subclusters[, head(.SD, 2), by = 'cluster']$feats +violinPlot(visium_lungcancer, feats = unique(topgenes_scran), + cluster_column = 'leiden_clus', + strip_text = 10, strip_position = 'right') +``` + + +![](images/visium_cytassist_lungcancer/15-violinPlot.png){width="50.0%"} + + +```{r, eval=FALSE} +# cluster heatmap +plotMetaDataHeatmap(visium_lungcancer, + selected_feats = topgenes_scran, + metadata_cols = c('leiden_clus'), + x_text_size = 10, y_text_size = 10) +``` + + +![](images/visium_cytassist_lungcancer/16-plotMetaDataHeatmap.png){width="50.0%"} + + +```{r, eval=FALSE} +# umap plots +dimFeatPlot2D(visium_lungcancer, + expression_values = 'scaled', + feats = scran_markers_subclusters[, head(.SD, 1), by = 'cluster']$feats, + cow_n_col = 3, point_size = 1) +``` + + +# 6. Cell Type Enrichment + +Visium spatial transcriptomics does not provide single-cell resolution, making cell type annotation a harder problem. Giotto provides several ways to calculate enrichment of specific cell-type signature gene lists: + +- PAGE +- hypergeometric test +- Rank +- DWLS + +[Deconvolution](https://genomebiology.biomedcentral.com/articles/10.1186/s13059-021-02362-7) +Corresponded Single cell dataset can be generated from [here](http://mousebrain.org/). Giotto_SC is processed from the downsampled [Loom](https://satijalab.org/loomr/loomr_tutorial) file and can also be downloaded from getSpatialDataset. + +## PAGE + +The cell-type specific signature gene list was obtained from a previous study focused on investigating the therapy-induced evolution of lung cancer revealed by single-cell RNA sequencing. More information about the paper and scRNA-seq dataset can be found [here](https://doi.org/10.1016/j.cell.2020.07.017). + + +```{r, eval=FALSE} +# umap plots +# Create PAGE matrix +# PAGE matrix should be a binary matrix with each row represent a gene marker and each column represent a cell type +# There are several ways to create PAGE matrix +# 1.1 create binary matrix of cell signature genes +# small example # +Tcells_markers = c("CD2", "CD3D", "CD3E", "CD3G") +macrophage_markers = c("MARCO", "CSF1R", "CD68", "GLDN", "APOE", "CCL3L1", "TREM2", "C1QB", "NUPR1", "FOLR2", "RNASE1", "C1QA") +dendritic_markers = c("CD1E", "CD1C", "FCER1A", "PKIB", "CYP2S1", "NDRG2") +mast_markers = c("CMA1", "TPSAB1", "TPSB2") +Bcell_markers = c("IGLL5", "MZB1", "JCHAIN", "DERL3", "SDC1", "MS$A1", "BANK1", "PAX5", "CD79A") +Bcell_PB_markers = c("PRDM1", "XSP1", "IRF4") +Bcell_mem_markers = c("MS4A1", "IRF8") +housekeeping_markers = c("ACTB", "GAPDH", "MALAT1") +neutrophils_markers = c("FCGR3B", "ALPL", "CXCR1", "CXCR2", "ADGRG3", "CMTM2", "PROK2", "MME", "MMP25", "TNFRSF10C") +pdcs_markers = c("SLC32A1", "SHD", "LRRC26", "PACSIN1", "LILRA4", "CLEC4C", "DNASE1L3", "SCT", "LAMP5") + +signature_matrix = makeSignMatrixPAGE(sign_names = c('T_Cells', 'Macrophage', 'Dendritic', 'Mast', 'B_cell', 'Bcell_PB', 'Bcells_memory', +'Housekeeping', 'Neutrophils', 'pDCs'), + sign_list = list(Tcells_markers, + macrophage_markers, + dendritic_markers, + mast_markers, + Bcell_markers, + Bcell_PB_markers, + Bcell_mem_markers, + housekeeping_markers, + neutrophils_markers, + pdcs_markers)) + +# 1.3 enrichment test with PAGE + +markers_scran = findMarkers_one_vs_all(gobject=giotto_SC, method="scran", + expression_values="normalized", cluster_column = "Class", min_feats=3) + +top_markers <- markers_scran[, head(.SD, 10), by="cluster"] +celltypes<-levels(factor(markers_scran$cluster)) +sign_list<-list() +for (i in 1:length(celltypes)){ + sign_list[[i]]<-top_markers[which(top_markers$cluster == celltypes[i]),]$feats +} + +PAGE_matrix_3 = makeSignMatrixPAGE(sign_names = celltypes, + sign_list = sign_list) + +# runSpatialEnrich() can also be used as a wrapper for all currently provided enrichment options +visium_lungcancer = runPAGEEnrich(gobject = visium_lungcancer, sign_matrix = signature_matrix, min_overlap_genes = 1) + +# 1.4 heatmap of enrichment versus annotation (e.g. clustering result) +cell_types = colnames(signature_matrix) +plotMetaDataCellsHeatmap(gobject = visium_lungcancer, + metadata_cols = 'leiden_clus', + value_cols = cell_types, + spat_enr_names = 'PAGE', + x_text_size = 8, + y_text_size = 8, + show_plot = T, + save_param = list(save_name="7_a_metaheatmap")) +``` + + +![](images/visium_cytassist_lungcancer/17-metaheatmap.png){width="50.0%"} + + +```{r, eval=FALSE} +cell_types_subset = colnames(signature_matrix) +spatCellPlot(gobject = visium_lungcancer, + spat_enr_names = 'PAGE', + cell_annotation_values = cell_types_subset, + cow_n_col = 4, coord_fix_ratio = NULL, point_size = 0.75, + save_param = list(save_name="7_b_spatcellplot_1")) +``` + + +![](images/visium_cytassist_lungcancer/18-spatcellplot_1.png){width="80.0%"} + + +```{r, eval=FALSE} +spatDimCellPlot(gobject = visium_lungcancer, + spat_enr_names = 'PAGE', + cell_annotation_values = c('B_cell','Macrophage'), + cow_n_col = 1, spat_point_size = 1.2, + plot_alignment = 'horizontal', + save_param = list(save_name="7_d_spatDimCellPlot", base_width=7, base_height=10)) +``` + + +![](images/visium_cytassist_lungcancer/19-spatDimCellPlot.png){width="80.0%"} + +# 7. Spatial Grids + + +```{r, eval=FALSE} +visium_lungcancer <- createSpatialGrid(gobject = visium_lungcancer, + sdimx_stepsize = 400, + sdimy_stepsize = 400, + minimum_padding = 0) + +spatPlot(visium_lungcancer, cell_color = 'leiden_clus', point_size = 2.5, show_grid = T, +grid_color = 'red', spatial_grid_name = 'spatial_grid') +``` + + +![](images/visium_cytassist_lungcancer/20-spatPlot2D.png){width="50.0%"} + +# 8. Spatial Network + + +```{r, eval=FALSE} +## Delaunay network: stats + creation +plotStatDelaunayNetwork(gobject = visium_lungcancer, maximum_distance = 400) +``` + + +![](images/visium_cytassist_lungcancer/21-plotStatDelaunayNetwork.png){width="50.0%"} + + +```{r, eval=FALSE} +visium_lungcancer = createSpatialNetwork(gobject = visium_lungcancer, minimum_k = 0) +showNetworks(visium_lungcancer) +spatPlot(gobject = visium_lungcancer, show_network = T, +network_color = 'blue', spatial_network_name = 'Delaunay_network') +``` + + +![](images/visium_cytassist_lungcancer/22-spatPlot2D.png){width="50.0%"} + +# 9. Spatial Genes + + +```{r, eval=FALSE} +# kmeans binarization +kmtest = binSpect(visium_lungcancer) +spatFeatPlot2D(visium_lungcancer, expression_values = 'scaled', + feats = kmtest$feats[1:6], cow_n_col = 2, point_size = 1.5) +``` + + +![](images/visium_cytassist_lungcancer/23-spatFeatPlot2D.png){width="50.0%"} + + +```{r, eval=FALSE} +## rank binarization +ranktest = binSpect(visium_lungcancer, bin_method = 'rank') +spatFeatPlot2D(visium_lungcancer, expression_values = 'scaled', + feats = ranktest$feats[1:6], cow_n_col = 2, point_size = 1.5) +``` + + + +```{r, eval=FALSE} +## spatially correlated genes ## +ext_spatial_genes = kmtest[1:500]$feats + +# 1. calculate gene spatial correlation and single-cell correlation +# create spatial correlation object +spat_cor_netw_DT = detectSpatialCorFeats(visium_lungcancer, + method = 'network', + spatial_network_name = 'Delaunay_network', + subset_feats = ext_spatial_genes) + +# 2. identify most similar spatially correlated genes for one gene +DNAI1_top10_genes = showSpatialCorFeats(spat_cor_netw_DT, feats = 'DNAI1', show_top_feats = 10) + +spatFeatPlot2D(visium_lungcancer, expression_values = 'scaled', + feats = c('RSPH1', 'C20orf85', 'DNAAF1','TEKT2'), point_size = 3) +``` + + +![](images/visium_cytassist_lungcancer/24-spatFeatPlot2D.png){width="50.0%"} + + +```{r, eval=FALSE} +spatFeatPlot2D(visium_lungcancer, expression_values = 'scaled', + feats = c('TEKT2', 'CFAP157', 'MAPK15', 'MS4A8', 'CDHR3', 'C9orf24'), point_size = 3) +``` + + +![](images/visium_cytassist_lungcancer/25-spatFeatPlot2D.png){width="50.0%"} + + +```{r, eval=FALSE} +# 3. cluster correlated genes & visualize +spat_cor_netw_DT = clusterSpatialCorFeats(spat_cor_netw_DT, name = ‘spat_netw_clus’, k = 10) + +heatmSpatialCorFeats(visium_lungcancer, spatCorObject = spat_cor_netw_DT, use_clus_name = ‘spat_netw_clus’, +save_param = c(save_name = ‘22-z1-heatmap_correlated_genes’, save_format = ‘pdf’, base_height = 6, base_width = 8, units = ‘cm’), heatmap_legend_param = list(title = NULL)) +``` + + +![](images/visium_cytassist_lungcancer/26-heatmap_correlated_genes.png){width="50.0%"} + + +```{r, eval=FALSE} +# 4. rank spatial correlated clusters and show genes for selected clusters +netw_ranks = rankSpatialCorGroups(visium_lungcancer, + spatCorObject = spat_cor_netw_DT, + use_clus_name = 'spat_netw_clus', + save_param = c(save_name = '22-z2-rank_correlated_groups', + base_height = 3, base_width = 5)) + +top_netw_spat_cluster = showSpatialCorFeats(spat_cor_netw_DT, use_clus_name = 'spat_netw_clus', + selected_clusters = 6, show_top_feats = 1) +``` + + +![](images/visium_cytassist_lungcancer/27-rank_correlated_groups.png){width="50.0%"} + + +```{r, eval=FALSE} +# 5. create metagene enrichment score for clusters +cluster_genes_DT = showSpatialCorFeats(spat_cor_netw_DT, use_clus_name = 'spat_netw_clus', show_top_feats = 1) +cluster_genes = cluster_genes_DT$clus; names(cluster_genes) = cluster_genes_DT$feat_ID + +visium_lungcancer = createMetafeats(visium_lungcancer, feat_clusters = cluster_genes, name = 'cluster_metagene') + +showGiottoSpatEnrichments(visium_lungcancer) + +spatCellPlot(visium_lungcancer, + spat_enr_names = 'cluster_metagene', + cell_annotation_values = netw_ranks$clusters, + point_size = 1.5, cow_n_col = 4) +``` + + +![](images/visium_cytassist_lungcancer/28-spatCellPlot2D.png){width="80.0%"} + +# 10. HMRF Domains + + +```{r, eval=FALSE} +# HMRF requires a fully connected network! +visium_lungcancer = createSpatialNetwork(gobject = visium_lungcancer, minimum_k = 2, name = 'Delaunay_full') + +# spatial genes +my_spatial_genes <- kmtest[1:100]$feats + +# do HMRF with different betas +hmrf_folder = paste0(results_folder,'/','HMRF_results/') +if(!file.exists(hmrf_folder)) dir.create(hmrf_folder, recursive = T) + +# if Rscript is not found, you might have to create a symbolic link, e.g. +# cd /usr/local/bin +# sudo ln -s /Library/Frameworks/R.framework/Resources/Rscript Rscript +HMRF_spatial_genes = doHMRF(gobject = visium_lungcancer, + expression_values = 'scaled', + spatial_network_name = 'Delaunay_full', + spatial_genes = my_spatial_genes, + k = 5, + betas = c(0, 10, 3), + output_folder = paste0(hmrf_folder, '/', 'Spatial_genes/SG_topgenes_k5_scaled')) + +## alternative way to view HMRF results +# results = writeHMRFresults(gobject = ST_test, +# HMRFoutput = HMRF_spatial_genes, +# k = 5, betas_to_view = seq(0, 25, by = 5)) +# ST_test = addCellMetadata(ST_test, new_metadata = results, by_column = T, column_cell_ID = 'cell_ID') + +## add HMRF of interest to giotto object +visium_lungcancer = addHMRF(gobject = visium_lungcancer, + HMRFoutput = HMRF_spatial_genes, + k = 5, betas_to_add = c(0,10,20), + hmrf_name = 'HMRF') + +showGiottoSpatEnrichments(visium_lungcancer) + +## visualize +spatPlot(gobject = visium_lungcancer, cell_color = 'HMRF_k5_b.0', point_size = 3) +``` + + +![](images/visium_cytassist_lungcancer/29-spatPlot2D.png){width="50.0%"} + + +```{r, eval=FALSE} +spatPlot(gobject = visium_lungcancer, cell_color = 'HMRF_k5_b.10', point_size = 3) +``` + + +![](images/visium_cytassist_lungcancer/30-spatPlot2D.png){width="50.0%"} + + +```{r, eval=FALSE} +sessionInfo() + +R version 4.2.2 (2022-10-31) +Platform: aarch64-apple-darwin20 (64-bit) +Running under: macOS Monterey 12.5.1 + +Matrix products: default +LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib + +locale: +[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 + +attached base packages: +[1] stats graphics grDevices utils datasets methods base + +other attached packages: +[1] Giotto_3.0.1 + +loaded via a namespace (and not attached): + [1] bitops_1.0-7 matrixStats_0.63.0 fs_1.5.2 + [4] usethis_2.1.6 devtools_2.4.5 GenomeInfoDb_1.34.3 + [7] tools_4.2.2 profvis_0.3.7 utf8_1.2.2 +[10] R6_2.5.1 irlba_2.3.5.1 BiocGenerics_0.44.0 +[13] colorspace_2.0-3 urlchecker_1.0.1 tidyselect_1.2.0 +[16] prettyunits_1.1.1 processx_3.8.0 compiler_4.2.2 +[19] cli_3.4.1 Biobase_2.58.0 BiocNeighbors_1.16.0 +[22] DelayedArray_0.24.0 scales_1.2.1 callr_3.7.3 +[25] stringr_1.4.1 digest_0.6.30 XVector_0.38.0 +[28] pkgconfig_2.0.3 htmltools_0.5.3 sessioninfo_1.2.2 +[31] sparseMatrixStats_1.10.0 MatrixGenerics_1.10.0 fastmap_1.1.0 +[34] limma_3.54.0 htmlwidgets_1.5.4 rlang_1.0.6 +[37] rstudioapi_0.14 shiny_1.7.3 DelayedMatrixStats_1.20.0 +[40] generics_0.1.3 BiocParallel_1.32.1 dplyr_1.0.10 +[43] RCurl_1.98-1.9 magrittr_2.0.3 BiocSingular_1.14.0 +[46] GenomeInfoDbData_1.2.9 Matrix_1.5-3 Rcpp_1.0.9 +[49] munsell_0.5.0 S4Vectors_0.36.0 fansi_1.0.3 +[52] lifecycle_1.0.3 stringi_1.7.8 SummarizedExperiment_1.28.0 +[55] zlibbioc_1.44.0 pkgbuild_1.3.1 grid_4.2.2 +[58] parallel_4.2.2 promises_1.2.0.1 dqrng_0.3.0 +[61] crayon_1.5.2 miniUI_0.1.1.1 lattice_0.20-45 +[64] beachmat_2.14.0 locfit_1.5-9.6 ps_1.7.2 +[67] pillar_1.8.1 igraph_1.3.5 GenomicRanges_1.50.1 +[70] codetools_0.2-18 ScaledMatrix_1.6.0 stats4_4.2.2 +[73] pkgload_1.3.2 glue_1.6.2 data.table_1.14.6 +[76] remotes_2.4.2 BiocManager_1.30.19 vctrs_0.5.1 +[79] httpuv_1.6.6 gtable_0.3.1 purrr_0.3.5 +[82] cachem_1.0.6 ggplot2_3.4.0 rsvd_1.0.5 +[85] mime_0.12 xtable_1.8-4 later_1.3.0 +[88] SingleCellExperiment_1.20.0 tibble_3.1.8 memoise_2.0.1 +[91] IRanges_2.32.0 cluster_2.1.4 bluster_1.8.0 +[94] ellipsis_0.3.2 +``` + diff --git a/vignettes/visium_mouse_brain.Rmd b/vignettes/visium_mouse_brain.Rmd new file mode 100644 index 000000000..9931d2f74 --- /dev/null +++ b/vignettes/visium_mouse_brain.Rmd @@ -0,0 +1,762 @@ +--- +title: "Visium Mouse Brain" +date: 2022-09-16 +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Visium Mouse Brain} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + + +```{r, eval=FALSE} +# Ensure Giotto Suite is installed. +if(!"Giotto" %in% installed.packages()) { + devtools::install_github("drieslab/Giotto@suite") +} + +# Ensure GiottoData, a small, helper module for tutorials, is installed. +if(!"GiottoData" %in% installed.packages()) { + devtools::install_github("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 + + +```{r, eval=FALSE} +library(Giotto) +library(GiottoData) + +# 1. set working directory +results_folder = 'path/to/result' + +# 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. +my_python_path = NULL # alternatively, "/local/python/path/python" if desired. + +# 3. Create Giotto Instructions +instrs = createGiottoInstructions(save_dir = results_folder, + save_plot = TRUE, + show_plot = FALSE, + python_path = my_python_path) +``` + + +# Dataset explanation + +[10X genomics](https://www.10xgenomics.com/spatial-transcriptomics/) recently launched a new platform to obtain spatial expression data using a Visium Spatial Gene Expression slide. + +The Visium brain data to run this tutorial can be found [here](https://support.10xgenomics.com/spatial-gene-expression/datasets/1.1.0/V1_Adult_Mouse_Brain) + +Visium technology: + +![](images/general_figs/visium_technology.png){width="50.0%"} + + +High resolution png from original tissue: + +![]images/general_figs/mouse_brain_highres.png){width="50.0%"} + +# Part 1: Create Giotto Visium Object and visualize + + +```{r, eval=FALSE} +## provide path to visium folder +data_path = '/path/to/Brain_data/' + +## directly from visium folder +visium_brain = createGiottoVisiumObject(visium_dir = data_path, + expr_data = 'raw', + png_name = 'tissue_lowres_image.png', + gene_column_index = 2, + instructions = instrs) + +## show associated images with giotto object +showGiottoImageNames(visium_brain) # "image" is the default name + +## check metadata +pDataDT(visium_brain) + +## show plot +spatPlot2D(gobject = visium_brain, cell_color = 'in_tissue', point_size = 2, + cell_color_code = c('0' = 'lightgrey', '1' = 'blue'), + show_image = T, image_name = 'image') +``` + + +![](images/visium_mouse_brain/0-spatPlot2D.png){width="50.0%"} + +# Part 2: Process Giotto Visium Object + + +```{r, eval=FALSE} +## subset on spots that were covered by tissue +metadata = pDataDT(visium_brain) +in_tissue_barcodes = metadata[in_tissue == 1]$cell_ID +visium_brain = subsetGiotto(visium_brain, cell_ids = in_tissue_barcodes) + +## filter +visium_brain <- filterGiotto(gobject = visium_brain, + expression_threshold = 1, + feat_det_in_min_cells = 50, + min_det_feats_per_cell = 1000, + expression_values = c('raw'), + verbose = T) + +## normalize +visium_brain <- normalizeGiotto(gobject = visium_brain, scalefactor = 6000, verbose = T) + +## add gene & cell statistics +visium_brain <- addStatistics(gobject = visium_brain) + +## visualize +spatPlot2D(gobject = visium_brain, show_image = T, point_alpha = 0.7, + cell_color = 'nr_feats', color_as_factor = F) +``` + + +![](images/visium_mouse_brain/1-spatPlot2D.png){width="50.0%"} + +# Part 3: Dimention Reduction + + +```{r, eval=FALSE} +## highly variable features / genes (HVF) +visium_brain <- calculateHVF(gobject = visium_brain, save_plot = TRUE) +``` + + +![](images/visium_mouse_brain/2-HVFplot.png){width="50.0%"} + + +```{r, eval=FALSE} +## run PCA on expression values (default) +gene_metadata = fDataDT(visium_brain) +featgenes = gene_metadata[hvf == 'yes' & perc_cells > 3 & mean_expr_det > 0.4]$feat_ID + +## run PCA on expression values (default) +visium_brain <- runPCA(gobject = visium_brain, + feats_to_use = featgenes) + +screePlot(visium_brain, ncp = 30) +``` + + +![](images/visium_mouse_brain/3-screePlot.png){width="50.0%"} + + +```{r, eval=FALSE} +dimPlot2D(gobject = visium_brain,dim_reduction_to_use = "pca") +``` + + +![](images/visium_mouse_brain/4-PCA.png){width="50.0%"} + + +```{r, eval=FALSE} +## run UMAP and tSNE on PCA space (default) +visium_brain <- runUMAP(visium_brain, dimensions_to_use = 1:10) +plotUMAP(gobject = visium_brain) +``` + + +![](images/visium_mouse_brain/5-UMAP.png){width="50.0%"} + + +```{r, eval=FALSE} +visium_brain <- runtSNE(visium_brain, dimensions_to_use = 1:10) +plotTSNE(gobject = visium_brain) +``` + + +![](images/visium_mouse_brain/6-tSNE.png){width="50.0%"} + +# Part 4: Cluster + + +```{r, eval=FALSE} +## sNN network (default) +visium_brain <- createNearestNetwork(gobject = visium_brain, dimensions_to_use = 1:10, k = 15) + +## Leiden clustering +visium_brain <- doLeidenCluster(gobject = visium_brain, resolution = 0.4, n_iterations = 1000) + +plotUMAP(gobject = visium_brain, + cell_color = 'leiden_clus', show_NN_network = T, point_size = 2.5) +``` + + +![](images/visium_mouse_brain/7-UMAP.png){width="50.0%"} + + +```{r, eval=FALSE} +# spatial and dimension plots +spatDimPlot(gobject = visium_brain, cell_color = 'leiden_clus', + dim_point_size = 2, spat_point_size = 2.5) +``` + + +![](images/visium_mouse_brain/8-spatDimPlot2D.png){width="50.0%"} + + +```{r, eval=FALSE} +spatDimPlot(gobject = visium_brain, cell_color = 'nr_feats', color_as_factor = F, + dim_point_size = 2, spat_point_size = 2.5) +``` + + +![](images/visium_mouse_brain/9-spatDimPlot2D.png){width="50.0%"} + + +```{r, eval=FALSE} +# dimension plots grouped by cluster +spatPlot2D(visium_brain, cell_color = 'leiden_clus', + coord_fix_ratio = 1) +``` + + +![](images/visium_mouse_brain/10-spatPlot2D.png){width="50.0%"} + +Plot with group by: + + +```{r, eval=FALSE} +spatPlot2D(visium_brain, cell_color = 'leiden_clus', + group_by = 'leiden_clus', coord_fix_ratio = 1, + cow_n_col = 6, show_legend = F, + save_param = list(base_width = 14, base_height = 14)) +``` + + +![](images/visium_mouse_brain/11-spatPlot2D.png){width="50.0%"} + +Highlight one or more groups: + + +```{r, eval=FALSE} +spatPlot2D(visium_brain, cell_color = 'leiden_clus', + select_cell_groups = '8', coord_fix_ratio = 1, show_other_cells = TRUE, + cell_color_code = c('8' = 'red'), other_cell_color = "grey", other_point_size = 1.5, + save_param = list(base_width = 7, base_height = 7)) +``` + + +![](images/visium_mouse_brain/12-spatPlot2D.png){width="50.0%"} + +# Part 5: subset data + + +```{r, eval=FALSE} +# create and show subset +DG_subset = subsetGiottoLocs(visium_brain, + x_max = 6500, x_min = 3000, + y_max = -2500, y_min = -5500, + return_gobject = TRUE) + +spatDimPlot(gobject = DG_subset, + cell_color = 'leiden_clus', spat_point_size = 5) +``` + + +![](images/visium_mouse_brain/13-spatDimPlot2D.png){width="50.0%"} + +# Part 6: marker gene detection for clusters + + +```{r, eval=FALSE} +## ------------------ ## +## Gini markers +gini_markers_subclusters = findMarkers_one_vs_all(gobject = visium_brain, + method = 'gini', + expression_values = 'normalized', + cluster_column = 'leiden_clus', + min_feats = 20, + min_expr_gini_score = 0.5, + min_det_gini_score = 0.5) +topgenes_gini = gini_markers_subclusters[, head(.SD, 2), by = 'cluster']$feats + +# violinplot +violinPlot(visium_brain, feats = unique(topgenes_gini), cluster_column = 'leiden_clus', + strip_text = 8, strip_position = 'right', + save_param = list(base_width = 5, base_height = 10)) +``` + + +![](images/visium_mouse_brain/14-violinPlot.png){width="50.0%"} + + +```{r, eval=FALSE} +# cluster heatmap +plotMetaDataHeatmap(visium_brain, selected_feats = unique(topgenes_gini), + metadata_cols = c('leiden_clus'), + x_text_size = 10, y_text_size = 10) +``` + + +![](images/visium_mouse_brain/15-plotMetaDataHeatmap.png){width="50.0%"} + + +```{r, eval=FALSE} +# umap plots +dimFeatPlot2D(visium_brain, expression_values = 'scaled', + feats = gini_markers_subclusters[, head(.SD, 1), by = 'cluster']$feats, + cow_n_col = 4, point_size = 0.75, + save_param = list(base_width = 8, base_height = 8)) +``` + + +![](images/visium_mouse_brain/16-dimFeatPlot2D.png){width="50.0%"} + + +```{r, eval=FALSE} +## ------------------ ## +# Scran Markers +scran_markers_subclusters = findMarkers_one_vs_all(gobject = visium_brain, + method = 'scran', + expression_values = 'normalized', + cluster_column = 'leiden_clus') +topgenes_scran = scran_markers_subclusters[, head(.SD, 2), by = 'cluster']$feats + +# violinplot +violinPlot(visium_brain, feats = unique(topgenes_scran), cluster_column = 'leiden_clus', + strip_text = 10, strip_position = 'right', + save_param = list(base_width = 5)) +``` + + +![](images/visium_mouse_brain/17-violinPlot.png){width="50.0%"} + + +```{r, eval=FALSE} +# cluster heatmap +plotMetaDataHeatmap(visium_brain, selected_feats = topgenes_scran, + metadata_cols = c('leiden_clus')) +``` + + +![](images/visium_mouse_brain/18-plotMetaDataHeatmap.png){width="50.0%"} + + +```{r, eval=FALSE} +# umap plots +dimFeatPlot2D(visium_brain, expression_values = 'scaled', + feats = scran_markers_subclusters[, head(.SD, 1), by = 'cluster']$feats, + cow_n_col = 3, point_size = 1, + save_param = list(base_width = 8, base_height = 8)) +``` + + +![](images/visium_mouse_brain/19-dimFeatPlot2D.png){width="50.0%"} + +# Part 7: Cell type enrichment + +Visium spatial transcriptomics does not provide single-cell resolution, making cell type annotation a harder problem. Giotto provides several ways to calculate enrichment of specific cell-type signature gene lists: + - PAGE + - hypergeometric test + - Rank + - [DWLS + +Deconvolution](https://genomebiology.biomedcentral.com/articles/10.1186/s13059-021-02362-7) Corresponded Single cell dataset can be generated from [here](http://mousebrain.org/). Giotto_SC is processed from the downsampled [Loom](https://satijalab.org/loomr/loomr_tutorial) file and can also be downloaded from getSpatialDataset. + + +```{r, eval=FALSE} +# download data to results directory #### +# if wget is installed, set method = 'wget' +# if you run into authentication issues with wget, then add " extra = '--no-check-certificate' " +getSpatialDataset(dataset = 'scRNA_mouse_brain', directory = results_folder) + +sc_expression = paste0(results_folder, "/brain_sc_expression_matrix.txt.gz") +sc_metadata = paste0(results_folder,"/brain_sc_metadata.csv") + +giotto_SC <- createGiottoObject( + expression = sc_expression, + instructions = instrs +) + +giotto_SC <- addCellMetadata(giotto_SC, + new_metadata = data.table::fread(sc_metadata)) + +giotto_SC<- normalizeGiotto(giotto_SC) +``` + + +## 7.1 PAGE enrichment + + +```{r, eval=FALSE} +# Create PAGE matrix +# PAGE matrix should be a binary matrix with each row represent a gene marker and each column represent a cell type +# There are several ways to create PAGE matrix +# 1.1 create binary matrix of cell signature genes +# small example # +gran_markers = c("Nr3c2", "Gabra5", "Tubgcp2", "Ahcyl2", + "Islr2", "Rasl10a", "Tmem114", "Bhlhe22", + "Ntf3", "C1ql2") + +oligo_markers = c("Efhd1", "H2-Ab1", "Enpp6", "Ninj2", + "Bmp4", "Tnr", "Hapln2", "Neu4", + "Wfdc18", "Ccp110") + +di_mesench_markers = c("Cartpt", "Scn1a", "Lypd6b", "Drd5", + "Gpr88", "Plcxd2", "Cpne7", "Pou4f1", + "Ctxn2", "Wnt4") + +PAGE_matrix_1 = makeSignMatrixPAGE(sign_names = c('Granule_neurons', + 'Oligo_dendrocytes', + 'di_mesenchephalon'), + sign_list = list(gran_markers, + oligo_markers, + di_mesench_markers)) + + + +# ---- + +# 1.2 [shortcut] fully pre-prepared matrix for all cell types +sign_matrix_path = system.file("extdata", "sig_matrix.txt", package = 'Giotto') +brain_sc_markers = data.table::fread(sign_matrix_path) +PAGE_matrix_2 = as.matrix(brain_sc_markers[,-1]) +rownames(PAGE_matrix_2) = brain_sc_markers$Event + + +# --- + +# 1.3 make PAGE matrix from single cell dataset +markers_scran = findMarkers_one_vs_all(gobject=giotto_SC, method="scran", + expression_values="normalized", cluster_column = "Class", min_feats=3) +top_markers <- markers_scran[, head(.SD, 10), by="cluster"] +celltypes<-levels(factor(markers_scran$cluster)) +sign_list<-list() +for (i in 1:length(celltypes)){ + sign_list[[i]]<-top_markers[which(top_markers$cluster == celltypes[i]),]$feats +} + +PAGE_matrix_3 = makeSignMatrixPAGE(sign_names = celltypes, + sign_list = sign_list) + +# 1.4 enrichment test with PAGE + +# runSpatialEnrich() can also be used as a wrapper for all currently provided enrichment options +visium_brain = runPAGEEnrich(gobject = visium_brain, sign_matrix = PAGE_matrix_2) + +# 1.5 heatmap of enrichment versus annotation (e.g. clustering result) +cell_types_PAGE = colnames(PAGE_matrix_2) +plotMetaDataCellsHeatmap(gobject = visium_brain, + metadata_cols = 'leiden_clus', + value_cols = cell_types_PAGE, + spat_enr_names = 'PAGE', + x_text_size = 8, + y_text_size = 8) +``` + + +![](images/visium_mouse_brain/20-plotMetaDataCellsHeatmap.png){width="50.0%"} + + +```{r, eval=FALSE} +# 1.6 visualizations +spatCellPlot2D(gobject = visium_brain, + spat_enr_names = 'PAGE', + cell_annotation_values = cell_types_PAGE[1:4], + cow_n_col = 2,coord_fix_ratio = 1, point_size = 1.25, show_legend = T) +``` + + +![](images/visium_mouse_brain/21-spatCellPlot2D.png){width="50.0%"} + + +```{r, eval=FALSE} +spatDimCellPlot2D(gobject = visium_brain, + spat_enr_names = 'PAGE', + cell_annotation_values = cell_types_PAGE[1:4], + cow_n_col = 1, spat_point_size = 1, + plot_alignment = 'horizontal', + save_param = list(base_width=7, base_height=10)) +``` + + +![](images/visium_mouse_brain/22-spatDimCellPlot2D.png){width="50.0%"} + +## 7.2 HyperGeometric test + + +```{r, eval=FALSE} +visium_brain = runHyperGeometricEnrich(gobject = visium_brain, + expression_values = "normalized", + sign_matrix = PAGE_matrix_2) + +cell_types_HyperGeometric = colnames(PAGE_matrix_2) +spatCellPlot(gobject = visium_brain, + spat_enr_names = 'hypergeometric', + cell_annotation_values = cell_types_HyperGeometric[1:4], + cow_n_col = 2,coord_fix_ratio = NULL, point_size = 1.75) +``` + + +![](images/visium_mouse_brain/23-spatCellPlot2D.png){width="50.0%"} + +## 7.3 Rank Enrichment + + +```{r, eval=FALSE} +# Create rank matrix, not that rank matrix is different from PAGE +# A count matrix and a vector for all cell labels will be needed +rank_matrix = makeSignMatrixRank(sc_matrix = get_expression_values(giotto_SC,values = "normalized",output = "matrix"), + sc_cluster_ids = pDataDT(giotto_SC)$Class) +colnames(rank_matrix)<-levels(factor(pDataDT(giotto_SC)$Class)) +visium_brain = runRankEnrich(gobject = visium_brain, sign_matrix = rank_matrix,expression_values = "normalized") + +# Plot Rank enrichment result +spatCellPlot2D(gobject = visium_brain, + spat_enr_names = 'rank', + cell_annotation_values = colnames(rank_matrix)[1:4], + cow_n_col = 2,coord_fix_ratio = 1, point_size = 1, + save_param = list(save_name = "spat_enr_Rank_plot")) +``` + + +![](images/visium_mouse_brain/vignette_220426/spat_enr_Rank_plot.png){width="50.0%"} + +## 7.4 DWLS spatial deconvolution + + +```{r, eval=FALSE} +# Create DWLS matrix, not that DWLS matrix is different from PAGE and rank +# A count matrix a vector for a list of gene signatures and a vector for all cell labels will be needed +DWLS_matrix<-makeSignMatrixDWLSfromMatrix(matrix = get_expression_values(giotto_SC,values = "normalized",output = "matrix"), + cell_type = pDataDT(giotto_SC)$Class, + sign_gene = top_markers$feats) +visium_brain = runDWLSDeconv(gobject = visium_brain, sign_matrix = DWLS_matrix) + + +# Plot DWLS deconvolution result +spatCellPlot2D(gobject = visium_brain, + spat_enr_names = 'DWLS', + cell_annotation_values = levels(factor(pDataDT(giotto_SC)$Class))[1:4], + cow_n_col = 2,coord_fix_ratio = 1, point_size = 1, + save_param = list(save_name = "DWLS_plot")) +``` + + +![](images/visium_mouse_brain/vignette_220426/DWLS_plot.png){width="50.0%"} + + +```{r, eval=FALSE} +# Plot DWLS deconvolution result with Pie plots + spatDeconvPlot(visium_brain, + show_image = T, + radius = 50, + save_param = list(save_name = "spat_DWLS_pie_plot")) +``` + + +![](images/visium_mouse_brain/vignette_220426/spat_DWLS_pie_plot.png){width="50.0%"} + +# Part 8: Spatial Grid + + +```{r, eval=FALSE} +visium_brain <- createSpatialGrid(gobject = visium_brain, + sdimx_stepsize = 400, + sdimy_stepsize = 400, + minimum_padding = 0) + +showGiottoSpatGrids(visium_brain) + +spatPlot2D(visium_brain, cell_color = 'leiden_clus', show_grid = T, + grid_color = 'red', spatial_grid_name = 'spatial_grid') +``` + + +![](images/visium_mouse_brain/24-spatPlot2D.png){width="50.0%"} + +# Part 9: spatial network + + +```{r, eval=FALSE} +visium_brain <- createSpatialNetwork(gobject = visium_brain, + method = 'kNN', k = 5, + maximum_distance_knn = 400, + name = 'spatial_network') + +showGiottoSpatNetworks(visium_brain) + +spatPlot2D(gobject = visium_brain, show_network= T, + network_color = 'blue', spatial_network_name = 'spatial_network') +``` + + +![](images/visium_mouse_brain/25-spatPlot2D.png){width="50.0%"} + +# Part 10: Spatial Genes + + +```{r, eval=FALSE} +## rank binarization +ranktest = binSpect(visium_brain, bin_method = 'rank', + calc_hub = T, hub_min_int = 5, + spatial_network_name = 'spatial_network') + +spatFeatPlot2D(visium_brain, expression_values = 'scaled', + feats = ranktest$feats[1:6], cow_n_col = 2, point_size = 1.5) +``` + + +![](images/visium_mouse_brain/26-spatFeatPlot2D.png){width="50.0%"} + +# Part 11: Spatial Co-Expression modules + + +```{r, eval=FALSE} +# cluster the top 500 spatial genes into 20 clusters +ext_spatial_genes = ranktest[1:1500,]$feats + +# here we use existing detectSpatialCorGenes function to calculate pairwise distances between genes (but set network_smoothing=0 to use default clustering) +spat_cor_netw_DT = detectSpatialCorFeats(visium_brain, + method = 'network', + spatial_network_name = 'spatial_network', + subset_feats = ext_spatial_genes) + +# 2. identify most similar spatially correlated genes for one gene +top10_genes = showSpatialCorFeats(spat_cor_netw_DT, feats = 'Ptprn', show_top_feats = 10) + +spatFeatPlot2D(visium_brain, expression_values = 'scaled', + feats = top10_genes$variable[1:4], point_size = 3) +``` + + +![](images/visium_mouse_brain/27-spatFeatPlot2D.png){width="50.0%"} + + +```{r, eval=FALSE} +# cluster spatial genes +spat_cor_netw_DT = clusterSpatialCorFeats(spat_cor_netw_DT, name = 'spat_netw_clus', k = 20) + +# visualize clusters +heatmSpatialCorFeats(visium_brain, + spatCorObject = spat_cor_netw_DT, + use_clus_name = 'spat_netw_clus', + heatmap_legend_param = list(title = NULL), + save_param = list(base_height = 6, base_width = 8, units = 'cm')) +``` + + +![](images/visium_mouse_brain/28-heatmSpatialCorFeats.png){width="50.0%"} + + +```{r, eval=FALSE} +# 4. rank spatial correlated clusters and show genes for selected clusters +netw_ranks = rankSpatialCorGroups(visium_brain, + spatCorObject = spat_cor_netw_DT, use_clus_name = 'spat_netw_clus', + save_param = list( base_height = 3, base_width = 5)) + + + +top_netw_spat_cluster = showSpatialCorFeats(spat_cor_netw_DT, use_clus_name = 'spat_netw_clus', + selected_clusters = 6, show_top_feats = 1) +``` + + +![](images/visium_mouse_brain/29-rankSpatialCorGroups.png){width="50.0%"} + + +```{r, eval=FALSE} +# 5. create metagene enrichment score for clusters +cluster_genes_DT = showSpatialCorFeats(spat_cor_netw_DT, use_clus_name = 'spat_netw_clus', show_top_feats = 1) +cluster_genes = cluster_genes_DT$clus; names(cluster_genes) = cluster_genes_DT$feat_ID + +visium_brain = createMetafeats(visium_brain, feat_clusters = cluster_genes, name = 'cluster_metagene') + +#showGiottoSpatEnrichments(visium_brain) + +spatCellPlot(visium_brain, + spat_enr_names = 'cluster_metagene', + cell_annotation_values = netw_ranks$clusters, + point_size = 1, cow_n_col = 5, save_param = list(base_width = 15)) +``` + + +![](images/visium_mouse_brain/30-spatCellPlot2D.png){width="50.0%"} + +# Part 12: Spatially informed clusters + + +```{r, eval=FALSE} +# top 30 genes per spatial co-expression cluster +table(spat_cor_netw_DT$cor_clusters$spat_netw_clus) +coexpr_dt = data.table::data.table(genes = names(spat_cor_netw_DT$cor_clusters$spat_netw_clus), + cluster = spat_cor_netw_DT$cor_clusters$spat_netw_clus) +data.table::setorder(coexpr_dt, cluster) +top30_coexpr_dt = coexpr_dt[, head(.SD, 30) , by = cluster] +my_spatial_genes <- top30_coexpr_dt$genes + + + +visium_brain <- runPCA(gobject = visium_brain, + feats_to_use = my_spatial_genes, + name = 'custom_pca') +visium_brain <- runUMAP(visium_brain, dim_reduction_name = 'custom_pca', dimensions_to_use = 1:20, + name = 'custom_umap') +visium_brain <- createNearestNetwork(gobject = visium_brain, + dim_reduction_name = 'custom_pca', + dimensions_to_use = 1:20, k = 5, + name = 'custom_NN') +visium_brain <- doLeidenCluster(gobject = visium_brain, network_name = 'custom_NN', + resolution = 0.15, n_iterations = 1000, + name = 'custom_leiden') + + +cell_meta = pDataDT(visium_brain) +cell_clusters = unique(cell_meta$custom_leiden) + +selected_colors = getDistinctColors(length(cell_clusters)) +names(selected_colors) = cell_clusters + +spatPlot2D(visium_brain, cell_color = 'custom_leiden', cell_color_code = selected_colors, coord_fix_ratio = 1) +``` + + +![](images/visium_mouse_brain/31-spatPlot2D.png){width="50.0%"} + + +```{r, eval=FALSE} +plotUMAP(gobject = visium_brain, cell_color = 'custom_leiden', cell_color_code = selected_colors, point_size = 1.5) +``` + + +![](images/visium_mouse_brain/32-UMAP.png){width="50.0%"} + +# Part 13: Spatial domains with HMRF + + +```{r, eval=FALSE} +# do HMRF with different betas on top 30 genes per spatial co-expression module +hmrf_folder = paste0(results_folder,'/','11_HMRF/') +if(!file.exists(hmrf_folder)) dir.create(hmrf_folder, recursive = T) + +HMRF_spatial_genes = doHMRF(gobject = visium_brain, + expression_values = 'scaled', + spatial_genes = my_spatial_genes, k = 20, + spatial_network_name="spatial_network", + betas = c(0, 10, 5), + output_folder = paste0(hmrf_folder, '/', 'Spatial_genes/SG_topgenes_k20_scaled')) + +visium_brain = addHMRF(gobject = visium_brain, HMRFoutput = HMRF_spatial_genes, + k = 20, betas_to_add = c(0, 10, 20, 30, 40), + hmrf_name = 'HMRF') + +spatPlot2D(gobject = visium_brain, cell_color = 'HMRF_k20_b.40') +``` + + +![](images/visium_mouse_brain/33-spatPlot2D.png){width="50.0%"} diff --git a/vignettes/visium_mouse_kidney.Rmd b/vignettes/visium_mouse_kidney.Rmd new file mode 100644 index 000000000..d693c5b84 --- /dev/null +++ b/vignettes/visium_mouse_kidney.Rmd @@ -0,0 +1,496 @@ +--- +title: "Visium Mouse Kidney" +date: 2021-08-30 +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Visium Mouse Kidney} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + + +Warning: This tutorial was written with Giotto version 2.0.0.9046.This is an older version and results could be slightly different + +```{r, eval=FALSE} +# Ensure Giotto Suite is installed. +if(!"Giotto" %in% installed.packages()) { + devtools::install_github("drieslab/Giotto@suite") +} + +# Ensure GiottoData, a small, helper module for tutorials, is installed. +if(!"GiottoData" %in% installed.packages()) { + devtools::install_github("drieslab/GiottoData") +} +# Ensure the Python environment for Giotto has been installed. +library(Giotto) +genv_exists = checkGiottoEnvironment() +if(!genv_exists){ + # The following command need only be run once to install the Giotto environment. + installGiottoEnvironment() +} +``` + + +```{r, eval=FALSE} +library(GiottoData) + +# 1. set working directory +results_folder = '/path/to/directory/' + +# 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. +``` + + +# Dataset explanation + +[10X genomics](https://www.10xgenomics.com/spatial-transcriptomics/) recently launched a new platform to obtain spatial expression data using a Visium Spatial Gene Expression slide. + +The Visium kidney data to run this tutorial can be found [here](https://support.10xgenomics.com/spatial-gene-expression/datasets/1.0.0/V1_Mouse_Kidney) + +Visium technology: + +![](images/general_figs/visium_technology.png) + +High resolution png from original tissue: + +![](images/general_figs/mouse_kidney_highres.png) + +# 1. Giotto global instructions and preparations + +```{r, eval=FALSE} +## create instructions +instrs = createGiottoInstructions(save_dir = results_folder, + save_plot = TRUE, + show_plot = FALSE, + python_path = python_path) + +## provide path to visium folder +data_path = '/path/to/Kidney_data/' +``` + +# 2. Create Giotto object & process data + +```{r, eval=FALSE} +## directly from visium folder +visium_kidney = createGiottoVisiumObject(visium_dir = data_path, + expr_data = 'raw', + png_name = 'tissue_lowres_image.png', + gene_column_index = 2, + instructions = instrs) + +## check metadata +pDataDT(visium_kidney) + +# check available image names +showGiottoImageNames(visium_kidney) # "image" is the default name + +## show aligned image +spatPlot(gobject = visium_kidney, cell_color = 'in_tissue', show_image = T, point_alpha = 0.7) +``` + +![](images/visium_mouse_kidney/0-spatPlot2D.png) + +```{r, eval=FALSE} +## subset on spots that were covered by tissue +metadata = pDataDT(visium_kidney) +in_tissue_barcodes = metadata[in_tissue == 1]$cell_ID +visium_kidney = subsetGiotto(visium_kidney, cell_ids = in_tissue_barcodes) + +## filter +visium_kidney <- filterGiotto(gobject = visium_kidney, + expression_threshold = 1, + feat_det_in_min_cells = 50, + min_det_feats_per_cell = 1000, + expression_values = c('raw'), + verbose = T) + +## normalize +visium_kidney <- normalizeGiotto(gobject = visium_kidney, scalefactor = 6000, verbose = T) + +## add gene & cell statistics +visium_kidney <- addStatistics(gobject = visium_kidney) + +## visualize +spatPlot2D(gobject = visium_kidney, show_image = T, point_alpha = 0.7) +``` + +![](images/visium_mouse_kidney/1-spatPlot2D.png) + +```{r, eval=FALSE} +spatPlot2D(gobject = visium_kidney, show_image = T, point_alpha = 0.7, + cell_color = 'nr_feats', color_as_factor = F) +``` + +![](images/visium_mouse_kidney/2-spatPlot2D.png) + +# 3. Dimension reduction + +```{r, eval=FALSE} +## highly variable features (genes) +visium_kidney <- calculateHVF(gobject = visium_kidney) +``` + +![](images/visium_mouse_kidney/3-HVFplot.png) + +```{r, eval=FALSE} +## run PCA on expression values (default) +visium_kidney <- runPCA(gobject = visium_kidney) +screePlot(visium_kidney, ncp = 30) +``` + +![](images/visium_mouse_kidney/4-screePlot.png) + +```{r, eval=FALSE} +plotPCA(gobject = visium_kidney) +``` + +![](images/visium_mouse_kidney/5-PCA.png) + +```{r, eval=FALSE} +## run UMAP and tSNE on PCA space (default) +visium_kidney <- runUMAP(visium_kidney, dimensions_to_use = 1:10) +plotUMAP(gobject = visium_kidney) +``` + +![](images/visium_mouse_kidney/6-UMAP.png) + +```{r, eval=FALSE} +visium_kidney <- runtSNE(visium_kidney, dimensions_to_use = 1:10) +plotTSNE(gobject = visium_kidney) +``` + +![](images/visium_mouse_kidney/7-tSNE.png) + +# 4. Clustering + +```{r, eval=FALSE} +## sNN network (default) +visium_kidney <- createNearestNetwork(gobject = visium_kidney, dimensions_to_use = 1:10, k = 15) +## Leiden clustering +visium_kidney <- doLeidenCluster(gobject = visium_kidney, resolution = 0.4, n_iterations = 1000) +plotUMAP(gobject = visium_kidney, cell_color = 'leiden_clus', show_NN_network = T, point_size = 2.5) +``` + +![](images/visium_mouse_kidney/8-UMAP.png) + +# 5. Co-visualize + +```{r, eval=FALSE} +# expression and spatial +spatDimPlot(gobject = visium_kidney, cell_color = 'leiden_clus', + dim_point_size = 2, spat_point_size = 2.5) +``` + +![](images/visium_mouse_kidney/9-spatDimPlot2D.png) + +```{r, eval=FALSE} +spatDimPlot(gobject = visium_kidney, cell_color = 'nr_feats', color_as_factor = F, + dim_point_size = 2, spat_point_size = 2.5) +``` + +![](images/visium_mouse_kidney/10-spatDimPlot2D.png) + +# 6. Cell type marker gene detection + +## gini + +```{r, eval=FALSE} +gini_markers_subclusters = findMarkers_one_vs_all(gobject = visium_kidney, + method = 'gini', + expression_values = 'normalized', + cluster_column = 'leiden_clus', + min_featss = 20, + min_expr_gini_score = 0.5, + min_det_gini_score = 0.5) +topgenes_gini = gini_markers_subclusters[, head(.SD, 2), by = 'cluster']$feats + +# violinplot +violinPlot(visium_kidney, feats = unique(topgenes_gini), cluster_column = 'leiden_clus', + strip_text = 8, strip_position = 'right') +``` + +![](images/visium_mouse_kidney/11-violinPlot.png) + +```{r, eval=FALSE} +violinPlot(visium_kidney, feats = unique(topgenes_gini), cluster_column = 'leiden_clus', + strip_text = 8, strip_position = 'right', + save_param = c(save_name = '11-z1-violinplot_gini', base_width = 5, base_height = 10)) +``` + +![](images/visium_mouse_kidney/11-z1-violinplot_gini.png) + +```{r, eval=FALSE} +# cluster heatmap +plotMetaDataHeatmap(visium_kidney, + selected_feats = topgenes_gini, + metadata_cols = c('leiden_clus'), + x_text_size = 10, y_text_size = 10) +``` + +![](images/visium_mouse_kidney/12-plotMetaDataHeatmap.png) + +```{r, eval=FALSE} +# umap plots +dimFeatPlot2D(visium_kidney, + expression_values = 'scaled', + feats = gini_markers_subclusters[, head(.SD, 1), by = 'cluster']$feats, + cow_n_col = 3, point_size = 1) +``` + +![](images/visium_mouse_kidney/13-dimFeatPlot2D.png) + +## scran + +```{r, eval=FALSE} +scran_markers_subclusters = findMarkers_one_vs_all(gobject = visium_kidney, + method = 'scran', + expression_values = 'normalized', + cluster_column = 'leiden_clus') +topgenes_scran = scran_markers_subclusters[, head(.SD, 2), by = 'cluster']$feats + +violinPlot(visium_kidney, feats = unique(topgenes_scran), + cluster_column = 'leiden_clus', + strip_text = 10, strip_position = 'right') +``` + +![](images/visium_mouse_kidney/14-violinPlot.png) + +```{r, eval=FALSE} +# cluster heatmap +plotMetaDataHeatmap(visium_kidney, selected_feats = topgenes_scran, + metadata_cols = c('leiden_clus')) +``` + +![](images/visium_mouse_kidney/15-plotMetaDataHeatmap.png) + +```{r, eval=FALSE} +# umap plots +dimFeatPlot2D(visium_kidney, expression_values = 'scaled', + feats = scran_markers_subclusters[, head(.SD, 1), by = 'cluster']$feats, + cow_n_col = 3, point_size = 1) +``` + +![](images/visium_mouse_kidney/16-dimFeatPlot2D.png) + +# 7. cell-type annotation + +Visium spatial transcriptomics does not provide single-cell resolution, making cell type annotation a harder problem. Giotto provides 3 ways to calculate enrichment of specific cell-type signature gene list: + +- PAGE +- rank +- hypergeometric test + +# 8. Spatial grid + +```{r, eval=FALSE} +visium_kidney <- createSpatialGrid(gobject = visium_kidney, + sdimx_stepsize = 400, + sdimy_stepsize = 400, + minimum_padding = 0) +spatPlot(visium_kidney, cell_color = 'leiden_clus', show_grid = T, + grid_color = 'red', spatial_grid_name = 'spatial_grid') +``` + +![](images/visium_mouse_kidney/17-spatPlot2D.png) + +# 9. spatial network + +```{r, eval=FALSE} +## delaunay network: stats + creation +plotStatDelaunayNetwork(gobject = visium_kidney, maximum_distance = 400) +``` + +![](images/visium_mouse_kidney/18-plotStatDelaunayNetwork.png) + +```{r, eval=FALSE} +visium_kidney = createSpatialNetwork(gobject = visium_kidney, minimum_k = 0) +showNetworks(visium_kidney) +spatPlot(gobject = visium_kidney, show_network = T, + network_color = 'blue', spatial_network_name = 'Delaunay_network') +``` + +![](images/visium_mouse_kidney/19-spatPlot2D.png) + +# 10. Spatial genes + +## Spatial genes + +```{r, eval=FALSE} +## kmeans binarization +kmtest = binSpect(visium_kidney) +spatFeatPlot2D(visium_kidney, expression_values = 'scaled', + feats = kmtest$feats[1:6], cow_n_col = 2, point_size = 1.5) +``` + +![](images/visium_mouse_kidney/20-spatFeatPlot2D.png) + +```{r, eval=FALSE} +## rank binarization +ranktest = binSpect(visium_kidney, bin_method = 'rank') +spatFeatPlot2D(visium_kidney, expression_values = 'scaled', + feats = ranktest$feats[1:6], cow_n_col = 2, point_size = 1.5) +``` + +![](images/visium_mouse_kidney/21-spatFeatPlot2D.png) + +## Spatial co-expression patterns + +```{r, eval=FALSE} +## spatially correlated genes ## +ext_spatial_genes = kmtest[1:500]$feats + +# 1. calculate gene spatial correlation and single-cell correlation +# create spatial correlation object +spat_cor_netw_DT = detectSpatialCorFeats(visium_kidney, + method = 'network', + spatial_network_name = 'Delaunay_network', + subset_feats = ext_spatial_genes) + +# 2. identify most similar spatially correlated genes for one gene +Napsa_top10_genes = showSpatialCorFeats(spat_cor_netw_DT, feats = 'Napsa', show_top_feats = 10) + +spatFeatPlot2D(visium_kidney, expression_values = 'scaled', + feats = c('Napsa', 'Kap', 'Defb29', 'Prdx1'), point_size = 3) +``` + +![](images/visium_mouse_kidney/22-spatFeatPlot2D.png) + +```{r, eval=FALSE} +# 3. cluster correlated genes & visualize +spat_cor_netw_DT = clusterSpatialCorFeats(spat_cor_netw_DT, + name = 'spat_netw_clus', k = 8) + +heatmSpatialCorFeats(visium_kidney, + spatCorObject = spat_cor_netw_DT, + use_clus_name = 'spat_netw_clus', + save_param = c(save_name = '22-z1-heatmap_correlated_genes', + save_format = 'pdf', + base_height = 6, + base_width = 8, units = 'cm'), + heatmap_legend_param = list(title = NULL)) +``` + +![](images/visium_mouse_kidney/22-z1-heatmap_correlated_genes.pdf) + +```{r, eval=FALSE} +# 4. rank spatial correlated clusters and show genes for selected clusters +netw_ranks = rankSpatialCorGroups(visium_kidney, + spatCorObject = spat_cor_netw_DT, + use_clus_name = 'spat_netw_clus', + save_param = c(save_name = '22-z2-rank_correlated_groups', + base_height = 3, + base_width = 5)) +``` + +![](images/visium_mouse_kidney/22-z2-rank_correlated_groups.png) + +```{r, eval=FALSE} +top_netw_spat_cluster = showSpatialCorFeats(spat_cor_netw_DT, + use_clus_name = 'spat_netw_clus', + selected_clusters = 6, + show_top_feats = 1) + +# 5. create metagene enrichment score for clusters +cluster_genes_DT = showSpatialCorFeats(spat_cor_netw_DT, + use_clus_name = 'spat_netw_clus', + show_top_feats = 1) +cluster_genes = cluster_genes_DT$clus +names(cluster_genes) = cluster_genes_DT$feat_ID + +visium_kidney = createMetafeats(visium_kidney, + feat_clusters = cluster_genes, + name = 'cluster_metagene') + +showGiottoSpatEnrichments(visium_kidney) + +spatCellPlot(visium_kidney, + spat_enr_names = 'cluster_metagene', + cell_annotation_values = netw_ranks$clusters, + point_size = 1.5, cow_n_col = 4) +``` + +![](images/visium_mouse_kidney/23-spatCellPlot2D.png) + +# 11. HMRF domains + +```{r, eval=FALSE} +# HMRF requires a fully connected network! +visium_kidney = createSpatialNetwork(gobject = visium_kidney, + minimum_k = 2, + name = 'Delaunay_full') + +# spatial genes +my_spatial_genes <- kmtest[1:100]$feats + +# do HMRF with different betas +hmrf_folder = paste0(results_folder,'/','HMRF_results/') +if(!file.exists(hmrf_folder)) dir.create(hmrf_folder, recursive = T) + +# if Rscript is not found, you might have to create a symbolic link, e.g. +# cd /usr/local/bin +# sudo ln -s /Library/Frameworks/R.framework/Resources/Rscript Rscript +HMRF_spatial_genes = doHMRF(gobject = visium_kidney, + expression_values = 'scaled', + spatial_network_name = 'Delaunay_full', + spatial_genes = my_spatial_genes, + k = 5, + betas = c(0, 1, 6), + output_folder = paste0(hmrf_folder, '/', 'Spatial_genes/SG_topgenes_k5_scaled')) +``` + + + +```{r, eval=FALSE} +## alternative way to view HMRF results +#results = writeHMRFresults(gobject = ST_test, +# HMRFoutput = HMRF_spatial_genes, +# k = 5, betas_to_view = seq(0, 25, by = 5)) +#ST_test = addCellMetadata(ST_test, new_metadata = results, by_column = T, column_cell_ID = 'cell_ID') + + +## add HMRF of interest to giotto object +visium_kidney = addHMRF(gobject = visium_kidney, + HMRFoutput = HMRF_spatial_genes, + k = 5, betas_to_add = c(0, 2), + hmrf_name = 'HMRF') + +## visualize +spatPlot(gobject = visium_kidney, + cell_color = 'HMRF_k5_b.0', + point_size = 5) +``` + +![](images/visium_mouse_kidney/24-spatPlot2D.png) + +```{r, eval=FALSE} +spatPlot(gobject = visium_kidney, + cell_color = 'HMRF_k5_b.2', + point_size = 5) +``` + +![](images/visium_mouse_kidney/25-spatPlot2D.png) + +# Export and create Giotto Viewers + +```{r, eval=FALSE} +# check which annotations are available +combineMetadata(visium_kidney) + +# select annotations, reductions and expression values to view in Giotto Viewer +viewer_folder = paste0(results_folder, '/', 'mouse_visium_kidney_viewer') + +exportGiottoViewer(gobject = visium_kidney, + output_directory = viewer_folder, + factor_annotations = c('in_tissue', + 'leiden_clus'), + numeric_annotations = c('nr_feats'), + dim_reductions = c('tsne', 'umap'), + dim_reduction_names = c('tsne', 'umap'), + expression_values = 'scaled', + expression_rounding = 2, + overwrite_dir = T) +``` + diff --git a/vignettes/visium_prostate_integration.Rmd b/vignettes/visium_prostate_integration.Rmd new file mode 100644 index 000000000..40c9a44da --- /dev/null +++ b/vignettes/visium_prostate_integration.Rmd @@ -0,0 +1,714 @@ +--- +title: "Visium Prostate Integration" +date: 5/5/23 +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Visium Prostate Integration} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + + +# 1 Start Giotto + + +```{r, eval=FALSE} +# Ensure Giotto Suite is installed +if(!"Giotto" %in% installed.packages()) { + devtools::install_github("drieslab/Giotto@suite") +} +library(Giotto) + +# Ensure Giotto Data is installed +if(!"GiottoData" %in% installed.packages()) { + devtools::install_github("drieslab/GiottoData") +} +library(GiottoData) + +# 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, eval=FALSE} +# 1. set working directory +results_directory = getwd() + +# 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 +if(is.null(python_path)) { + installGiottoEnvironment() +} +``` + + + +```{r, eval=FALSE} +# 3. create giotto instructions +instrs = createGiottoInstructions(save_dir = results_directory, + save_plot = TRUE, + show_plot = TRUE, + python_path = python_path) +``` + + +# 2 Dataset explanation + +[10X genomics](https://www.10xgenomics.com/spatial-transcriptomics/) recently launched a new platform to obtain spatial expression data using a Visium Spatial Gene Expression slide. + +The Visium Cancer Prostate data to run this tutorial can be found [here](https://www.10xgenomics.com/resources/datasets/human-prostate-cancer-adenocarcinoma-with-invasive-carcinoma-ffpe-1-standard-1-3-0) The Visium Normal Prostate data to run this tutorial can be found [here](https://www.10xgenomics.com/resources/datasets/normal-human-prostate-ffpe-1-standard-1-3-0) + +Visium technology: + +![](images/general_figs/visium_technology.png){width="50.0%"} + +High resolution png from original tissue: + +![](images/general_figs/Visium_FFPE_Human_Normal_Prostate_image.png){width="50.0%"} + +![](images/general_figs/Visium_FFPE_Human_Prostate_Cancer_image.png){width="50.0%"} + +# 3 Create Giotto objects and join + + +```{r, eval=FALSE} +# This dataset must be downlaoded manually; please do so and change the path below as appropriate +data_directory <- getwd() + +## obese upper +N_pros = createGiottoVisiumObject( + visium_dir = paste0(data_directory,'/Visium_FFPE_Human_Normal_Prostate'), + expr_data = 'raw', + png_name = 'tissue_lowres_image.png', + gene_column_index = 2, + instructions = instrs +) +``` + + + +```{r, eval=FALSE} +## obese lower +C_pros = createGiottoVisiumObject( + visium_dir = paste0(data_directory,'/Visium_FFPE_Human_Prostate_Cancer/'), + expr_data = 'raw', + png_name = 'tissue_lowres_image.png', + gene_column_index = 2, + instructions = instrs +) +``` + + + +```{r, eval=FALSE} +# join giotto objects +# joining with x_shift has the advantage that you can join both 2D and 3D data +# x_padding determines how much distance is between each dataset +# if x_shift = NULL, then the total shift will be guessed from the giotto image +testcombo = joinGiottoObjects(gobject_list = list(N_pros, C_pros), + gobject_names = c('NP', 'CP'), + join_method = 'shift', x_padding = 1000) +``` + + +```{r, eval=FALSE} +# join info is stored in this slot +# simple list for now +testcombo@join_info +``` + + + +```{r, eval=FALSE} +# check joined Giotto object +fDataDT(testcombo) +``` + + +```{r, eval=FALSE} +pDataDT(testcombo) +``` + + +```{r, eval=FALSE} +showGiottoImageNames(testcombo) +``` + + +```{r, eval=FALSE} +showGiottoSpatLocs(testcombo) +``` + + +```{r, eval=FALSE} +showGiottoExpression(testcombo) +``` + + +```{r, eval=FALSE} +# this plots all the images by list_ID +spatPlot2D(gobject = testcombo, cell_color = 'in_tissue', + show_image = T, image_name = c("NP-image", "CP-image"), + group_by = 'list_ID', point_alpha = 0.5, + save_param = list(save_name = "1a_plot")) +``` + + +![](images/visium_prostate_integration/unnamed-chunk-5-1.png) + + + + +```{r, eval=FALSE} +# this plots one selected image +spatPlot2D(gobject = testcombo, cell_color = 'in_tissue', + show_image = T, image_name = c("NP-image"), point_alpha = 0.3, + save_param = list(save_name = "1b_plot")) +``` + + +![](images/visium_prostate_integration/unnamed-chunk-6-1.png) + + + + +```{r, eval=FALSE} +# this plots two selected images +spatPlot2D(gobject = testcombo, cell_color = 'in_tissue', + show_image = T, image_name = c( "NP-image", "CP-image"), + point_alpha = 0.3, + save_param = list(save_name = "1c_plot")) +``` + + +![](images/visium_prostate_integration/unnamed-chunk-7-1.png) + + + +# 4 Process Giotto Objects + + +```{r, eval=FALSE} +# subset on in-tissue spots +metadata = pDataDT(testcombo) +in_tissue_barcodes = metadata[in_tissue == 1]$cell_ID +testcombo = subsetGiotto(testcombo, cell_ids = in_tissue_barcodes) +``` + + + +```{r, eval=FALSE} +## filter +testcombo <- filterGiotto(gobject = testcombo, + expression_threshold = 1, + feat_det_in_min_cells = 50, + min_det_feats_per_cell = 500, + expression_values = c('raw'), + verbose = T) +``` + + +```{r, eval=FALSE} +## normalize +testcombo <- normalizeGiotto(gobject = testcombo, scalefactor = 6000) +``` + + + +```{r, eval=FALSE} +## add gene & cell statistics +testcombo <- addStatistics(gobject = testcombo, expression_values = 'raw') + +fmeta = fDataDT(testcombo) +testfeats = fmeta[perc_cells > 20 & perc_cells < 50][100:110]$feat_ID + +violinPlot(testcombo, feats = testfeats, cluster_column = 'list_ID', save_param = list(save_name = "2a_plot")) +``` + + +![](images/visium_prostate_integration/unnamed-chunk-9-1.png) + + +```{r, eval=FALSE} +plotMetaDataHeatmap(testcombo, selected_feats = testfeats, metadata_cols = 'list_ID', save_param = list(save_name = "2b_plot")) +``` + + +![](images/visium_prostate_integration/unnamed-chunk-9-3.png) + + + + +```{r, eval=FALSE} +## visualize +spatPlot2D(gobject = testcombo, group_by = 'list_ID', cell_color = 'nr_feats', color_as_factor = F, point_size = 0.75, save_param = list(save_name = "2c_plot")) +``` + + +![](images/visium_prostate_integration/unnamed-chunk-10-1.png) + + + +# 5 Dimention Reduction + + +```{r, eval=FALSE} +## PCA ## +testcombo <- calculateHVF(gobject = testcombo) +``` + + +![](images/visium_prostate_integration/unnamed-chunk-11-1.png) + + +```{r, eval=FALSE} +testcombo <- runPCA(gobject = testcombo, center = TRUE, scale_unit = TRUE) +``` + + + +```{r, eval=FALSE} +screePlot(testcombo, ncp = 30, save_param = list(save_name = "3a_screeplot")) +``` + + +![](images/visium_prostate_integration/unnamed-chunk-11-2.png) + + + +# 6 Clustering + +## 6.1 Without Integration + +Integration is usually needed for dataset of different conditions to minimize batch effects. Without integration means without using any integration methods. + + +```{r, eval=FALSE} +## cluster and run UMAP ## +# sNN network (default) +testcombo <- createNearestNetwork(gobject = testcombo, + dim_reduction_to_use = 'pca', dim_reduction_name = 'pca', + dimensions_to_use = 1:10, k = 15) + +# Leiden clustering +testcombo <- doLeidenCluster(gobject = testcombo, resolution = 0.2, n_iterations = 1000) + +# UMAP +testcombo = runUMAP(testcombo) + +plotUMAP(gobject = testcombo, + cell_color = 'leiden_clus', show_NN_network = T, point_size = 1.5, + save_param = list(save_name = "4.1a_plot")) +``` + + +![](images/visium_prostate_integration/unnamed-chunk-12-1.png) + + + + +```{r, eval=FALSE} +spatPlot2D(gobject = testcombo, group_by = 'list_ID', + cell_color = 'leiden_clus', + point_size = 1.5, + save_param = list(save_name = "4.1b_plot")) +``` + + +![](images/visium_prostate_integration/unnamed-chunk-13-1.png) + + + + +```{r, eval=FALSE} +spatDimPlot2D(gobject = testcombo, + cell_color = 'leiden_clus', + save_param = list(save_name = "4.1c_plot")) +``` + + +![](images/visium_prostate_integration/unnamed-chunk-14-1.png) + + + +## 6.2 With Harmony integration + +Harmony is a integration algorithm developed by [Korsunsky, I. et al.](https://www.nature.com/articles/s41592-019-0619-0). It was designed for integration of single cell data but also work well on spatial datasets. + + +```{r, eval=FALSE} +## data integration, cluster and run UMAP ## + +# harmony +#library(devtools) +#install_github("immunogenomics/harmony") +library(harmony) +``` + + +```{r, eval=FALSE} +## run harmony integration +testcombo = runGiottoHarmony(testcombo, vars_use = 'list_ID', do_pca = F) +``` + + + +```{r, eval=FALSE} +## sNN network (default) +testcombo <- createNearestNetwork(gobject = testcombo, + dim_reduction_to_use = 'harmony', dim_reduction_name = 'harmony', name = 'NN.harmony', + dimensions_to_use = 1:10, k = 15) + +## Leiden clustering +testcombo <- doLeidenCluster(gobject = testcombo, + network_name = 'NN.harmony', resolution = 0.2, n_iterations = 1000, name = 'leiden_harmony') + +# UMAP dimension reduction +testcombo = runUMAP(testcombo, dim_reduction_name = 'harmony', dim_reduction_to_use = 'harmony', name = 'umap_harmony') + + +plotUMAP(gobject = testcombo, + dim_reduction_name = 'umap_harmony', + cell_color = 'leiden_harmony', + show_NN_network = F, + point_size = 1.5, + save_param = list(save_name = "4.2a_plot")) +``` + + +![](images/visium_prostate_integration/unnamed-chunk-15-1.png) + + +```{r, eval=FALSE} +# If you want to show NN network information, you will need to specify these arguments in the plotUMAP function +# show_NN_network = T, nn_network_to_use = 'sNN' , network_name = 'NN.harmony' +``` + + + +```{r, eval=FALSE} +spatPlot2D(gobject = testcombo, group_by = 'list_ID', + cell_color = 'leiden_harmony', + point_size = 1.5, + save_param = list(save_name = "4.2b_plot")) +``` + + +![](images/visium_prostate_integration/unnamed-chunk-16-1.png) + + + + +```{r, eval=FALSE} +spatDimPlot2D(gobject = testcombo, + dim_reduction_to_use = 'umap', dim_reduction_name = 'umap_harmony', + cell_color = 'leiden_harmony', + save_param = list(save_name = "4.2c_plot")) +``` + + +![](images/visium_prostate_integration/unnamed-chunk-17-1.png) + + + + +```{r, eval=FALSE} +# compare to previous results +spatPlot2D(gobject = testcombo, + cell_color = 'leiden_clus', + save_param = list(save_name = "4_w_o_integration_plot")) +``` + + +![](images/visium_prostate_integration/unnamed-chunk-18-1.png) + + +```{r, eval=FALSE} +spatPlot2D(gobject = testcombo, + cell_color = 'leiden_harmony', + save_param = list(save_name = "4_w_integration_plot")) +``` + + +![](images/visium_prostate_integration/unnamed-chunk-18-3.png) + + + +# 7 Cell type annotation + +Visium spatial transcriptomics does not provide single-cell resolution, making cell type annotation a harder problem. Giotto provides several ways to calculate enrichment of specific cell-type signature gene list: + +- PAGE +- hypergeometric test +- Rank +- [DWLS Deconvolution](https://genomebiology.biomedcentral.com/articles/10.1186/s13059-021-02362-7) + +This is also the easiest way to integrate Visium datasets with single cell data. Example shown here is from [Ma et al.](https://pubmed.ncbi.nlm.nih.gov/33032611/) from two prostate cancer patients. The raw dataset can be found [here](https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE157703) Giotto_SC is processed variable in the [single cell RNAseq tutorial](https://giottosuite.com/articles/singlecell_prostate_standard_Sep29_21.html). You can also get access to the processed files of this dataset using getSpatialDataset + + +```{r, eval=FALSE} +# download data to results directory #### +# if wget is installed, set method = 'wget' +# if you run into authentication issues with wget, then add " extra = '--no-check-certificate' " +getSpatialDataset(dataset = 'scRNA_prostate', directory = data_directory) +``` + + + +```{r, eval=FALSE} +sc_expression = paste0(data_directory, "/prostate_sc_expression_matrix.csv.gz") +sc_metadata = paste0(data_directory, "/prostate_sc_metadata.csv") + +giotto_SC <- createGiottoObject( + expression = sc_expression, + instructions = instrs +) +``` + + + +```{r, eval=FALSE} +giotto_SC <- addCellMetadata(giotto_SC, + new_metadata = data.table::fread(sc_metadata)) + +giotto_SC<- normalizeGiotto(giotto_SC) +``` + + +## 7.1 PAGE enrichment + + +```{r, eval=FALSE} +# Create PAGE matrix +# PAGE matrix should be a binary matrix with each row represent a gene marker and each column represent a cell type +# markers_scran is generated from single cell analysis () +markers_scran = findMarkers_one_vs_all(gobject=giotto_SC, + method="scran", + expression_values="normalized", + cluster_column='prostate_labels', + min_feats=3) +``` + + + +```{r, eval=FALSE} +top_markers <- markers_scran[, head(.SD, 10), by="cluster"] +celltypes<-levels(factor(markers_scran$cluster)) +sign_list<-list() + +for (i in 1:length(celltypes)){ + sign_list[[i]]<-top_markers[which(top_markers$cluster == celltypes[i]),]$feats +} + +PAGE_matrix = makeSignMatrixPAGE(sign_names = celltypes, + sign_list = sign_list) +``` + + + +```{r, eval=FALSE} +testcombo = runPAGEEnrich(gobject = testcombo, + sign_matrix = PAGE_matrix, + min_overlap_genes = 2) + +cell_types_subset = colnames(PAGE_matrix) + +# Plot PAGE enrichment result +spatCellPlot(gobject = testcombo, + spat_enr_names = 'PAGE', + cell_annotation_values = cell_types_subset[1:4], + cow_n_col = 2,coord_fix_ratio = NULL, point_size = 1.25, + save_param = list(save_name = "5a_PAGE_plot")) +``` + + +![](images/visium_prostate_integration/unnamed-chunk-21-1.png) + + + +## 7.2 Hypergeometric test + + +```{r, eval=FALSE} +testcombo = runHyperGeometricEnrich(gobject = testcombo, + expression_values = "normalized", + sign_matrix = PAGE_matrix) +cell_types_subset = colnames(PAGE_matrix) +spatCellPlot(gobject = testcombo, + spat_enr_names = 'hypergeometric', + cell_annotation_values = cell_types_subset[1:4], + cow_n_col = 2,coord_fix_ratio = NULL, point_size = 1.75, + save_param = list(save_name = "5b_HyperGeometric_plot")) +``` + + +![](images/visium_prostate_integration/unnamed-chunk-22-1.png) + + + +## 7.3 Rank Enrichment + + +```{r, eval=FALSE} +# Create rank matrix, not that rank matrix is different from PAGE +# A count matrix and a vector for all cell labels will be needed +sc_expression_norm = getExpression(giotto_SC, + values = "normalized", + output = "matrix") + +prostate_feats = pDataDT(giotto_SC)$prostate_label + +rank_matrix = makeSignMatrixRank(sc_matrix = sc_expression_norm, + sc_cluster_ids = prostate_feats) +colnames(rank_matrix)<-levels(factor(prostate_feats)) +testcombo = runRankEnrich(gobject = testcombo, sign_matrix = rank_matrix,expression_values = "normalized") + +# Plot Rank enrichment result +spatCellPlot2D(gobject = testcombo, + spat_enr_names = 'rank', + cell_annotation_values = cell_types_subset[1:4], + cow_n_col = 2,coord_fix_ratio = NULL, point_size = 1, + save_param = list(save_name = "5c_Rank_plot")) +``` + + +![](images/visium_prostate_integration/unnamed-chunk-23-1.png) + + + +## 7.4 DWLS Deconvolution + + +```{r, eval=FALSE} +# Create DWLS matrix, not that DWLS matrix is different from PAGE and rank +# A count matrix a vector for a list of gene signatures and a vector for all cell labels will be needed +DWLS_matrix<-makeSignMatrixDWLSfromMatrix(matrix = sc_expression_norm, + cell_type = prostate_feats, + sign_gene = top_markers$feats) +testcombo = runDWLSDeconv(gobject = testcombo, sign_matrix = DWLS_matrix) + + +# Plot DWLS deconvolution result +spatCellPlot2D(gobject = testcombo, + spat_enr_names = 'DWLS', + cell_annotation_values = levels(factor(prostate_feats))[1:4], + cow_n_col = 2,coord_fix_ratio = NULL, point_size = 1, + save_param = list(save_name = "5d_DWLS_plot")) +``` + + +![](images/visium_prostate_integration/unnamed-chunk-24-1.png) + + + +# 8 Session Info + + +```{r, eval=FALSE} +sessionInfo() + +R version 4.2.2 (2022-10-31 ucrt) + Platform: x86_64-w64-mingw32/x64 (64-bit) + Running under: Windows 10 x64 (build 22621) + + Matrix products: default + + locale: + [1] LC_COLLATE=English_United States.utf8 + [2] LC_CTYPE=English_United States.utf8 + [3] LC_MONETARY=English_United States.utf8 + [4] LC_NUMERIC=C + [5] LC_TIME=English_United States.utf8 + + attached base packages: + [1] stats graphics grDevices utils datasets methods base + + other attached packages: + [1] harmony_0.1.1 Rcpp_1.0.10 GiottoData_0.2.1 Giotto_3.3.0 + [5] testthat_3.1.5 + + loaded via a namespace (and not attached): + [1] systemfonts_1.0.4 plyr_1.8.8 + [3] igraph_1.4.1 lazyeval_0.2.2 + [5] sp_1.6-0 BiocParallel_1.32.6 + [7] listenv_0.9.0 usethis_2.1.6 + [9] GenomeInfoDb_1.34.6 ggplot2_3.4.2 + [11] digest_0.6.30 htmltools_0.5.4 + [13] magick_2.7.4 fansi_1.0.4 + [15] magrittr_2.0.3 memoise_2.0.1 + [17] ScaledMatrix_1.6.0 cluster_2.1.4 + [19] limma_3.54.2 remotes_2.4.2 + [21] globals_0.16.2 matrixStats_0.63.0 + [23] R.utils_2.12.2 prettyunits_1.1.1 + [25] colorspace_2.1-0 rappdirs_0.3.3 + [27] ggrepel_0.9.2 textshaping_0.3.6 + [29] xfun_0.38 dplyr_1.1.1 + [31] callr_3.7.3 crayon_1.5.2 + [33] RCurl_1.98-1.9 jsonlite_1.8.3 + [35] progressr_0.13.0 glue_1.6.2 + [37] gtable_0.3.3 zlibbioc_1.44.0 + [39] XVector_0.38.0 DelayedArray_0.24.0 + [41] pkgbuild_1.4.0 BiocSingular_1.14.0 + [43] RcppZiggurat_0.1.6 future.apply_1.10.0 + [45] SingleCellExperiment_1.20.0 BiocGenerics_0.44.0 + [47] scales_1.2.1 edgeR_3.40.1 + [49] miniUI_0.1.1.1 viridisLite_0.4.2 + [51] xtable_1.8-4 dqrng_0.3.0 + [53] reticulate_1.26 rsvd_1.0.5 + [55] stats4_4.2.2 profvis_0.3.7 + [57] metapod_1.6.0 htmlwidgets_1.6.2 + [59] httr_1.4.5 RColorBrewer_1.1-3 + [61] ellipsis_0.3.2 scuttle_1.8.3 + [63] urlchecker_1.0.1 pkgconfig_2.0.3 + [65] R.methodsS3_1.8.2 farver_2.1.1 + [67] uwot_0.1.14 deldir_1.0-6 + [69] locfit_1.5-9.7 utf8_1.2.3 + [71] here_1.0.1 tidyselect_1.2.0 + [73] labeling_0.4.2 rlang_1.1.0 + [75] reshape2_1.4.4 later_1.3.0 + [77] munsell_0.5.0 tools_4.2.2 + [79] cachem_1.0.6 cli_3.4.1 + [81] dbscan_1.1-11 generics_0.1.3 + [83] devtools_2.4.5 evaluate_0.20 + [85] stringr_1.5.0 fastmap_1.1.0 + [87] yaml_2.3.7 ragg_1.2.4 + [89] processx_3.8.0 knitr_1.42 + [91] fs_1.5.2 purrr_1.0.1 + [93] future_1.32.0 sparseMatrixStats_1.10.0 + [95] mime_0.12 scran_1.26.1 + [97] R.oo_1.25.0 brio_1.1.3 + [99] compiler_4.2.2 rstudioapi_0.14 + [101] plotly_4.10.1 png_0.1-7 + [103] statmod_1.4.37 tibble_3.2.1 + [105] stringi_1.7.8 ps_1.7.2 + [107] desc_1.4.2 bluster_1.8.0 + [109] lattice_0.20-45 Matrix_1.5-1 + [111] vctrs_0.6.1 pillar_1.9.0 + [113] lifecycle_1.0.3 BiocNeighbors_1.16.0 + [115] RcppAnnoy_0.0.20 data.table_1.14.6 + [117] cowplot_1.1.1 bitops_1.0-7 + [119] irlba_2.3.5.1 httpuv_1.6.6 + [121] GenomicRanges_1.50.2 R6_2.5.1 + [123] promises_1.2.0.1 IRanges_2.32.0 + [125] parallelly_1.35.0 sessioninfo_1.2.2 + [127] codetools_0.2-18 pkgload_1.3.2 + [129] SummarizedExperiment_1.28.0 rprojroot_2.0.3 + [131] withr_2.5.0 S4Vectors_0.36.2 + [133] GenomeInfoDbData_1.2.9 parallel_4.2.2 + [135] terra_1.7-18 quadprog_1.5-8 + [137] grid_4.2.2 beachmat_2.14.0 + [139] tidyr_1.3.0 Rfast_2.0.6 + [141] DelayedMatrixStats_1.20.0 rmarkdown_2.21 + [143] MatrixGenerics_1.10.0 Rtsne_0.16 + [145] Biobase_2.58.0 shiny_1.7.4 +``` + + +