#' @title ROC
#' @description Calculate ROC score for each gene in separating clusters
#' @param data DEG matrix obtained from conservedMarkers, or Seurat function 'FindAllMarkers'
#' @param obj Seurat object
#' @examples
#' \dontrun{
#' addROC(data, obj)
#' }
#' @export
#' @import pROC
addROC <- function(data, obj){
data$AUC <- 0
for( i in unique(data$cluster)){
row.idx <- which(data$cluster == i)
for( j in row.idx){
this.gene <- data$gene[j]
this.exp <- obj@data[this.gene,]
this.class <- as.character(obj@ident)
this.class[this.class==i] <- 1
this.class[this.class!=1] <- 0
data$AUC[j] <- as.numeric(roc(this.class, this.exp)$auc)
}
}
return(data)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.