plotfeatureCoverage.Rd
Plots the 3 tabular data types (A-C) generated by the featureCoverage
function. It accepts data from single or many features (e.g. CDSs) and
samples (BAM files). The coverage from multiple features will be summarized
using methods such as mean
, while the data from multiple samples will
be plotted in separate panels.
plotfeatureCoverage(covMA, method = mean, scales = "fixed", extendylim=2,
scale_count_val = 10^6)
Object of class data.frame
generated by featureCoverage
function.
Defines the summary statistics to use when covMA
contains coverage
data from multiple features (e.g. transcripts). The default calculates the
mean coverage for each positon and/or bin of the corresponding coverage
vectors.
Scales setting passed on to the facet_wrap
function of ggplot2
.
For details see ggplot2::facet_wrap
. The default fixed
assures a
constant scale across all bar plot panels, while free
uses the optimum
scale within each bar plot panel. To evaluate plots in all their details, it
may be necessary to generate two graphics files one for each scaling option.
Allows to extend the upper limit of the y axis when scales=fixed
. Internally, the
function identifies the maximum value in the data and then multiplies this maximum value
by the value provided under extendylim
. The default is set to extendylim=2
.
Scales (normalizes) the read counts to a fixed value of aligned reads
in each sample such as counts per million aligned reads (default is 10^6).
For this calculation the N_total_aligned
values are used that are
reported in the input data.frame
generated by the upstream
featureCoverage
function. Assign NULL
to turn off
scaling.
Currently, the function returns ggplot2 bar plot graphics.
featureCoverage
## Construct SYSargs2 object from param and targets files
targets <- system.file("extdata", "targets.txt", package="systemPipeR")
dir_path <- system.file("extdata/cwl", package="systemPipeR")
args <- loadWorkflow(targets=targets, wf_file="hisat2/hisat2-mapping-se.cwl",
input_file="hisat2/hisat2-mapping-se.yml", dir_path=dir_path)
args <- renderWF(args, inputvars=c(FileName="_FASTQ_PATH1_", SampleName="_SampleName_"))
args
#> Instance of 'SYSargs2':
#> Slot names/accessors:
#> targets: 18 (M1A...V12B), targetsheader: 4 (lines)
#> modules: 1
#> wf: 0, clt: 1, yamlinput: 7 (inputs)
#> input: 18, output: 18
#> cmdlist: 18
#> Sub Steps:
#> 1. hisat2-mapping-se (rendered: TRUE)
#>
#>
if (FALSE) {
## Run alignments
args <- runCommandline(args, dir = FALSE, make_bam = TRUE)
outpaths <- subsetWF(args, slot = "output", subset = 1, index = 1)
## Features from sample data of systemPipeRdata package
library(GenomicFeatures)
file <- system.file("extdata/annotation", "tair10.gff", package="systemPipeRdata")
txdb <- makeTxDbFromGFF(file=file, format="gff3", organism="Arabidopsis")
## (A) Generate binned coverage for two BAM files and 4 transcripts
grl <- cdsBy(txdb, "tx", use.names=TRUE)
fcov <- featureCoverage(bfl=BamFileList(outpaths[1:2]), grl=grl[1:4], resizereads=NULL,
readlengthrange=NULL, Nbins=20, method=mean, fixedmatrix=FALSE,
resizefeatures=TRUE, upstream=20, downstream=20,
outfile="results/featureCoverage.xls")
plotfeatureCoverage(covMA=fcov, method=mean, scales="fixed", scale_count_val=10^6)
## (B) Coverage matrix upstream and downstream of start/stop codons
fcov <- featureCoverage(bfl=BamFileList(outpaths[1:2]), grl=grl[1:4], resizereads=NULL,
readlengthrange=NULL, Nbins=NULL, method=mean, fixedmatrix=TRUE,
resizefeatures=TRUE, upstream=20, downstream=20,
outfile="results/featureCoverage_UpDown.xls")
plotfeatureCoverage(covMA=fcov, method=mean, scales="fixed", scale_count_val=10^6)
## (C) Combined matrix for both binned and start/stop codon
fcov <- featureCoverage(bfl=BamFileList(outpaths[1:2]), grl=grl[1:4], resizereads=NULL,
readlengthrange=NULL, Nbins=20, method=mean, fixedmatrix=TRUE,
resizefeatures=TRUE, upstream=20, downstream=20,
outfile="results/test.xls")
plotfeatureCoverage(covMA=fcov, method=mean, scales="fixed", scale_count_val=10^6)
## (D) Rle coverage objects one for each query feature
fcov <- featureCoverage(bfl=BamFileList(outpaths[1:2]), grl=grl[1:4], resizereads=NULL,
readlengthrange=NULL, Nbins=NULL, method=mean, fixedmatrix=FALSE,
resizefeatures=TRUE, upstream=20, downstream=20,
outfile="results/RleCoverage.xls")
}