@@ -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