Skip to content

Commit 7cf0263

Browse files
authored
Merge pull request #6 from jeliason/fix/sic-extraction-prefix-matching
Fix SIC extraction for cell types with shared prefixes
2 parents a59eb48 + 6a4bf7a commit 7cf0263

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

.github/workflows/tests.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343

4444
- uses: r-lib/actions/setup-r-dependencies@v2
4545
with:
46+
upgrade: 'TRUE'
4647
extra-packages: |
4748
any::testthat
4849
any::devtools

R/sic_extraction.R

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,9 @@ compute_sic_posterior <- function(fit,
153153
for (group_i in indices) {
154154
for (source in source_types) {
155155
# Find coefficient indices for this target-source pair
156-
coef_pattern <- paste0("_", target_type, "_", source)
157-
coef_ix <- grep(coef_pattern, coef_names, fixed = TRUE)
156+
# Use $ anchor to match exact source name at end (avoids matching cd4tcells_ICOS when looking for cd4tcells)
157+
coef_pattern <- paste0("_", target_type, "_", source, "$")
158+
coef_ix <- grep(coef_pattern, coef_names)
158159

159160
if (length(coef_ix) == 0) {
160161
warning(sprintf("No coefficients found for %s -> %s", source, target_type))
@@ -221,8 +222,9 @@ compute_sic_posterior <- function(fit,
221222
for (patient_i in indices) {
222223
for (source in source_types) {
223224
# Find coefficient indices for this target-source pair
224-
coef_pattern <- paste0("_", target_type, "_", source)
225-
coef_ix <- grep(coef_pattern, coef_names, fixed = TRUE)
225+
# Use $ anchor to match exact source name at end (avoids matching cd4tcells_ICOS when looking for cd4tcells)
226+
coef_pattern <- paste0("_", target_type, "_", source, "$")
227+
coef_ix <- grep(coef_pattern, coef_names)
226228

227229
if (length(coef_ix) == 0) {
228230
warning(sprintf("No coefficients found for %s -> %s", source, target_type))
@@ -283,8 +285,9 @@ compute_sic_posterior <- function(fit,
283285
for (image_i in indices) {
284286
for (source in source_types) {
285287
# Find coefficient indices for this target-source pair
286-
coef_pattern <- paste0("_", target_type, "_", source)
287-
coef_ix <- grep(coef_pattern, coef_names, fixed = TRUE)
288+
# Use $ anchor to match exact source name at end (avoids matching cd4tcells_ICOS when looking for cd4tcells)
289+
coef_pattern <- paste0("_", target_type, "_", source, "$")
290+
coef_ix <- grep(coef_pattern, coef_names)
288291

289292
if (length(coef_ix) == 0) {
290293
warning(sprintf("No coefficients found for %s -> %s", source, target_type))

0 commit comments

Comments
 (0)