Skip to content

Commit

Permalink
add simpler milo check for plotting functions
Browse files Browse the repository at this point in the history
  • Loading branch information
missaroa committed Apr 5, 2024
1 parent d7c32d5 commit 3f825b9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Description: Sensitive DE testing using neighbourhoods instead of discrete clust
License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.0
Imports:
dplyr,
ggplot2,
Expand Down
2 changes: 1 addition & 1 deletion R/plotting_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ plot_milo_by_single_metric = function(x, nhood_stat, colour_by = "logFC" , signi

# checks
out = .check_argument_correct(x, .check_sce, "Check x - something is wrong (gene names unique? reducedDim.name is not present?)") &
.check_sce_milo(x) &
.check_sce_milo_wo_graph(x) &
.check_argument_correct(order_direction, .check_boolean, "Check order_direction - should be either TRUE or FALSE") &
.check_reducedDim_in_sce(x , layout) & .check_nhood_stat(nhood_stat , x)

Expand Down
23 changes: 23 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,29 @@
}
}

# sce-milo check wo/ calculation of the length of graph: that is used in plotting functions
#' @importFrom miloR Milo nhoods graph graph<- nhoods<- nhoodIndex<- buildNhoodGraph
#' @importFrom methods is
.check_sce_milo_wo_graph = function(x){
if (!is(x , "Milo")){
stop("x should be a Milo object. Please run `assign_neighbourhoods` first.")
return(FALSE)
} else if (sum(sum(nhoods(x))) == 0){
stop("x should have calculated nhoods. Please run 'assign_neighbourhoods' first.")
return(FALSE)
} else if ( nrow(nhoods(x)) == 1 & ncol(nhoods(x)) == 1 ){
stop("x should contain non-trivial nhoods. Please run `assign_neighbourhoods` first.")
return(FALSE)
} else if (isEmpty(nhoodIndex(x))){
stop("x should have calculated nhoodIndex. Please run 'assign_neighbourhoods' first.")
return(FALSE)
} else {
return(TRUE)
}
}



# sce check: that is used in add_embedding
#' @importFrom SingleCellExperiment reducedDimNames
#' @importFrom SummarizedExperiment assays<- assays
Expand Down

0 comments on commit 3f825b9

Please sign in to comment.