#' Find top cluster markers
#'
#' Find top cluster markers.
#'
#' @param cluster.markers Data.frame generated by Seurat FindAllMarkers
#' @param ntop Number of top markers for each cluster
#' @param padj.cutoff Cutoff of adjusted p-values
#' @param pct.cutoff Cutoff of percentage of expressing cells
#' @return Data.frame
#' @export
find_top_cluster_markers <- function(cluster.markers, ntop = 5, padj.cutoff = 0.05, pct.cutoff = 0.25) {
cluster.markers %>%
dplyr::filter(p_val_adj < padj.cutoff & pct.1 >= pct.cutoff) %>%
dplyr::group_by(cluster) %>%
dplyr::top_n(n = 2*ntop, wt = avg_log2FC) %>%
as.data.frame() %>%
dplyr::filter(!(duplicated(gene) | duplicated(gene, fromLast = TRUE))) %>%
dplyr::group_by(cluster) %>%
dplyr::top_n(n = ntop, wt = avg_log2FC) %>%
as.data.frame() %>%
dplyr::mutate(cluster = paste("Cluster", cluster)) %>%
dplyr::mutate(cluster = factor(cluster, levels = unique(cluster)))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.