5 Improving package integration
- Add suppporting functions to access AnnotationHub-hosted files;
- Write a vignette to document a use case for the package;
- Create a pkgdown website for package documentation
At any time, if you are lost or do not understand how functions in the proposed solution work, type ?<function> in the R console and a help menu will appear.
You can also check the help tab in the corresponding quadrant.
We aim to create a package which can plot the aggregated coverage of a genomic track over a set of GRanges of interest (at a fixed width).
5.1 Use TxDb and AnnotationHub resources
5.1.1 TxDb database
TxDb packages provide transcript annotations for model organisms.
Find the TxDb package associated with UCSC-provided human gene annotations and install it.
Note: You will need annotations from the hg19 human genome reference.
TxDb packages follow the naming scheme TxDb.<Species>.<Provider>.<Genome>.<Table>. For UCSC human hg19 known genes, that is TxDb.Hsapiens.UCSC.hg19.knownGene. Install it with BiocManager::install().
GenomicFeatures is a package designed in order to facilitate conversion of TxDb objects into GRanges objects.
5.1.2 AnnotationHub database
AnnotationHub provides access to a large number of NGS datasets.
Can you query the
AnnotationHubto explore which datasets are available?Which species are most represented?
Hint: The mcols() function will extract metadata associated with each entry in the AnnotationHub.
The Epigenome roadmap project by the Broad Institute performed H3K4me3 ChIP-seq in human (among other marks). They generated a library labelled ‘LL227’ (GEO ID: GSM409308).
- Which signal corresponds to a ChIP-seq coverage track? How can you download the associated file?
5.2 Create a AggregatedCoverage object
This AggregatedCoverage should contain aggregated H3K4me3 coverage over the TSSs of all forward human genes.
Three arguments are required:
-
bw_file: the path to a disk-stored coverage track file (e.g. the path to abwfile) -
features_file: the path to a disk-stored features file (e.g. the path to abedfile) -
width: an integer specifying the width to use for each genomic locus
-
bw_file: the local path returned byBiocIO::resource(bw). -
features_file: derive TSSs of forward genes from theTxDb(genes(), subsetstrand == "+",resize(width = 1, fix = "start")), thenrtracklayer::export()them to abedfile —AggregatedCoverage()expects a file path, not aGRanges. -
width: an integer, e.g.8000Lfor a ±4 kb window.
- Preparing
bw_fileargument:
- Preparing
features_fileargument:
library(GenomicRanges)
library(rtracklayer)
txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene::TxDb.Hsapiens.UCSC.hg19.knownGene
genes <- GenomicFeatures::genes(txdb)
forward_genes <- genes[strand(genes) == '+']
forward_tss <- resize(forward_genes, width = 1, fix = 'start')
export(forward_tss, "forward_tss.bed")
features_file <- 'forward_tss.bed'- Preparing
widthargument:
Now that all the arguments are ready, one can create an AggregatedCoverage object.
Create a AggregatedCoverage object summarizing the coverage of H3K4me3 over the TSSs (± 4kb) of all forward human genes.
5.3 Add a vignette to your package
The previous section reuses publicly available datasets and resources provided by Bioconductor to illustrate a use case for our package.
Initiate a vignette using
biocthistemplate;Fill out the vignette header with relevant information (namely, the
authorfield);Describe the use case developed in the previous section.
biocthis::use_bioc_vignette() scaffolds a Bioconductor-style vignette under vignettes/. It takes the vignette name and a title.
Because the vignette relies on several packages, these need to be declared in the DESCRIPTION file. Make sure to update it.
usethis::use_package("<pkg>") adds a package to the Imports: field of your DESCRIPTION (use type = "Suggests" for packages only needed by the vignette or tests). Call it once per dependency.
5.4 Create pkgdown website and host it on GitHub
Comment on why setting up a pkgdown website helps with checking that your package reliably works?
Commit your changes. Did that include your newly created
docsfolder? Why?Remove
docsfrom.gitignore, then commit thedocs/folder with git.Now push all your commits to your github remote repository, navigate to its webpage, and enable
Pagesdeployment from thedocsfolder. Check the resulting website.