Last updated: 2021-09-10

Checks: 7 0

Knit directory: hesc-epigenomics/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20210202) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 1e75889. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    data/bed/
    Ignored:    data/bw/
    Ignored:    data/rnaseq/
    Ignored:    data_backup/
    Ignored:    figures_data/

Untracked files:
    Untracked:  Kumar_2021_hESC_data.zip
    Untracked:  analysis/sup_01_replicates.Rmd
    Untracked:  data/Lanner_lineagemarker_genes.csv
    Untracked:  data/Messmer_intermediate_down_top50.txt
    Untracked:  data/Messmer_intermediate_up_top50.txt
    Untracked:  data/meta/Kumar_2020_master_bins_10kb_table_final_raw.tsv
    Untracked:  data/meta/Kumar_2020_master_gene_table_rnaseq_shrunk_annotated.tsv
    Untracked:  output/

Unstaged changes:
    Modified:   .gitignore
    Modified:   analysis/fig_01_quantitative_chip.Rmd
    Modified:   analysis/fig_04_intermediate.Rmd
    Modified:   analysis/master_bins_table.Rmd
    Modified:   analysis/master_gene_table.Rmd
    Modified:   analysis/rnaseq_comparison.Rmd
    Deleted:    data/README.md
    Deleted:    data/meta/Court_2017_gene_names_uniq.txt
    Deleted:    data/meta/Kumar_2020_master_gene_table_rnaseq_shrunk_annotated.zip
    Deleted:    data/meta/Kumar_2020_public_data_plus_layout.csv
    Deleted:    data/meta/biblio.bib
    Deleted:    data/meta/colors.R
    Deleted:    data/meta/style_info.csv
    Deleted:    data/other/Messmer_2019/Messmer_intermediate_down_top50.txt
    Deleted:    data/other/Messmer_2019/Messmer_intermediate_up_top50.txt

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/fig_03_h3k27m3_groups.Rmd) and HTML (docs/fig_03_h3k27m3_groups.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 1e75889 C. Navarro 2021-09-10 Fig 3 clean
html 4018a69 C. Navarro 2021-07-15 Build site.
Rmd a042dd0 C. Navarro 2021-07-15 wflow_publish(“./analysis/fig_03_h3k27m3_groups.Rmd”, verbose = T)
html 6a92a76 C. Navarro 2021-07-09 Build site.
Rmd d9e2a8f C. Navarro 2021-07-09 wflow_publish(“./analysis/fig_03_h3k27m3_groups.Rmd”, verbose = T)
html e846502 C. Navarro 2021-07-09 Build site.
Rmd d50d87a C. Navarro 2021-07-09 wflow_publish(“./analysis/fig_03_h3k27m3_groups.Rmd”, verbose = T)
html daf3d4a C. Navarro 2021-07-08 Build site.
Rmd 4d534a3 C. Navarro 2021-07-08 wflow_publish(“./analysis/fig_03_h3k27m3_groups.Rmd”, verbose = T)
html 7117e7a C. Navarro 2021-07-08 Build site.
Rmd 394d32e C. Navarro 2021-07-08 wflow_publish(“./analysis/fig_03_h3k27m3_groups.Rmd”, verbose = T)
html 67895c5 C. Navarro 2021-07-01 Build site.
Rmd 70ee455 C. Navarro 2021-07-01 wflow_publish(“./analysis/fig_03_h3k27m3_groups.Rmd”)

Summary

This is the supplementary notebook for figure 3.

H3K27m3 groups

H3K27m3 group selection

k27_groups <- split(genes, genes$k27_bivalency_grp)
k27_groups_loci <- lapply(k27_groups, make_gr_from_table)

H3K27m3 alluvial plot

gr_annot <-
  genes %>% dplyr::select(name, seqnames, start, end, strand,
    H3K4m3_DS_Pr_vs_Ni_log2FoldChange,
    H3K27m3_DS_Pr_vs_Ni_log2FoldChange,
    H2Aub_DS_Pr_vs_Ni_log2FoldChange,
    H3K4m3_DS_Pr_vs_Ni_padj,
    H3K27m3_DS_Pr_vs_Ni_padj,
    H2Aub_DS_Pr_vs_Ni_padj
  )

gr_annot <- gr_annot %>% mutate(
   k4 = factor(case_when(
     H3K4m3_DS_Pr_vs_Ni_padj < pval_cutoff & H3K4m3_DS_Pr_vs_Ni_log2FoldChange > fc_cutoff ~ "Pr >> Ni",
     H3K4m3_DS_Pr_vs_Ni_padj < pval_cutoff & H3K4m3_DS_Pr_vs_Ni_log2FoldChange < -fc_cutoff ~ "Ni >> Pr",
     TRUE ~ "unchanged")
   ),
   k27 = factor(case_when(
     H3K27m3_DS_Pr_vs_Ni_padj < pval_cutoff & H3K27m3_DS_Pr_vs_Ni_log2FoldChange > fc_cutoff ~ "Pr >> Ni",
     H3K27m3_DS_Pr_vs_Ni_padj < pval_cutoff & H3K27m3_DS_Pr_vs_Ni_log2FoldChange < -fc_cutoff ~ "Ni >> Pr",
     TRUE ~ "unchanged")
   ),
   ub = factor(case_when(
     H2Aub_DS_Pr_vs_Ni_padj < pval_cutoff & H2Aub_DS_Pr_vs_Ni_log2FoldChange > fc_cutoff ~ "Pr >> Ni",
     H2Aub_DS_Pr_vs_Ni_padj < pval_cutoff & H2Aub_DS_Pr_vs_Ni_log2FoldChange < -fc_cutoff ~ "Ni >> Pr",
     TRUE ~ "unchanged")
   ))

counts_table <- gr_annot %>% dplyr::count(k4, k27, ub)

ggplot(counts_table, aes(y = n, axis1 = k4, axis2 = k27, axis3 = ub, fill = k27)) + 
  geom_alluvium(width = 1 / 12) +
  geom_stratum(width = 1 / 12, color = "black") + 
  geom_text(stat = "stratum", aes(label = after_stat(stratum)), nudge_x = -0.08, angle = 90, size = 3) + 
  scale_fill_manual(values = c("#278b8b",  "#f44b34", "#cccccc")) +
  theme_default() + 
  scale_x_discrete(limits = c("H3K4m3", "H3K27m3", "H2AUb"), expand = c(.05, .05)) 

H3K27m3 group heatmap panels

H3K27m3 and H2AUb

plot_bw_heatmap_panel(
    c(bwfiles$k27[c(1, 3)], bwfiles$ub[c(1, 3)]),
    list(k27_groups_loci$Pr_higher_than_Ni,
         k27_groups_loci$Ni_higher_than_Pr,
         k27_groups_loci$Always_up
    ),
    c("H3K27m3_Ni", "H3K27m3_Pr", "H2Aub_Ni", "H2Aub_Pr"),
    c("Primed >> Naive", "Naive >> Primed", "Always up"),
    global_scale = TRUE,
    proportional = TRUE,
    mode = "center"
)

Version Author Date
e846502 C. Navarro 2021-07-09
67895c5 C. Navarro 2021-07-01

Plot the second part of the heatmap panel.

plot_bw_heatmap_panel(
  c(bwfiles$k27[c(1, 3)], bwfiles$ub[c(1, 3)]),
  list(k27_groups_loci$Pr_higher_than_Ni, k27_groups_loci$K4_only),
  c("H3K27m3_Ni", "H3K27m3_Pr", "H2Aub_Ni", "H2Aub_Pr"),
  c("Primed >> Naive", "Rest"),
  global_scale = TRUE,
  proportional = TRUE,
  mode = "center",
  zmin = 0,
  zmax = 23
)

Version Author Date
e846502 C. Navarro 2021-07-09
67895c5 C. Navarro 2021-07-01

H3K4m3

Plot the H3K4m3 part, sorted by the same reference

plot_bw_heatmap_panel(
    c(bwfiles$k27[1], bwfiles$k4[c(1, 3)]),
    list(k27_groups_loci$Pr_higher_than_Ni,
         k27_groups_loci$Ni_higher_than_Pr,
         k27_groups_loci$Always_up
    ),
    c("H3K27m3_Ni", "H3K4m3_Ni", "H3K4m3_Pr"),
    c("Primed >> Naive", "Naive >> Primed", "Always up"),
    global_scale = TRUE,
    proportional = TRUE,
    mode = "center",
    zmin = 0,
    zmax = 188
)

Version Author Date
6a92a76 C. Navarro 2021-07-09
e846502 C. Navarro 2021-07-09
7117e7a C. Navarro 2021-07-08
plot_bw_heatmap_panel(
  c(bwfiles$k27[1], bwfiles$k4[c(1, 3)]),
  list(k27_groups_loci$Pr_higher_than_Ni, k27_groups_loci$K4_only),
  c("H3K27m3_Ni", "H3K4m3_Ni", "H2Aub_Pr"),
  c("Primed >> Naive", "Rest"),
  global_scale = TRUE,
  proportional = TRUE,
  mode = "center"
)

Version Author Date
4018a69 C. Navarro 2021-07-15
6a92a76 C. Navarro 2021-07-09
e846502 C. Navarro 2021-07-09

RNA-seq ratios at H3K27m3 groups

H327m3 Naive >> Primed

df <-
  genes[, c(
    "name",
    "RNASeq_DS_Pr_vs_Ni_log2FoldChange",
    "RNASeq_DS_EZH2i_vs_Ni_log2FoldChange",
    "RNASeq_DS_EZH2i_vs_Pr_log2FoldChange"
  )]

colnames(df) <- c("name", "Primed vs Naive", "EZH2i vs Naive", "EZH2i vs Primed")
df_k27_up <- df[df$name %in% k27_groups_loci$Ni_higher_than_Pr$name, ]

df_long <- df %>% pivot_longer(!name, names_to = "group", values_to = "fc")
df_long_k27 <- df_k27_up %>% pivot_longer(!name, names_to = "group", values_to = "fc")

df_long$group <- factor(df_long$group, levels = c("Primed vs Naive", "EZH2i vs Naive", "EZH2i vs Primed"))
df_long_k27$group <- factor(df_long_k27$group, levels = c("Primed vs Naive", "EZH2i vs Naive", "EZH2i vs Primed"))

# Stats subset vs global
ni_pr_test <- wilcox.test(df_k27_up[, "Primed vs Naive"],
  df[!df$name %in% df_k27_up$name , "Primed vs Naive"], na.rm = T)

ni_pr_effect <- cohen.d(df_k27_up[, "Primed vs Naive"],
  df[!df$name %in% df_k27_up$name , "Primed vs Naive"], na.rm = T)

col <- "EZH2i vs Naive"
ni_ezh2i_test <- wilcox.test(df_k27_up[, col],
  df[!df$name %in% df_k27_up$name , col], na.rm = T)

ni_ezh2i_effect <- cohen.d(df_k27_up[, col],
  df[!df$name %in% df_k27_up$name , col], na.rm = T)

col <- "EZH2i vs Primed"
pr_ezh2i_test <- wilcox.test(df_k27_up[, col],
  df[!df$name %in% df_k27_up$name , col], na.rm = T)

pr_ezh2i_effect <- cohen.d(df_k27_up[, col],
  df[!df$name %in% df_k27_up$name , col], na.rm = T)

stats_caption <- paste("Wilcoxon global vs. selection",
  paste("Ni_Pr:", format(ni_pr_test$p.value, digits=8),
        "Cohen D:", round(ni_pr_effect$estimate, digits = 4),
        "(", ni_pr_effect$magnitude, ")"),
  paste("Ni_EZH2i:", format(ni_ezh2i_test$p.value, digits=8),
        "Cohen D:", round(ni_ezh2i_effect$estimate, digits = 4),
        "(", ni_ezh2i_effect$magnitude, ")"),
  paste("Pr_EZH2i:", format(pr_ezh2i_test$p.value, digits=8),
        "Cohen D:", round(pr_ezh2i_effect$estimate, digits = 4),
        "(", pr_ezh2i_effect$magnitude, ")"),
  sep = "\n")

my_comparisons <- list(c("EZH2i vs Naive", "EZH2i vs Primed"),
                       c("Primed vs Naive", "EZH2i vs Naive"),
                       c("Primed vs Naive", "EZH2i vs Primed"))

k27_up_color <- "#009784"

ggplot(data=df_long, aes(x = group, y = fc)) +
  geom_violin(size = 0.8) +
  stat_compare_means(data=df_long_k27,
    comparisons = my_comparisons, method = "wilcox.test", paired = TRUE) +
  rasterize(
    geom_jitter(data=df_long_k27, color = k27_up_color, alpha = 0.7, size = 0.1),
    dpi = 300) +
  geom_hline (yintercept = 0, linetype = "dashed") + 
  coord_cartesian(ylim = c(-13, 24)) +
  theme_default(base_size = 14) + 
  labs(x = "Condition",
       y = "Log2 FC",
       title = "RNASeq expression changes",
       subtitle = "Global vs H3K27m3 Naïve >> Primed TSS",
       caption = stats_caption)

Version Author Date
e846502 C. Navarro 2021-07-09
67895c5 C. Navarro 2021-07-01

Download values: Distribution, K27 higher naive points,

H327m3 Primed >> Naive

df <-
  genes[, c(
    "name",
    "RNASeq_DS_Pr_vs_Ni_log2FoldChange",
    "RNASeq_DS_EZH2i_vs_Ni_log2FoldChange",
    "RNASeq_DS_EZH2i_vs_Pr_log2FoldChange"
  )]

colnames(df) <- c("name", "Primed vs Naive", "EZH2i vs Naive", "EZH2i vs Primed")

df_k27_up <- df[df$name %in% k27_groups_loci$Pr_higher_than_Ni$name, ]

df_k27_up$`Primed vs Naive` <- -df_k27_up$`Primed vs Naive`
df$`Primed vs Naive` <- -df$`Primed vs Naive`

df_long <- df %>% pivot_longer(!name, names_to = "group", values_to = "fc")
df_long_k27 <- df_k27_up %>% pivot_longer(!name, names_to = "group", values_to = "fc")

df_long$group <- factor(df_long$group, levels = c("Primed vs Naive", "EZH2i vs Naive", "EZH2i vs Primed"))
df_long_k27$group <- factor(df_long_k27$group, levels = c("Primed vs Naive", "EZH2i vs Naive", "EZH2i vs Primed"))

levels(df_long$group) <- c("Naive vs Primed", "EZH2i vs Naive", "EZH2i vs Primed")
levels(df_long_k27$group) <- c("Naive vs Primed", "EZH2i vs Naive", "EZH2i vs Primed")

my_comparisons <- list(c("EZH2i vs Naive", "EZH2i vs Primed"),
                       c("Naive vs Primed", "EZH2i vs Naive"),
                       c("Naive vs Primed", "EZH2i vs Primed"))

# Stats subset vs global
ni_pr_test <- wilcox.test(df_k27_up[, "Primed vs Naive"],
  df[!df$name %in% df_k27_up$name , "Primed vs Naive"], na.rm = T)

ni_pr_effect <- cohen.d(df_k27_up[, "Primed vs Naive"],
  df[!df$name %in% df_k27_up$name , "Primed vs Naive"], na.rm = T)

col <- "EZH2i vs Naive"
ni_ezh2i_test <- wilcox.test(df_k27_up[, col],
  df[!df$name %in% df_k27_up$name , col], na.rm = T)

ni_ezh2i_effect <- cohen.d(df_k27_up[, col],
  df[!df$name %in% df_k27_up$name , col], na.rm = T)

col <- "EZH2i vs Primed"
pr_ezh2i_test <- wilcox.test(df_k27_up[, col],
  df[!df$name %in% df_k27_up$name , col], na.rm = T)

pr_ezh2i_effect <- cohen.d(df_k27_up[, col],
  df[!df$name %in% df_k27_up$name , col], na.rm = T)

stats_caption <- paste("Wilcoxon global vs. selection",
  paste("Ni_Pr:", format(ni_pr_test$p.value, digits=8),
        "Cohen D:", round(ni_pr_effect$estimate, digits = 4),
        "(", ni_pr_effect$magnitude, ")"),
  paste("Ni_EZH2i:", format(ni_ezh2i_test$p.value, digits=8),
        "Cohen D:", round(ni_ezh2i_effect$estimate, digits = 4),
        "(", ni_ezh2i_effect$magnitude, ")"),
  paste("Pr_EZH2i:", format(pr_ezh2i_test$p.value, digits=8),
        "Cohen D:", round(pr_ezh2i_effect$estimate, digits = 4),
        "(", pr_ezh2i_effect$magnitude, ")"),
  sep = "\n")

k27_up_color <- "#ff4b40"

ggplot(data=df_long, aes(x = group, y = fc)) +
  geom_violin(size = 0.8) +
  stat_compare_means(
    data=df_long_k27, comparisons = my_comparisons,
    method = "wilcox.test", paired = TRUE) +
  rasterize(
    geom_jitter(data=df_long_k27, color = k27_up_color, alpha = 0.7, size = 0.1),
    dpi = 300) +
  geom_hline (yintercept = 0, linetype = "dashed") + 
  coord_cartesian(ylim = c(-13, 24)) +
  theme_default(base_size = 14) + 
  labs(x = "Condition",
       y = "Log2 FC",
       title = "RNASeq expression changes",
       subtitle = "Global vs H3K27m3 Primed >> Naïve TSS",
       caption = stats_caption)

Version Author Date
e846502 C. Navarro 2021-07-09
67895c5 C. Navarro 2021-07-01
write.table(df_long[!is.na(df_long$fc), ],
  file = "./figures_data/fig3_violin_k27_pr_higher_violin.tsv",
  col.names = T, sep = "\t", quote = F, row.names = F)

write.table(df_long_k27[!is.na(df_long_k27$fc), ],
  file = "./figures_data/fig3_violin_k27_pr_higher_jitter_k27_values.tsv",
  col.names = T, sep = "\t", quote = F, row.names = F)

Download values: K27 primed higher points.

H327m3 always high

df <-
  genes[, c(
    "name",
    "RNASeq_DS_Pr_vs_Ni_log2FoldChange",
    "RNASeq_DS_EZH2i_vs_Ni_log2FoldChange",
    "RNASeq_DS_EZH2i_vs_Pr_log2FoldChange"
  )]

colnames(df) <- c("name", "Primed vs Naive", "EZH2i vs Naive", "EZH2i vs Primed")

df_k27_up <- df[df$name %in% k27_groups_loci$Always_up$name, ]

df_k27_up$`Primed vs Naive` <- -df_k27_up$`Primed vs Naive`
df$`Primed vs Naive` <- -df$`Primed vs Naive`

df_long <- df %>% pivot_longer(!name, names_to = "group", values_to = "fc")
df_long_k27 <- df_k27_up %>% pivot_longer(!name, names_to = "group", values_to = "fc")

df_long$group <- factor(df_long$group, levels = c("Primed vs Naive", "EZH2i vs Naive", "EZH2i vs Primed"))
df_long_k27$group <- factor(df_long_k27$group, levels = c("Primed vs Naive", "EZH2i vs Naive", "EZH2i vs Primed"))

levels(df_long$group) <- c("Naive vs Primed", "EZH2i vs Naive", "EZH2i vs Primed")
levels(df_long_k27$group) <- c("Naive vs Primed", "EZH2i vs Naive", "EZH2i vs Primed")

my_comparisons <- list(c("EZH2i vs Naive", "EZH2i vs Primed"),
                       c("Naive vs Primed", "EZH2i vs Naive"),
                       c("Naive vs Primed", "EZH2i vs Primed"))

# Stats subset vs global
ni_pr_test <- wilcox.test(df_k27_up[, "Primed vs Naive"],
  df[!df$name %in% df_k27_up$name , "Primed vs Naive"], na.rm = T)

ni_pr_effect <- cohen.d(df_k27_up[, "Primed vs Naive"],
  df[!df$name %in% df_k27_up$name , "Primed vs Naive"], na.rm = T)

col <- "EZH2i vs Naive"
ni_ezh2i_test <- wilcox.test(df_k27_up[, col],
  df[!df$name %in% df_k27_up$name , col], na.rm = T)

ni_ezh2i_effect <- cohen.d(df_k27_up[, col],
  df[!df$name %in% df_k27_up$name , col], na.rm = T)

col <- "EZH2i vs Primed"
pr_ezh2i_test <- wilcox.test(df_k27_up[, col],
  df[!df$name %in% df_k27_up$name , col], na.rm = T)

pr_ezh2i_effect <- cohen.d(df_k27_up[, col],
  df[!df$name %in% df_k27_up$name , col], na.rm = T)

stats_caption <- paste("Wilcoxon global vs. selection",
  paste("Ni_Pr:", format(ni_pr_test$p.value, digits=8),
        "Cohen D:", round(ni_pr_effect$estimate, digits = 4),
        "(", ni_pr_effect$magnitude, ")"),
  paste("Ni_EZH2i:", format(ni_ezh2i_test$p.value, digits=8),
        "Cohen D:", round(ni_ezh2i_effect$estimate, digits = 4),
        "(", ni_ezh2i_effect$magnitude, ")"),
  paste("Pr_EZH2i:", format(pr_ezh2i_test$p.value, digits=8),
        "Cohen D:", round(pr_ezh2i_effect$estimate, digits = 4),
        "(", pr_ezh2i_effect$magnitude, ")"),
  sep = "\n")

k27_up_color <- "#4463b9"

ggplot(data=df_long, aes(x = group, y = fc)) +
  geom_violin(size = 0.8) +
  stat_compare_means(
    data=df_long_k27, comparisons = my_comparisons,
    method = "wilcox.test", paired = TRUE) +
  rasterize(
    geom_jitter(data=df_long_k27, color = k27_up_color, alpha = 0.7, size = 0.1),
    dpi = 300) +
  geom_hline (yintercept = 0, linetype = "dashed") + 
  coord_cartesian(ylim = c(-13, 24)) +
  theme_default(base_size = 14) + 
  labs(x = "Condition",
       y = "Log2 FC",
       title = "RNASeq expression changes",
       subtitle = "Global vs H3K27m3 H3K27m3 always up TSS",
       caption = stats_caption)

Version Author Date
4018a69 C. Navarro 2021-07-15
write.table(df_long[!is.na(df_long$fc), ],
  file = "./figures_data/fig3_violin_k27_always_up_violin.tsv",
  col.names = T, sep = "\t", quote = F, row.names = F)

write.table(df_long_k27[!is.na(df_long_k27$fc), ],
  file = "./figures_data/fig3_violin_k27_always_up_jitter_k27_values.tsv",
  col.names = T, sep = "\t", quote = F, row.names = F)

Download values: K27 always up points.

Combined heatmaps

Naive markers

naive_markers <-
  c("KLF17",
    "DPPA5",
    "DNMT3L",
    "GATA6",
    "TBX3",
    "IL6ST",
    "DPPA3",
    "KLF5",
    "KLF4",
    "HORMAD1",
    "KHDC3L",
    "ALPP",
    "ALPPL2",
    "ZNF729",
    "TRIM60"
  )

tpm_cols <- grep("RNASeq_TPM", colnames(genes), value = T)
cols_used <- c("name", "H3K27m3_Ni_mean_cov", "H3K27m3_Pr_mean_cov", "H3K27m3_Ni_EZH2i_mean_cov", "H3K27m3_Pr_EZH2i_mean_cov",
               "H3K4m3_Ni_mean_cov", "H3K4m3_Pr_mean_cov", "H3K4m3_Ni_EZH2i_mean_cov", "H3K4m3_Pr_EZH2i_mean_cov",
               "H2Aub_Ni_mean_cov", "H2Aub_Pr_mean_cov",  "H2Aub_Ni_EZH2i_mean_cov", "H2Aub_Pr_EZH2i_mean_cov",
               tpm_cols)

values <- genes[genes$name %in% naive_markers, cols_used]
values[, tpm_cols] <- log2(values[, tpm_cols] + 1)

write.table(values, "./figures_data/fig3_messmer_naive_heatmap_global_scale.tsv")

fig <- combined_heatmap(
  genes,
  naive_markers,
  rnaseq_limits = c(0, 11.5),
  k4m3_limits = c(0, 90),
  k27m3_limits = c(0, 8),
  ub_limits = c(0, 11)
)

fig 
orca(fig, "./output/fig3_messmer_naive_heatmap_global_scale.svg", width = 9, height = 9, more_args = c('--disable-gpu'))

Primed markers

primed_markers <-
  c("CD24",
    "ZIC2",
    "SFRP2",
    "OTX2",
    "CYTL1",
    "HMX2",
    "THY1",
    "DUSP6",
    "PTPRZ1"
  )

values <- genes[genes$name %in% primed_markers, cols_used]
values[, tpm_cols] <- log2(values[, tpm_cols] + 1)

write.table(values, "./figures_data/fig3_messmer_primed_heatmap_global_scale.tsv")

fig <- combined_heatmap(
  genes,
  primed_markers,
  rnaseq_limits = c(0, 11.5),
  k4m3_limits = c(0, 90),
  k27m3_limits = c(0, 8),
  ub_limits = c(0, 11)
)

fig
orca(fig, "./output/fig3_messmer_primed_heatmap_global_scale.svg", width = 9, height = 9, more_args = c('--disable-gpu'))

Other figures

H3K27m3 promoter volcano plot

genes_tss <- makeGRangesFromDataFrame(genes, keep.extra.columns = T)
court_peaks <- import("./data/bed/Bivalent_Court2017.hg38.bed")
court_tss <- subsetByOverlaps(genes_tss, court_peaks)

court_tss_df <- data.frame(court_tss)

ggplot(genes, aes(x=H3K27m3_DS_Pr_vs_Ni_log2FoldChange, y=-log10(H3K27m3_DS_Pr_vs_Ni_padj))) +
    rasterise(geom_point(size = 1, alpha = 0.7, color = "gray"), dpi = 300) +
    theme_default(base_size = 12) +
    rasterise(geom_point(data = court_tss_df, size = 1, alpha = 0.8, color = "black"), dpi = 300) +
      labs(x = "Log2 FC (primed/naive)",
         y = "Log10 pval", title = "Promoter H3K27m3 - Court 2017 bivalent in black") +
    geom_hline(yintercept = -log10(0.05), linetype = "dashed") +
    geom_vline(xintercept = 0) +
    coord_cartesian(xlim = c(-6,6), ylim = c(0, 20))

Version Author Date
daf3d4a C. Navarro 2021-07-08
7117e7a C. Navarro 2021-07-08
df <- genes[, c("H3K27m3_DS_Pr_vs_Ni_log2FoldChange", "H3K27m3_DS_Pr_vs_Ni_padj")]
df[, "H3K27m3_DS_Pr_vs_Ni_padj"] <- -log10(df[, "H3K27m3_DS_Pr_vs_Ni_padj"])

write.table(df, "./figures_data/fig3_h3k27m3_promoter_volcano_all.tsv", sep = "\t", row.names = F)

df <- court_tss_df[, c("H3K27m3_DS_Pr_vs_Ni_log2FoldChange", "H3K27m3_DS_Pr_vs_Ni_padj")]
df[, "H3K27m3_DS_Pr_vs_Ni_padj"] <- -log10(df[, "H3K27m3_DS_Pr_vs_Ni_padj"])
write.table(df, "./figures_data/fig3_h3k27m3_promoter_volcano_court.tsv", sep = "\t", row.names = F)

Piled up profiles

plot_func <-
  purrr::partial(
    plot_bw_profile,
    loci = k27_groups_loci[c("Pr_higher_than_Ni", "Ni_higher_than_Pr", "Always_up", "K4_only")],
    labels = c("Pr >> Ni", "Ni >> Pr", "Always up", "Not enriched"),
    colors = c("#092ba8", "#5f9ea0", "#cccccc", "#f47770"),
    mode = "center",
    verbose = F
  )

plot_func(bwfiles$k4[1]) + 
  labs(title = "H3K4m3 Naive", subtitle = "Loci: H3K27m3 groups")

plot_func(bwfiles$k4[2]) + 
  labs(title = "H3K4m3 Naive + EZH2i", subtitle = "Loci: H3K27m3 groups")

plot_func(bwfiles$k4[3]) + 
  labs(title = "H3K4m3 Primed", subtitle = "Loci: H3K27m3 groups")

plot_func(bwfiles$k4[4]) + 
  labs(title = "H3K4m3 Primed + EZH2i", subtitle = "Loci: H3K27m3 groups")

plot_func(bwfiles$k27[1]) + 
  labs(title = "H3K27m3 Naive", subtitle = "Loci: H3K27m3 groups") + 
  coord_cartesian(ylim = c(0, 6))

plot_func(bwfiles$k27[2]) + 
  labs(title = "H3K27m3 Naive + EZH2i", subtitle = "Loci: H3K27m3 groups") + 
  coord_cartesian(ylim = c(0, 6))

plot_func(bwfiles$k27[3]) + 
  labs(title = "H3K27m3 Primed", subtitle = "Loci: H3K27m3 groups") + 
  coord_cartesian(ylim = c(0, 6))

plot_func(bwfiles$k27[4]) + 
  labs(title = "H3K27m3 Primed + EZH2i", subtitle = "Loci: H3K27m3 groups") + 
  coord_cartesian(ylim = c(0, 6))

plot_func(bwfiles$ub[1]) + 
  labs(title = "H2Aub Naive", subtitle = "Loci: H3K27m3 groups")

plot_func(bwfiles$ub[2]) + 
  labs(title = "H2Aub Naive + EZH2i", subtitle = "Loci: H3K27m3 groups")

plot_func(bwfiles$ub[3]) + 
  labs(title = "H2Aub Primed", subtitle = "Loci: H3K27m3 groups")

plot_func(bwfiles$ub[4]) + 
  labs(title = "H2Aub Primed + EZH2i", subtitle = "Loci: H3K27m3 groups")


sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=sv_SE.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=sv_SE.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=sv_SE.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=sv_SE.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] parallel  stats4    stats     graphics  grDevices utils     datasets 
[8] methods   base     

other attached packages:
 [1] svglite_2.0.0        heatmaply_1.2.1      viridis_0.6.1       
 [4] viridisLite_0.4.0    plotly_4.9.4.1       wigglescout_0.13.1  
 [7] ggalluvial_0.12.3    cowplot_1.1.1        ggrastr_0.2.3       
[10] ggpubr_0.4.0         effsize_0.8.1        forcats_0.5.1       
[13] stringr_1.4.0        dplyr_1.0.7          purrr_0.3.4         
[16] readr_1.4.0          tidyr_1.1.3          tibble_3.1.4        
[19] ggplot2_3.3.5        tidyverse_1.3.1      rtracklayer_1.52.0  
[22] GenomicRanges_1.44.0 GenomeInfoDb_1.28.1  IRanges_2.26.0      
[25] S4Vectors_0.30.0     BiocGenerics_0.38.0  workflowr_1.6.2     

loaded via a namespace (and not attached):
  [1] readxl_1.3.1                backports_1.2.1            
  [3] systemfonts_1.0.2           plyr_1.8.6                 
  [5] lazyeval_0.2.2              crosstalk_1.1.1            
  [7] BiocParallel_1.26.0         listenv_0.8.0              
  [9] digest_0.6.27               foreach_1.5.1              
 [11] htmltools_0.5.2             fansi_0.5.0                
 [13] magrittr_2.0.1              openxlsx_4.2.4             
 [15] globals_0.14.0              Biostrings_2.60.2          
 [17] modelr_0.1.8                matrixStats_0.60.1         
 [19] askpass_1.1                 colorspace_2.0-2           
 [21] rvest_1.0.0                 haven_2.4.1                
 [23] xfun_0.24                   crayon_1.4.1               
 [25] RCurl_1.98-1.4              jsonlite_1.7.2             
 [27] iterators_1.0.13            glue_1.4.2                 
 [29] registry_0.5-1              gtable_0.3.0               
 [31] zlibbioc_1.38.0             XVector_0.32.0             
 [33] webshot_0.5.2               DelayedArray_0.18.0        
 [35] car_3.0-11                  abind_1.4-5                
 [37] scales_1.1.1                DBI_1.1.1                  
 [39] rstatix_0.7.0               Rcpp_1.0.7                 
 [41] foreign_0.8-81              htmlwidgets_1.5.3          
 [43] httr_1.4.2                  RColorBrewer_1.1-2         
 [45] ellipsis_0.3.2              pkgconfig_2.0.3            
 [47] XML_3.99-0.7                farver_2.1.0               
 [49] sass_0.4.0                  dbplyr_2.1.1               
 [51] utf8_1.2.2                  tidyselect_1.1.1           
 [53] labeling_0.4.2              rlang_0.4.11               
 [55] reshape2_1.4.4              later_1.3.0                
 [57] munsell_0.5.0               cellranger_1.1.0           
 [59] tools_4.1.1                 cli_3.0.1                  
 [61] generics_0.1.0              broom_0.7.8                
 [63] evaluate_0.14               fastmap_1.1.0              
 [65] yaml_2.2.1                  processx_3.5.2             
 [67] knitr_1.33                  fs_1.5.0                   
 [69] zip_2.2.0                   dendextend_1.15.1          
 [71] future_1.21.0               whisker_0.4                
 [73] xml2_1.3.2                  compiler_4.1.1             
 [75] rstudioapi_0.13             beeswarm_0.4.0             
 [77] curl_4.3.2                  ggsignif_0.6.2             
 [79] reprex_2.0.0                bslib_0.2.5.1              
 [81] stringi_1.7.4               ps_1.6.0                   
 [83] highr_0.9                   lattice_0.20-44            
 [85] Matrix_1.3-4                vctrs_0.3.8                
 [87] pillar_1.6.2                lifecycle_1.0.0            
 [89] furrr_0.2.3                 jquerylib_0.1.4            
 [91] data.table_1.14.0           bitops_1.0-7               
 [93] seriation_1.3.0             httpuv_1.6.2               
 [95] R6_2.5.1                    BiocIO_1.2.0               
 [97] promises_1.2.0.1            TSP_1.1-10                 
 [99] gridExtra_2.3               rio_0.5.27                 
[101] vipor_0.4.5                 parallelly_1.26.1          
[103] codetools_0.2-18            assertthat_0.2.1           
[105] SummarizedExperiment_1.22.0 openssl_1.4.4              
[107] rprojroot_2.0.2             rjson_0.2.20               
[109] withr_2.4.2                 GenomicAlignments_1.28.0   
[111] Rsamtools_2.8.0             GenomeInfoDbData_1.2.6     
[113] hms_1.1.0                   grid_4.1.1                 
[115] rmarkdown_2.9               MatrixGenerics_1.4.0       
[117] carData_3.0-4               Cairo_1.5-12.2             
[119] git2r_0.28.0                Biobase_2.52.0             
[121] lubridate_1.7.10            ggbeeswarm_0.6.0           
[123] restfulr_0.0.13