R/plot_coverage.R
plot_coverage.Rd
plot_coverage
plots the coverage of nuclear and cytoplasmic RNA from
adult and prenatal human prefrontal cortex across a candidate or series of
candidate probe sequences for BrainFlow. If the sequence spans splice
junctions, the plot will include the introns. A good candidate sequence will
be highly and evenly expressed in nuclear RNA.
plot_coverage(
REGION,
PDF = "regionCoverage_fractionedData.pdf",
OUTDIR = tempdir(),
COVERAGE = NULL,
CODING_ONLY = FALSE,
VERBOSE = TRUE
)
Either a single hg19 genomic sequence including the chromosome, start, end, and optionally strand separated by colons (e.g., 'chr20:10199446-10288068:+'), or a string of sequences. Must be character. Chromosome must be proceeded by 'chr'.
The name of the PDF file. Defaults to
regionCoverage_fractionedData.pdf
.
The default directory where PDF
will be saved to.
The output of brainflowprobes_cov for the input
REGION
. Defaults to NULL
but it can be pre-computed and saved
separately since this is the step that takes the longest to run. Also, this
is the only step that depends on rtracklayer's functionality for reading
BigWig files which does not run on Windows OS. So it could be run on a
non-Windows machine, saved, and then shared with Windows users.
A logical vector of length 1 specifying whether to
subset the Annotated Genes to only the coding genes. That is, whether to
subset the genes by whether they have a non-NA CSS
value. The Annotated
Genes are downloaded with GenomicState::GenomicStateHub()
.
A logical value indicating whether to print updates from the process of loading the data from the BigWig files.
plot_coverage
plots all input sequences using
derfinderPlot::plotRegionCoverage()
. It returns a plot for each
input candidate sequence listed in REGION. Each plot includes coverage of
the sequence(s) in nuclear (N) and cytoplasmic (C) RNA isolated from adult
(A) and fetal (F) prefrontal cortex, sequenced using two different library
preparation methods. PolyA+ libraries (P) were generated using selection
for polyadenylated transcripts, and RiboZero (R) libraries were generated
using a ribosomal RNA depletion protocol.
Each plot also shows the overlapping genes beneath the coverage, and the
genomic location. The title lists the nearest gene, the position of the
sequence relative to the gene's canonical transcriptional start site (TSS),
and further annotation information as described in the 'region' column from
bumphunter::matchGenes()
.
plot_coverage
saves the results as regionCoverage_fractionedData.pdf
in a temporary directory unless otherwise specified with OUTDIR
.
## Here we use the pre-saved example coverage data such that this example
## will run fast!
plot_coverage("chr20:10286777-10288069:+",
COVERAGE = four_panels_example_cov
)
#> loading from cache
#> loading from cache
#> 2023-05-07 06:27:01.480368 annotateRegions: counting
#> 2023-05-07 06:27:02.895399 annotateRegions: annotating
#> 2023-05-07 06:27:03.121126 Completed! Check for /tmp/Rtmp3fU3Pu/regionCoverage_fractionedData.pdf.
## Without using COVERAGE, this function reads BigWig files from the web
## using rtracklayer and this functionality is not supported on Windows
## machines.
if (.Platform$OS.type != "windows") {
plot_coverage("chr20:10286777-10288069:+",
PDF = "regionCoverage_fractionedData_fromScratch.pdf"
)
}
#> loading from cache
#> loading from cache
#> 2023-05-07 06:27:18.387853 annotateRegions: counting
#> 2023-05-07 06:27:18.976636 annotateRegions: annotating
#> 2023-05-07 06:27:19.08606 getRegionCoverage : attempting to load coverage data from 'files'.
#> 2023-05-07 06:27:19.09772 fullCoverage: processing chromosome chr20
#> 2023-05-07 06:27:19.11821 loadCoverage: finding chromosome lengths
#> 2023-05-07 06:27:19.34331 loadCoverage: loading BigWig file http://brain-flow-rna.s3.us-east-2.amazonaws.com/Sep/Br1113C1_polyA.bw
#> 2023-05-07 06:27:19.738588 loadCoverage: loading BigWig file http://brain-flow-rna.s3.us-east-2.amazonaws.com/Sep/Br1113N1_polyA.bw
#> 2023-05-07 06:27:20.146545 loadCoverage: loading BigWig file http://brain-flow-rna.s3.us-east-2.amazonaws.com/Sep/Br2046C_polyA.bw
#> 2023-05-07 06:27:20.534804 loadCoverage: loading BigWig file http://brain-flow-rna.s3.us-east-2.amazonaws.com/Sep/Br2046N_polyA.bw
#> 2023-05-07 06:27:20.880288 loadCoverage: loading BigWig file http://brain-flow-rna.s3.us-east-2.amazonaws.com/Sep/Br2074C_polyA.bw
#> 2023-05-07 06:27:22.345428 loadCoverage: loading BigWig file http://brain-flow-rna.s3.us-east-2.amazonaws.com/Sep/Br2074N_polyA.bw
#> 2023-05-07 06:27:22.711935 loadCoverage: loading BigWig file http://brain-flow-rna.s3.us-east-2.amazonaws.com/Sep/Br5339C1_polyA.bw
#> 2023-05-07 06:27:23.071987 loadCoverage: loading BigWig file http://brain-flow-rna.s3.us-east-2.amazonaws.com/Sep/Br5339N1_polyA.bw
#> 2023-05-07 06:27:23.419618 loadCoverage: loading BigWig file http://brain-flow-rna.s3.us-east-2.amazonaws.com/Sep/Br5340C1_polyA.bw
#> 2023-05-07 06:27:23.768357 loadCoverage: loading BigWig file http://brain-flow-rna.s3.us-east-2.amazonaws.com/Sep/Br5340N1_polyA.bw
#> 2023-05-07 06:27:24.11167 loadCoverage: loading BigWig file http://brain-flow-rna.s3.us-east-2.amazonaws.com/Sep/Br5341C1_polyA.bw
#> 2023-05-07 06:27:24.492876 loadCoverage: loading BigWig file http://brain-flow-rna.s3.us-east-2.amazonaws.com/Sep/Br5341N1_polyA.bw
#> 2023-05-07 06:27:24.867908 loadCoverage: loading BigWig file http://brain-flow-rna.s3.us-east-2.amazonaws.com/Sep/Br1113C1_RiboZero.bw
#> 2023-05-07 06:27:25.221257 loadCoverage: loading BigWig file http://brain-flow-rna.s3.us-east-2.amazonaws.com/Sep/Br2046C_RiboZero.bw
#> 2023-05-07 06:27:25.587989 loadCoverage: loading BigWig file http://brain-flow-rna.s3.us-east-2.amazonaws.com/Sep/Br2046N_RiboZero.bw
#> 2023-05-07 06:27:25.933481 loadCoverage: loading BigWig file http://brain-flow-rna.s3.us-east-2.amazonaws.com/Sep/Br2074C_RiboZero.bw
#> 2023-05-07 06:27:26.279156 loadCoverage: loading BigWig file http://brain-flow-rna.s3.us-east-2.amazonaws.com/Sep/Br2074N_RiboZero.bw
#> 2023-05-07 06:27:26.617171 loadCoverage: loading BigWig file http://brain-flow-rna.s3.us-east-2.amazonaws.com/Sep/Br5339C1_RiboZero.bw
#> 2023-05-07 06:27:26.961305 loadCoverage: loading BigWig file http://brain-flow-rna.s3.us-east-2.amazonaws.com/Sep/Br5339N1_RiboZero.bw
#> 2023-05-07 06:27:27.301182 loadCoverage: loading BigWig file http://brain-flow-rna.s3.us-east-2.amazonaws.com/Sep/Br5340C1_RiboZero.bw
#> 2023-05-07 06:27:27.639771 loadCoverage: loading BigWig file http://brain-flow-rna.s3.us-east-2.amazonaws.com/Sep/Br5340N1_RiboZero.bw
#> 2023-05-07 06:27:27.981568 loadCoverage: loading BigWig file http://brain-flow-rna.s3.us-east-2.amazonaws.com/Sep/Br5341C1_RiboZero.bw
#> 2023-05-07 06:27:28.376316 loadCoverage: loading BigWig file http://brain-flow-rna.s3.us-east-2.amazonaws.com/Sep/Br5341N1_RiboZero.bw
#> 2023-05-07 06:27:28.714921 loadCoverage: applying the cutoff to the merged data
#> 2023-05-07 06:27:28.926351 filterData: originally there were 63025520 rows, now there are 63025520 rows. Meaning that 0 percent was filtered.
#> 2023-05-07 06:27:28.99449 getRegionCoverage: processing chr20
#> 2023-05-07 06:27:29.080237 getRegionCoverage: done processing chr20
#> 2023-05-07 06:27:29.195568 Completed! Check for /tmp/Rtmp3fU3Pu/regionCoverage_fractionedData_fromScratch.pdf.
if (FALSE) {
## These examples will take a few minutes to run!
plot_coverage(c(
"chr20:10286777-10288069:+",
"chr18:74690788-74692427:-",
"chr19:49932861-49933829:-"
))
candidates <- c(
"chr20:10286777-10288069:+",
"chr18:74690788-74692427:-",
"chr19:49932861-49933829:-"
)
## General syntax:
plot_coverage(candidates,
PDF = "PDF_file.pdf",
OUTDIR = "/path/to/directory/"
)
plot_coverage("chr20:10286777-10288069:+",
PDF = "PDF_file.pdf", OUTDIR = "/path/to/directory/"
)
## Explore the effect of changing CODING_ONLY
## Check how gene name and distance to TSS changes in the title of the plot
## (everything else stays the same)
cov <- brainflowprobes_cov("chr10:135379301-135379311:+")
plot_coverage("chr10:135379301-135379311:+", COVERAGE = cov)
plot_coverage("chr10:135379301-135379311:+",
COVERAGE = cov,
PDF = "coding_only_plot_coverage", CODING_ONLY = TRUE
)
}