Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ Bug fixes:
mismatched spots.
- `generate_sim_spatialcluster`: check that the simulated dataset still lines
up with the real one, through a new `check_alignment()` helper.
- `downstream`: reuse the `spatial_cluster` that
`process_datasets/generate_sim_spatialcluster` already computed, instead of
running `BayesSpace::spatialCluster()` a second time. Saves an MCMC run per
method per dataset and makes the metric report the clustering the pipeline
stored. This does not make `clustering_ari` reproducible: both before and
after, a fixed reference is compared against one unseeded run.
- `generate_cosine()`: filter the Moran's I values rather than the objects
holding them, so that a single NaN no longer takes the whole metric with
it. `crosscor_cosine` was NA for 32 of 99 runs.
Expand Down
19 changes: 13 additions & 6 deletions src/metrics/downstream/script.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,20 @@ crosscor_cosine <- generate_cosine(real_moransI, sim_moransI)
crosscor_mantel <- generate_mantel(real_moransI, sim_moransI)

cat("spatial clustering evaluation\n")
# reclassify the clustering result
real_cluster <- input_real_sp$obs[, c("spatial_cluster")]
sim_cluster <- generate_sim_spatialCluster(input_real_sp, input_simulated_sp)
location <- rownames(input_simulated_sp)
sim_new_cluster <- reclassify_simsce(location, real_cluster, sim_cluster)
# the simulated clustering was already computed by
# process_datasets/generate_sim_spatialcluster; recomputing it here would give a
# different answer every time, since BayesSpace is stochastic and unseeded
real_cluster <- input_real_sp$obs[["spatial_cluster"]]
sim_cluster <- input_simulated_sp$obs[["spatial_cluster"]]

# ART and NMI
if (is.null(sim_cluster)) {
stop(
"The simulated dataset has no 'spatial_cluster' column. ",
"Did it pass through process_datasets/generate_sim_spatialcluster?"
)
}

# ARI and NMI
clustering_ari <- aricode::ARI(real_cluster, sim_cluster)
clustering_nmi <- aricode::NMI(real_cluster, sim_cluster)

Expand Down
Loading