Skip to content

Commit

Permalink
Update getHierarchicalPredSets.R
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielaCorbetta authored Apr 25, 2024
1 parent 0da6153 commit 1e432ea
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions R/getHierarchicalPredSets.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#' @title Get hierarchical prediction sets exploiting the cell ontology
#' @description Let K be the total number of distinct cell type labels and n, m
#' the number of cells in the calibration and in the test data, respectively.
#' This function takes as input two matrices: a matrix \code{n \times K} and
#' a matrix \code{m \times K} with the estimated
#' This function takes as input two matrices: a matrix \code{n x K} and
#' a matrix \code{m x K} with the estimated
#' probabilities for each cell in the calibration and in the test data, respectively.
#' It returns a list with the prediction sets for each cell in the test data.
#'
Expand All @@ -26,7 +26,7 @@ getHierarchicalPredSets <- function(p.cal, p.test, y.cal, onto, alpha, lambdas){
# Get prediction sets for each value of lambda for all the calibration data
sets <- foreach(lambda = lambdas) %dopar% {
lapply(1:nrow(p.cal),
function(i) .pred_sets(lambda=lambda, pred=p.cal[i, ], onto=onto))}
function(i) .predSets(lambda=lambda, pred=p.cal[i, ], onto=onto))}

# Get the loss table (ncal x length(lambda) table with TRUE\FALSE)
loss <- sapply(1:length(lambdas), function(lambda) {
Expand All @@ -42,7 +42,7 @@ getHierarchicalPredSets <- function(p.cal, p.test, y.cal, onto, alpha, lambdas){
lhat <- lambdas[lhat_idx]

# Get prediction sets for test data
sets.test <- apply(p.test, 1, function(x) .pred_sets(lambda=lhat, pred=x, onto=onto))
sets.test <- apply(p.test, 1, function(x) .predSets(lambda=lhat, pred=x, onto=onto))

return(sets.test)
}
Expand Down

0 comments on commit 1e432ea

Please sign in to comment.