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
)

Arguments

gobject

giotto object

spat_unit

spatial unit

feat_type

feature type

HMRFoutput

HMRF output from doHMRF()

k

number of domains

betas_to_add

results from different betas that you want to add

hmrf_name

specify a custom name

Value

giotto object

Examples

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
#> 3.2 read Giotto spatial centroid information
#> 3.3 read Giotto spatial overlap information
#> 4. read Giotto image information
#> python already initialized in this session
#>  active environment : '/usr/bin/python3'
#>  python version : 3.12
#> checking default envname 'giotto_env'
#> a system default python environment was found
#> Using python path:
#>  "/usr/bin/python3"
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
)
#> Error: package 'smfishHmrf' is not yet installed
#> 
#>  To install:
#> ## active python env: '/usr/bin/python3' 
#> ## python version: 3.12
#> ## restart session then use GiottoClass::set_giotto_python_path() if this is incorrect
#> reticulate::conda_install(envname = '/usr/bin/python3', packages = c('smfishHmrf'), pip = TRUE)

g <- addHMRF(
    gobject = g,
    HMRFoutput = out,
    k = 6,
    betas_to_add = 20,
    hmrf_name = "HMRF"
)
#> Error: object 'out' not found

spatPlot(
    gobject = g, cell_color = "HMRF_k6_b.20",
)
#> Error: spatPlot2D()
#>  HMRF_k6_b.20 is not a color or a column name