diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 794ac1d..a30a2e1 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -43,6 +43,7 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: + upgrade: 'TRUE' extra-packages: | any::testthat any::devtools diff --git a/R/sic_extraction.R b/R/sic_extraction.R index f7babc6..49f134b 100644 --- a/R/sic_extraction.R +++ b/R/sic_extraction.R @@ -153,8 +153,9 @@ compute_sic_posterior <- function(fit, for (group_i in indices) { for (source in source_types) { # Find coefficient indices for this target-source pair - coef_pattern <- paste0("_", target_type, "_", source) - coef_ix <- grep(coef_pattern, coef_names, fixed = TRUE) + # Use $ anchor to match exact source name at end (avoids matching cd4tcells_ICOS when looking for cd4tcells) + coef_pattern <- paste0("_", target_type, "_", source, "$") + coef_ix <- grep(coef_pattern, coef_names) if (length(coef_ix) == 0) { warning(sprintf("No coefficients found for %s -> %s", source, target_type)) @@ -221,8 +222,9 @@ compute_sic_posterior <- function(fit, for (patient_i in indices) { for (source in source_types) { # Find coefficient indices for this target-source pair - coef_pattern <- paste0("_", target_type, "_", source) - coef_ix <- grep(coef_pattern, coef_names, fixed = TRUE) + # Use $ anchor to match exact source name at end (avoids matching cd4tcells_ICOS when looking for cd4tcells) + coef_pattern <- paste0("_", target_type, "_", source, "$") + coef_ix <- grep(coef_pattern, coef_names) if (length(coef_ix) == 0) { warning(sprintf("No coefficients found for %s -> %s", source, target_type)) @@ -283,8 +285,9 @@ compute_sic_posterior <- function(fit, for (image_i in indices) { for (source in source_types) { # Find coefficient indices for this target-source pair - coef_pattern <- paste0("_", target_type, "_", source) - coef_ix <- grep(coef_pattern, coef_names, fixed = TRUE) + # Use $ anchor to match exact source name at end (avoids matching cd4tcells_ICOS when looking for cd4tcells) + coef_pattern <- paste0("_", target_type, "_", source, "$") + coef_ix <- grep(coef_pattern, coef_names) if (length(coef_ix) == 0) { warning(sprintf("No coefficients found for %s -> %s", source, target_type))