Last data update: 2014.03.03
|
R: scan BAM files for total read counts
totalReadCounts | R Documentation |
scan BAM files for total read counts
Description
scan BAM files for total read counts
Usage
totalReadCounts(x)
Arguments
x |
BamViews-class instance
|
Details
slow procedure – does lightweight scan of entire file
Value
named integer vector of read counts per sample
Author(s)
VJ Carey <stvjc@channing.harvard.edu>
Examples
example(bs1)
totalReadCounts(bs1)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(leeBamViews)
Loading required package: Biobase
Loading required package: BiocGenerics
Loading required package: parallel
Attaching package: 'BiocGenerics'
The following objects are masked from 'package:parallel':
clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
clusterExport, clusterMap, parApply, parCapply, parLapply,
parLapplyLB, parRapply, parSapply, parSapplyLB
The following objects are masked from 'package:stats':
IQR, mad, xtabs
The following objects are masked from 'package:base':
Filter, Find, Map, Position, Reduce, anyDuplicated, append,
as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
rbind, rownames, sapply, setdiff, sort, table, tapply, union,
unique, unsplit
Welcome to Bioconductor
Vignettes contain introductory material; view with
'browseVignettes()'. To cite Bioconductor, see
'citation("Biobase")', and for packages 'citation("pkgname")'.
Loading required package: Rsamtools
Loading required package: GenomeInfoDb
Loading required package: stats4
Loading required package: S4Vectors
Attaching package: 'S4Vectors'
The following objects are masked from 'package:base':
colMeans, colSums, expand.grid, rowMeans, rowSums
Loading required package: IRanges
Loading required package: GenomicRanges
Loading required package: Biostrings
Loading required package: XVector
Loading required package: BSgenome
Loading required package: rtracklayer
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/leeBamViews/totalReadCounts.Rd_%03d_medium.png", width=480, height=480)
> ### Name: totalReadCounts
> ### Title: scan BAM files for total read counts
> ### Aliases: totalReadCounts totalReadCounts,BamViews-method
> ### Keywords: models
>
> ### ** Examples
>
> example(bs1)
bs1> library(leeBamViews) # bam files stored in package
bs1> bpaths = dir(system.file("bam", package="leeBamViews"), full=TRUE, patt="bam$")
bs1> #
bs1> # extract genotype and lane information from filenames
bs1> #
bs1> gt = gsub(".*/", "", bpaths)
bs1> gt = gsub("_.*", "", gt)
bs1> lane = gsub(".*(.)$", "\1", gt)
bs1> geno = gsub(".$", "", gt)
bs1> #
bs1> # format the sample-level information appropriately
bs1> #
bs1> pd = DataFrame(geno=geno, lane=lane, row.names=paste(geno,lane,sep="."))
bs1> prd = new("DataFrame") # protocol data could go here
bs1> #
bs1> # create the views object, adding some arbitrary experiment-level information
bs1> #
bs1> bs1 = BamViews(bamPaths=bpaths, bamSamples=pd,
bs1+ bamExperiment=list(annotation="org.Sc.sgd.db"))
bs1> bs1
BamViews dim: 0 ranges x 8 samples
names: isowt.5 isowt.6 ... xrn.1 xrn.2
detail: use bamPaths(), bamSamples(), bamRanges(), ...
bs1> # add ranges and tabulate reads
bs1>
bs1> START=c(861250, 863000)
bs1> END=c(862750, 864000)
bs1> exc = GRanges(IRanges(start=START, end=END), seqnames="Scchr13", strand="+")
bs1> values(exc)$name = c("intv1", "intv2") # necessary
bs1> bamRanges(bs1) = exc
bs1> bs1
BamViews dim: 2 ranges x 8 samples
names: isowt.5 isowt.6 ... xrn.1 xrn.2
detail: use bamPaths(), bamSamples(), bamRanges(), ...
bs1> tabulateReads(bs1, "+")
intv1 intv2
start 861250 863000
end 862750 864000
isowt.5 3673 2697
isowt.6 3770 2653
rlp.5 1532 1047
rlp.6 1567 1140
ssr.1 4304 3065
ssr.2 4627 3388
xrn.1 2841 1695
xrn.2 3477 2199
> totalReadCounts(bs1)
isowt5_13e.bam isowt6_13e.bam rlp5_13e.bam rlp6_13e.bam ssr1_13e.bam
34549 34552 24634 25102 32657
ssr2_13e.bam xrn1_13e.bam xrn2_13e.bam
35268 23513 29410
>
>
>
>
>
> dev.off()
null device
1
>
|