Skip to content

Commit

Permalink
fix issue 88 plotAbundance rank
Browse files Browse the repository at this point in the history
  • Loading branch information
Insaynoah committed Apr 10, 2024
1 parent 0fa499a commit 3375c9c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion R/plotAbundance.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,26 @@ setGeneric("plotAbundance", signature = c("x"),
}
}

.find_lowest_taxonomy_level<- function(x){
levels <- taxonomyRanks(x)
for(tax_index in 1:length(levels)){
if(anyNA(rowData(x)[,levels[tax_index]])){
return(levels[tax_index-1])
}

}
return(levels[length(levels)])
}



#' @rdname plotAbundance
#' @importFrom scater plotExpression
#' @importFrom ggplot2 facet_wrap
#' @export
setMethod("plotAbundance", signature = c("SummarizedExperiment"),
function(x,
rank = taxonomyRanks(x)[1],
rank = .find_lowest_taxonomy_level(x),
features = NULL,
order_rank_by = c("name","abund","revabund"),
order_sample_by = NULL,
Expand Down

0 comments on commit 3375c9c

Please sign in to comment.