This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Adding median value to VlnPlot in Seurat

How to add median value to the code for vlnplot:

plot_list <- list()
for (i in gene_list) {
  plot_list[[i]] <- FeaturePlot(data, features = i, split.by = "sample", cols = c("grey","blue"))
}
vplot_list <- list()
data$clusternum <- Idents(data)
for (i in gene_list) {
  vplot_list[[i]] <- VlnPlot(data, features = i, split.by = "sample", group.by = "clusternum",
    pt.size = 0, combine = FALSE)
}
for (i in gene_list) {
  ggsave(paste0("/home/mitralab/featureplot/","map_", i, "_0.2_raw.pdf"),plot = plot_list[[i]], width = 11, height = 8.5)
  pdf(paste0("/home/mitralab/vlnplot/","vin_", i, "_0.2_raw.pdf"), width = 11, height = 8.5)
   print(vplot_list[[i]])
  dev.off()
}
median seurat

1 answer

If you know ggplot2, you can get_expression_data function in here https://divingintogeneticsandgenomics.rbind.io/post/how-to-do-gene-correlation-for-single-cell-rnaseq-data-part-1/ to get the dataframe and use ggplot2 to plot the violin plot and add median or mean. https://r-charts.com/distribution/violin-plot-mean-ggplot2/

Log in to answer this question.