Last active
May 24, 2024 16:34
-
-
Save diazdc/1735102c243cd16acb1b1f3fd09a26e1 to your computer and use it in GitHub Desktop.
Multicore solution for Seurat FindAllMarkers()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n_clust <- 1:(max(as.numeric(Idents(seurat_obj)))) | |
mcFindMarkers <- function(i){ | |
ident1 <- i | |
ident2 <- n_clust[n_clust != i] | |
table <- FindMarkers(seurat_obj, | |
ident.1 = ident1, ident.2 = ident2, only.pos = TRUE) | |
table$Gene.name.uniq <- rownames(table) | |
table$cluster <- rep(i, nrow(table)) | |
return(table) | |
} | |
marker_results <- list()[n_clust] | |
ptm <- proc.time() | |
marker_results <- parallel::mclapply(n_clust, mcFindMarkers, mc.cores = 16) | |
time_diff <- proc.time() - ptm | |
time_diff | |
# nice way to flatten list into a single DF | |
markers <- dplyr::bind_rows(markers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very helpful--thank you! BTW, I think that
markers <- dplyr::bind_rows(markers)
should bemarkers <- dplyr::bind_rows(marker_results)