Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #13 from cytomining/updates
Browse files Browse the repository at this point in the history
Handle rep_group correctly
  • Loading branch information
shntnu authored Mar 13, 2023
2 parents 5e39445 + e8623b2 commit 8fa534a
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 13 deletions.
23 changes: 17 additions & 6 deletions matric/2.calculate_index.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,27 @@ profiles <-
```{r}
log_info("Calculating index ...")
if (is.null(params$sim_params$any_different_cols_non_rep)) {
log_info("Reducing similarity calculations because `any_different_cols_non_rep` is NULL ...")
x_all_same_cols_rep <- params$sim_params$all_same_cols_rep
if (is.null(params$sim_params$any_different_cols_non_rep) &
xor(
!is.null(params$sim_params$all_same_cols_rep),
!is.null(params$sim_params$all_same_cols_group)
)) {
log_info(
"Reducing similarity calculations because `any_different_cols_non_rep` is NULL and only one of `all_same_cols_rep` and `all_same_cols_group` are specified..."
)
if (!is.null(params$sim_params$all_same_cols_rep)) {
x_all_same_cols_rep_or_group <- params$sim_params$all_same_cols_rep
} else {
x_all_same_cols_rep_or_group <-
params$sim_params$all_same_cols_group
}
x_all_same_cols_ref <- params$sim_params$all_same_cols_ref
x_reference_df <- reference_df
} else {
log_info(
"Performing all similarity calculations because `any_different_cols_non_rep` is not NULL ..."
"Performing all similarity calculations because `any_different_cols_non_rep` is not NULL or both `all_same_cols_rep` and `all_same_cols_group` are specified...."
)
x_all_same_cols_rep <- NULL
x_all_same_cols_rep_or_group <- NULL
x_all_same_cols_ref <- NULL
x_reference_df <- NULL
}
Expand All @@ -102,7 +113,7 @@ sim_df <-
population = profiles,
method = NULL,
lazy = TRUE,
all_same_cols_rep_or_group = x_all_same_cols_rep,
all_same_cols_rep_or_group = x_all_same_cols_rep_or_group,
all_same_cols_ref = x_all_same_cols_ref,
reference = x_reference_df
)
Expand Down
2 changes: 1 addition & 1 deletion matric/3.calculate_metrics.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ if (!is.null(attr(collated_sim, "params")$calculate_index$sim_params$any_differe
sim_metrics(
collated_sim,
sim_type_background = "non_rep",
calculate_grouped = FALSE,
calculate_grouped = calculate_grouped,
use_furrr = TRUE,
calculate_pvalue = TRUE
)
Expand Down
38 changes: 34 additions & 4 deletions matric/5.inspect_metrics.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ plot_metric <-

# Read

## Level 1_0

```{r}
metric_set <- glue("level_1_0_{type}")
Expand All @@ -84,11 +86,9 @@ log_info("Reading {parquet_file} ...")
level_1_0_metrics <-
arrow::read_parquet(glue(parquet_file))
all_same_cols_rep <- attr(level_1_0_metrics, "all_same_cols_rep")
```

After reading level_1, drop duplicates that may result from annotating level 1_0 entities
## Level 1

```{r}
metric_set <- glue("level_1_{type}")
Expand All @@ -102,11 +102,41 @@ parquet_file <-
log_info("Reading {parquet_file} ...")
level_1_metrics <-
arrow::read_parquet(glue(parquet_file)) %>%
arrow::read_parquet(glue(parquet_file))
```

After reading level_1, drop duplicates that may result from annotating level 1_0 entities

```{r}
all_same_cols_rep <- attr(level_1_0_metrics, "all_same_cols_rep")
level_1_metrics <-
level_1_metrics %>%
select(all_of(all_same_cols_rep), matches("^sim_")) %>%
distinct()
```


## Level 2_1

```{r}
metric_set <- glue("level_2_1_{type}")
parquet_file <-
with(
params,
glue("{input_metrics_file_prefix}_{metric_set}.parquet")
)
if (file.exists(parquet_file)) {
log_info("Reading {parquet_file} ...")
level_2_1_metrics <-
arrow::read_parquet(glue(parquet_file))
}
```


# Plot metrics

## Average Precision
Expand Down
4 changes: 2 additions & 2 deletions renv.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,7 @@
"RemoteRepo": "matric",
"RemoteUsername": "shntnu",
"RemoteRef": "null_df",
"RemoteSha": "419ed83c194624a5a5393f6c8765fae9c2940630",
"RemoteSha": "a2adb70e437cd1f07020ada415292590220d4ff1",
"Requirements": [
"R",
"arrow",
Expand All @@ -1336,7 +1336,7 @@
"tidyr",
"yardstick"
],
"Hash": "653b4266a16595683c83c021c59f030e"
"Hash": "ab6353150e1beacd9443747b47539fcd"
},
"memoise": {
"Package": "memoise",
Expand Down

0 comments on commit 8fa534a

Please sign in to comment.