Add selected results from doHMRF to the giotto object
addHMRF(
gobject,
spat_unit = NULL,
feat_type = NULL,
HMRFoutput,
k = NULL,
betas_to_add = NULL,
hmrf_name = NULL
)
giotto object
spatial unit
feature type
HMRF output from doHMRF()
number of domains
results from different betas that you want to add
specify a custom name
giotto object
g <- GiottoData::loadGiottoMini("visium")
#> 1. read Giotto object
#> 2. read Giotto feature information
#> 3. read Giotto spatial information
#> 3.1 read Giotto spatial shape information
#> cell_spatInfo_spatVector.shp
#> cell
#>
#> 3.2 read Giotto spatial centroid information
#> cell
#>
#> 3.3 read Giotto spatial overlap information
#> No overlaps were found, overlap loading will be
#> skipped
#>
#> 4. read Giotto image information
#> a giotto python environment was found
#> Using python path:
#> "/Users/yuanlab/Library/r-miniconda/envs/giotto_env/bin/pythonw"
spat_genes <- binSpect(g)
#>
#> This is the single parameter version of binSpect
#>
#> 1. matrix binarization complete
#>
#> 2. spatial enrichment test completed
#>
#> 3. (optional) average expression of high
#> expressing cells calculated
#>
#> 4. (optional) number of high expressing cells
#> calculated
output_folder <- file.path(tempdir(), 'HMRF')
if(!file.exists(output_folder)) dir.create(output_folder, recursive = TRUE)
out <- doHMRF(
g, spatial_genes = spat_genes[seq_len(20)]$feats,
expression_values = "scaled",
spatial_network_name = "Delaunay_network",
k = 6, betas = c(0, 10, 5),
output_folder = output_folder
)
#> Warning: this matrix will be converted to a dense and memory intensive
#> base matrix ...
#> expression_matrix.txt already exists at this location, will be
#> overwritten
#> spatial_genes.txt already exists at this location, will be
#> overwritten
#> spatial_network.txt already exists at this location, will be
#> overwritten
#> spatial_cell_locations.txt already exists at this location,
#> will be overwritten
#> [1] "/Users/yuanlab/Library/r-miniconda/envs/giotto_env/bin/pythonw /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/library/Giotto/python/reader2.py -l \"/var/folders/wl/055wx0m919n1wvp5t1tl_r2c0000gp/T//RtmpRCiCyr/HMRF/spatial_cell_locations.txt\" -g \"/var/folders/wl/055wx0m919n1wvp5t1tl_r2c0000gp/T//RtmpRCiCyr/HMRF/spatial_genes.txt\" -n \"/var/folders/wl/055wx0m919n1wvp5t1tl_r2c0000gp/T//RtmpRCiCyr/HMRF/spatial_network.txt\" -e \"/var/folders/wl/055wx0m919n1wvp5t1tl_r2c0000gp/T//RtmpRCiCyr/HMRF/expression_matrix.txt\" -o \"/var/folders/wl/055wx0m919n1wvp5t1tl_r2c0000gp/T//RtmpRCiCyr/HMRF/result.spatial.zscore\" -a test -k 6 -b 0 10 5 -t 1e-10 -z none -s 100 -i 100"
g <- addHMRF(
gobject = g,
HMRFoutput = out,
k = 6,
betas_to_add = 20,
hmrf_name = "HMRF"
)
#> [1] "/Users/yuanlab/Library/r-miniconda/envs/giotto_env/bin/pythonw /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/library/Giotto/python/get_result2.py -r \"/var/folders/wl/055wx0m919n1wvp5t1tl_r2c0000gp/T//RtmpRCiCyr/HMRF/result.spatial.zscore\" -a test -k 6 -b 20"
spatPlot(
gobject = g, cell_color = 'HMRF_k6_b.20',
)