Skip to content

Instantly share code, notes, and snippets.

@FloWuenne
Created June 30, 2020 20:54
Show Gist options
  • Save FloWuenne/83b8fea1b7fd970075a921ea5a91ef09 to your computer and use it in GitHub Desktop.
Save FloWuenne/83b8fea1b7fd970075a921ea5a91ef09 to your computer and use it in GitHub Desktop.
Make a Featureplot style plot using schex from a Seurat object
feature_schex <- function(seurat_object,
gene_ids,
label = FALSE,
nbins = 150,
reduction = "UMAP",
assay = "SCT",
slot = "data",
action = "mean"){
require(Seurat)
require(schex)
seurat_object <- make_hexbin(seurat_object, nbins = nbins, dimension_reduction = reduction)
plot_list <- list()
for(gene in gene_ids){
print(gene)
schex_plot <- plot_hexbin_feature(seurat_object, type=slot, feature=gene,
action= action, xlab="UMAP 1", ylab="UMAP 2", mod = assay,
title= gene) +
theme_cowplot() +
theme(legend.position = "bottom")
plot_list[[gene]] <- schex_plot
}
return(plot_list)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment