Chapter 6 Statistics of enriched signals

We can use the extracted data to draw any plot what you want. One example is that we can do some statistics for the enrichment signals across the samples.


6.1 Check extracted data

df.profile.data <- mat_df$profile

# check
head(df.profile.data,3)
#    density x sample split  lower_ci upper_ci   group split.group
# 1 2.082559 1    0 h     A 0.1148654 4.050253 H3H4me3      group1
# 2 2.152473 2    0 h     A 0.1412727 4.163673 H3H4me3      group1
# 3 2.250226 3    0 h     A 0.2950159 4.205437 H3H4me3      group1

6.2 Drawing boxplot

We can see the difference across different time point on multiple binding-site groups:

library(ggpubr)
library(ggh4x)

# plot
ggplot(df.profile.data,
       aes(x = sample,y = density,fill = sample)) +
  stat_boxplot(aes(ymin = ..lower.., ymax = ..upper..),outlier.shape = NA,width=0.5) +
  stat_boxplot(geom = "errorbar", aes(ymin = ..ymax..),width=0.2,size=0.35) +
  stat_boxplot(geom = "errorbar", aes(ymax = ..ymin..),width=0.2,size=0.35) +
  geom_boxplot(outlier.color = "grey90",outlier.alpha = 0.5,
               width=0.5,alpha = 0.5) +
  facet_nested(~split.group + split,
               nest_line = element_line(linetype = 1)) +
  theme_classic() +
  scale_fill_brewer(palette = "Paired") +
  theme(strip.background = element_blank(),
        axis.text = element_text(colour = "black"),
        strip.text = element_text(face = "bold.italic",size = rel(1)),
        ggh4x.facet.nestline = element_line(linewidth = 1,
                                            colour = "black")) +
  stat_compare_means(ref.group = "0 h",label = "p.signif")