Skip to contents

Compute, without applying, the changes a partner patch would make to an hyperannotatR project: ROIs are joined by id and classified as create, update, unchanged, delete (only with delete_missing = TRUE) or conflict. Reviewed or locked ROIs, and ROIs in locked layers, are never changed automatically, and nothing is created in or moved into a locked layer; such changes become conflicts. Incoming ROIs whose id was minted on import (features without an id) are always created, with an id unique in the project. Incoming ROIs at another pyramid level are compared, and updates stored, at the level of the existing ROI. A patch that repeats an ROI id aborts (DUPLICATE_ID). When expected_revision is given and the project has moved on, staging aborts with an at_conflict_error (REVISION_CONFLICT).

Usage

at_stage_qupflowr(
  x,
  patch,
  expected_revision = NULL,
  delete_missing = FALSE,
  call = rlang::caller_env()
)

Arguments

x

An annot_project, or the path of a saved project .rds (then the commit re-reads and re-checks that file).

patch

An import report from at_import_qupflowr(), a handoff directory, or one or more annot_layer objects.

expected_revision

Optional revision of x the partner based its patch on (see at_annotation_revision()).

delete_missing

Logical; treat ROIs absent from the patch's layers as deletions. Default FALSE.

call

The calling environment, for error reporting.

Value

An at_staged_patch: a list with patch_id, state = "staged", created, base_revision, proposed_revision, operations (tibble of op, roi_id, layer, label, reason), summary (counts by op), base, proposed (the would-be project), target_path and patch_digest.

Examples

proj <- at_example_project()
partner <- at_layer_add(at_layer("regions"), at_roi_rect(10, 10, 40, 40, label = "tumour",
                                                         id = "partner-1"))
st <- at_stage_qupflowr(proj, partner, expected_revision = at_annotation_revision(proj))
st$summary
#> $create
#> [1] 1
#> 
#> $update
#> [1] 0
#> 
#> $unchanged
#> [1] 0
#> 
#> $delete
#> [1] 0
#> 
#> $conflict
#> [1] 0
#>