vignettes/work_with_multiple_analyses.Rmd
work_with_multiple_analyses.Rmd
The default Giotto workflow is similar to other scRNA-seq workflows
and does not require you to provide a custom name for each analysis
(e.g. PCA, UMAP, …), but running an analysis twice will overwrite the
previous results with a warning. However, there are situations where
being able to run and store multiple analyses can be advantageous:
- test multiple parameters for a single analysis
- test multiple combinations across functions (see example
hvg->pca->umap)
- use different output results as input for downstream analyses (see
example spatial genes)
We will use the seqFish+ somatosensory cortex as an example dataset after creating and processing a Giotto object.
# using the loess method
VC_test <- calculateHVG(gobject = VC_test,
method = 'cov_loess', difference_in_cov = 0.1,
HVGname = 'loess_hvg')
# using the expression groups method
VC_test <- calculateHVG(gobject = VC_test
, method = 'cov_group', zscore_threshold = 1,
HVGname = 'group_hvg')
## 4. spatial network
VC_test <- createSpatialNetwork(gobject = VC_test, method = 'kNN', k = 5) # standard name: 'spatial_network'
VC_test <- createSpatialNetwork(gobject = VC_test, method = 'kNN', k = 10, name = 'large_network')
VC_test <- createSpatialNetwork(gobject = VC_test, method = 'kNN', k = 100, maximum_distance_knn = 200, minimum_k = 2, name = 'distance_network')
## visualize different spatial networks on first field (~ layer 1)
cell_metadata = pDataDT(VC_test)
field1_ids = cell_metadata[Field_of_View == 0]$cell_ID
subVC_test = subsetGiotto(VC_test, cell_ids = field1_ids)
spatPlot(gobject = subVC_test, show_network = T,
network_color = 'blue', spatial_network_name = 'spatial_network')
spatial network:
spatPlot(gobject = subVC_test, show_network = T,
network_color = 'blue', spatial_network_name = 'large_network')
large network:
spatPlot(gobject = subVC_test, show_network = T,
network_color = 'blue', spatial_network_name = 'distance_network')
distance network:
## 5. spatial genes
# the provided spatial_network_name can be given to downstream analyses
# spatial genes based on large network
ranktest_large = binSpect(VC_test,
subset_genes = loess_genes,
bin_method = 'rank',
spatial_network_name = 'large_network')
spatGenePlot(VC_test,
expression_values = 'scaled',
genes = ranktest_large$genes[1:6], cow_n_col = 2, point_size = 1,
genes_high_color = 'red', genes_mid_color = 'white', genes_low_color = 'darkblue', midpoint = 0)
large network spatial genes:
# spatial genes based on distance network
ranktest_dist = binSpect(VC_test,
subset_genes = loess_genes,
bin_method = 'rank',
spatial_network_name = 'distance_network')
spatGenePlot(VC_test,
expression_values = 'scaled',
genes = ranktest_dist$genes[1:6], cow_n_col = 2, point_size = 1,
genes_high_color = 'red', genes_mid_color = 'white', genes_low_color = 'darkblue', midpoint = 0)
distance network spatial genes: