Post

Violin Plot P-value 포함

violin plot 그리면서 condition 별로 색 다시 지정하고, p-val 포함해서 그리는법

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
library(Seurat)
library(ggplot2)
library(ggrepel)
library(ggdendro)
library(ggsignif)

Mono <- readRDS("Mono_forDEG.rds")

Mono$Age_Infection_re <- as.character(Mono$Age_Infection)
Mono@meta.data[Mono$Age_Infection=="Young.negative","Age_Infection_re"] <- "Young.contorl"
Mono@meta.data[Mono$Age_Infection=="Old.negative","Age_Infection_re"] <- "Old.contorl"
Mono@meta.data[Mono$Age_Infection=="Young.positive","Age_Infection_re"] <- "Young.Infected"
Mono@meta.data[Mono$Age_Infection=="Old.positive","Age_Infection_re"] <- "Old.Infected"
Mono$Age_Infection_re <- factor(Mono$Age_Infection_re,levels=c("Young.contorl","Old.contorl","Young.Infected","Old.Infected"))

Idents(Mono) <- "Age_Infection_re"
my_comparisons <- list( c("Young.contorl", "Old.contorl"),c("Young.Infected", "Old.Infected"), c("Young.contorl", "Young.Infected"), c("Old.contorl", "Old.Infected"))
VlnPlot(Mono, features = "IFI6", pt.size=0,cols=c("#9ac9e6","#f5f5f5","#2b89c5","#3d3d3d")) +
    geom_signif(comparisons = my_comparisons,
              annotations = c(sprintf("*p = %.2g", 3.17e-306),"ns",sprintf("*p = %.2g", 0),"ns"),
              step_increase = 0.15) +
ylim(0, 8)
ggsave("IFI6_vln.png")

This post is licensed under CC BY 4.0 by the author.

© Subin Cho. Some rights reserved.

Using the Chirpy theme for Jekyll.