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 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! 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 701a84d. 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:
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/annotations.Rmd) and HTML (docs/annotations.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.
This notebook shows how the genome annotations relevant for this publication were calculated.
Gene annotation: Genes obtained from UCSC hg38.
Bivalent genes: Genes from UCSC hg38 overlapping with bivalent peaks from (Court and Arnaud 2017).
Differential TSS per histone mark: H2AUb and H3K4m3 +/- 1500 bp used. H3K27m3: +/- 2500bp used, as this is a broader mark. DESeq2 (Love, Huber, and Anders 2014) was used ad-hoc for our Minute-ChIP data. See deseq_functions.R for more details. Naïve condition was used as reference for enrichment / depletion. Genes were selected if adjusted p value from DESeq2 was lower than 0.05 and absolute value of log2 fold change was > 1. A separate annotation was created for genes selected by this procedure that overlapped with bivalent genes: H2AUb, H3K4m3, H3K27m3.
Differential 10000 bp bins per histone mark: DESeq2 was used in the same way as differential TSS. Bins were selected by p-value only. These results are cached and / or skipped in this notebook because this is a very memory-demanding step: H2AUb, H3K4m3, H3K27m3.
Gene expression groups: Data from (Collier et al. 2017) was used to select top-med-low groups of genes by expression. Genes were pre-filtered by transcript length (> 500) and minimum TPM (0.01) and top, med and low 10% of genes were retained per replicate. Genes were annotated to each of these categories if they appeared in all three replicates within the given range. Downloads: Naïve top, med and low. Primed top, med and low.
Differentially expressed genes: Data from (Collier et al. 2017) was analysed with DESeq2 to obtain Naïve vs. Primed differentially expressed genes. Genes were selected if adjusted p value from DESeq2 was lower than 0.05 and absolute value of log2 fold change was > 1. Downloads: Naïve_up, Naïve_down.
Master gene table. All gene-specific annotations above are summarized in a gene table. Each gene along with their locus has a column for each histone mark and also expression data.
Helper functions
#' Select DESeq results by pval and fc cutoff and returns GRanges
#'
#' @param diff_lfc Results dataframe
#' @param loci Corresponding GRanges
#' @param p_cutoff Pvalue cutoff
#' @param fc_cutoff Fold change cutoff
#'
#' @return GRanges with filtered elements
select_signif <- function(diff_lfc, loci, p_cutoff = 0.05, fc_cutoff = 1) {
diff_lfc <- diff_lfc[!is.na(diff_lfc$padj), ]
signif_tss <- diff_lfc[diff_lfc$padj <= p_cutoff & abs(diff_lfc$log2FoldChange) > fc_cutoff, ]
mcols(loci) <- NULL
signif_gr <- loci[as.numeric(rownames(signif_tss)), ]
signif_gr$score <- signif_tss$log2FoldChange
signif_gr
}
#' Intersect 3 gene results by gene name
#'
#' @param glist List of gene results
#' @param field Field used to intersect
#'
#' @return A list of intersecting elements
intersect_genes_3 <- function(glist, field = "gene_id") {
intersect(intersect(glist[[1]][[field]],
glist[[2]][[field]]),
glist[[3]][[field]])
}
#' Subset a named granges by name
#'
#' @param names Names list
#' @param granges GRanges to subset.
#'
#' @return GRanges
select_genes <- function(names, granges) {
sort(granges[granges$name %in% names, ])
}
#' Export genes that overlap in a set of replicates (3)
#'
#' @param replicates Gene counts results list
#' @param path Output file
export_gene_set <- function(replicates, path) {
gene_names <- intersect_genes_3(replicates)
genes_all <- genes_hg38()
genes_all <- genes_all[, "name"]
result <- select_genes(gene_names, genes_all)
export(result, path)
}
#' Select by quantile
#'
#' @param counts Counts table.
#' @param length_cutoff Gene length cutoff.
#' @param value_cutoff Value cutoff
#' @param min_q Minimum quantile to consider
#' @param max_q Maximum quantile to consider
#' @param field Which field to use (default = TPM).
#'
#' @return filtered data.frame
quantile_group <- function(counts, min_q, max_q,
value_cutoff = 0,
length_cutoff = 500,
field = "TPM") {
counts <- dplyr::filter(counts, .data[[field]] > value_cutoff &
length > length_cutoff)
q <- quantile(counts[, field], probs = c(min_q, max_q))
dplyr::filter(counts, .data[[field]] >= q[1] & .data[[field]] <= q[2])
}
Gene annotation
Gene annotation is obtained from UCSC hg38 annotation.
genes <- genes_hg38()
Only genes that have a gene symbol associated to it are kept, leaving a set of 25747.
Some of the names cases are: either the gene has not been annotated because locus is proximal to annotation but not overlapping it (this may be because of lift over of coordinates), or because the name from UCSC hg38 annotation does not match the name in Court 2017 original annotated gene name.
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
Warning: The above code chunk cached its results, but it won’t be re-run if previous chunks it depends on are updated. If you need to use caching, it is highly recommended to also set knitr::opts_chunk$set(autodep = TRUE) at the top of the file (in a chunk that is not cached). Alternatively, you can customize the option dependson for each individual chunk that is cached. Using either autodep or dependson will remove this warning. See the knitr cache options for more details.
Gene expression levels on Naïve and Primed hESC cells
Data: Used public data from (Collier et al. 2017): H9 embryonic stem cells in Naïve and Primed state, three biological replicates.
Sample info
dataset_id
gsm_id
description
filename
run_id
input
layout
experiment
26
Collier_2017
GSM2449055
hESC_H9_naive_1
hESC_H9_naive_1
SRR5151102
-
single
RNA-seq
27
Collier_2017
GSM2449056
hESC_H9_naive_2
hESC_H9_naive_2
SRR5151103
-
single
RNA-seq
28
Collier_2017
GSM2449057
hESC_H9_naive_3
hESC_H9_naive_3
SRR5151104
-
single
RNA-seq
29
Collier_2017
GSM2449058
hESC_H9_primed_1
hESC_H9_primed_1
SRR5151105
-
single
RNA-seq
30
Collier_2017
GSM2449059
hESC_H9_primed_2
hESC_H9_primed_2
SRR5151106
-
single
RNA-seq
31
Collier_2017
GSM2449060
hESC_H9_primed_3
hESC_H9_primed_3
SRR5151107
-
single
RNA-seq
Primary analysis
RNA-seq data was analysed by a standard RNA-seq pipeline v2.0, available on nf-core (Ewels et al. 2019) with mostly default settings. For more information about the specific steps involved in this analysis, refer to the repository documentation: https://nf-co.re/rnaseq/2.0, using the option --aligner star_rsem.
Reference genome used was hg38, downloaded from illumina iGenomes:
Collier, Amanda J, Sarita P Panula, John Paul Schell, Peter Chovanec, Alvaro Plaza Reyes, Sophie Petropoulos, Anne E Corcoran, et al. 2017. “Comprehensive Cell Surface Protein Profiling Identifies Specific Markers of Human Naive and Primed Pluripotent States.”Cell Stem Cell 20 (6): 874–90.
Court, Franck, and Philippe Arnaud. 2017. “An Annotated List of Bivalent Chromatin Regions in Human ES Cells: A New Tool for Cancer Epigenetic Research.”Oncotarget 8 (3): 4110.
Ewels, Philip A, Alexander Peltzer, Sven Fillinger, Johannes Alneberg, Harshil Patel, Andreas Wilm, Maxime Ulysse Garcia, Paolo Di Tommaso, and Sven Nahnsen. 2019. “Nf-Core: Community Curated Bioinformatics Pipelines.”BioRxiv, 610741.
Love, Michael I, Wolfgang Huber, and Simon Anders. 2014. “Moderated Estimation of Fold Change and Dispersion for RNA-Seq Data with DESeq2.”Genome Biology 15 (12): 1–21.