setwd("~/Downloads")

library(Seurat)
## Attaching SeuratObject
library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
plasma = readRDS("plasma.rds")
plasma = subset(plasma, idents = c("Plasma 1","Plasma 2","Plasma 3","Plasma 4"))

#umap
DimPlot(plasma, reduction = "umap", label.box = F, label = T) & NoLegend()

#markers
plasma.markers = FindAllMarkers(plasma, only.pos = TRUE, min.pct = 0.25, logfc.threshold = 0.25)
## Calculating cluster Plasma 1
## Calculating cluster Plasma 2
## Calculating cluster Plasma 3
## Calculating cluster Plasma 4
top5 = plasma.markers %>% group_by(cluster) %>% top_n(n = 5, wt = avg_log2FC)

#dotplot
plot = DotPlot(object = plasma, features = unique(top5$gene), assay="RNA")
plot + coord_flip()