Closed browaeysrobin closed 9 months ago
Thanks for the kind words! Below is an example of how the gating plot can be generated, though note that you can change the marker identification step to use any DE/marker method of your choice.
library(ggplot2)
library(ggridges)
library(Seurat)
gating_plot <- function(data,clusts,ident.1,ident.2) {
markers <- FindMarkers(data,ident.1=ident.1,ident.2=ident.2,group.by=clusts)
markers <- markers[markers$p_val_adj<0.05,]
counts <- as.matrix(GetAssayData(data,slot='counts')[,clusts%in%c(ident.1,ident.2)])
up_sum <- colSums(counts[rownames(markers)[markers$avg_log2FC>0],])/colSums(counts)
down_sum <- colSums(counts[rownames(markers)[markers$avg_log2FC<0],])/colSums(counts)
labels <- clusts[clusts%in%c(ident.1,ident.2)]
p <- ggplot(data.frame(up.rates=up_sum,
down.rates=down_sum,
cluster=labels),
aes(x=up.rates,y=down.rates,color=cluster,fill=cluster))+
geom_point(alpha=0.5,size=0.5)+
theme_classic(base_size=12)+
ylab(ident.1)+xlab(ident.2)
print(ggExtra::ggMarginal(p,fill='gray'))
}
Hi @igrabski
Thank you!
Hi @igrabski
Thank you for developing this elegant and useful tool! I have a question related to the scRNA-seq gating plots that you show in your paper. Would you be willing to share the code to make these?