Skip to content

Commit

Permalink
change: print when no nonzero adjusted p.values are found
Browse files Browse the repository at this point in the history
- this should probably be caught differently
  • Loading branch information
jiajic committed May 23, 2024
1 parent c098f45 commit 7796cc5
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions R/spatial_interaction.R
Original file line number Diff line number Diff line change
Expand Up @@ -2851,7 +2851,6 @@ specificCellCellcommunicationScores <- function(gobject,
difference[difference < 0] <- -1
total_bool <- total_bool + difference
}
if (verbose) cat("\n")

comScore[, rand_expr := total_av / random_iter]

Expand Down Expand Up @@ -2884,11 +2883,23 @@ specificCellCellcommunicationScores <- function(gobject,

# get minimum adjusted p.value that is not zero
all_p.adj <- comScore[["p.adj"]]
# TODO catch when len = 0
lowest_p.adj <- min(all_p.adj[all_p.adj != 0])
nonzero_p.adj <- all_p.adj[all_p.adj != 0]
if (length(nonzero_p.adj) == 0L) {
warning(
call. = FALSE,
"no adjusted p.values that are not zero; returning Inf"
)
if (verbose) cat("<- Inf returned")
lowest_p.adj <- Inf
} else {
lowest_p.adj <- min(nonzero_p.adj)
}

comScore[, PI := ifelse(p.adj == 0, log2fc * (
-log10(lowest_p.adj)), log2fc * (-log10(p.adj)))]

if (verbose) cat("\n")

return(comScore)
}
}
Expand Down

0 comments on commit 7796cc5

Please sign in to comment.