Last data update: 2014.03.03

R: Create a dummy GRanges object as a placeholder in case nbh_em...
addDummyProbR Documentation

Create a dummy GRanges object as a placeholder in case nbh_em fails (Internal function)

Description

This function is used to generate a place holder in cases the EM fails to converge on a chromosome due to too few number of reads mapped to that chromosome. This is an internal function not expected to be directly called by the user.

Usage

addDummyProb(alignGR, K = 2, randomProb = FALSE, runViterbi = FALSE, ...)

Arguments

alignGR

GRanges object derived from RIP-seq alignment inputs.

K

Number of hidden states (Default: 2).

randomProb

A binary value to indicate whether to use random probability as a place holder to present posterior probabilities. If set FALSE, (by default), equal probability is used for all states.

runViterbi

A binary value to indicate whether to generate place holder for the Viterbi state sequence (Default: FALSE).

...

Additional arguments expected to contain the bin size used for computing the bin counts in binCount function, and any other extra arguments are ignored.

Details

A priviate function to fall back in case HMM fails to converge mostly due to too many zero counts in the input vector. When that occurs, a GRanges place holder object needs to be returned to keep consistent with the remaining GRanges for each chromosome. Thus, all information slot will be generated as place holder to properly create the GRangesList for the predictions on all chromosomes (each as an GRanges item in the list).

Value

GRanges

A GRanges object containing the read count (in the defined bin size), alpha, beta, TRANS dummy values for the HMM

Author(s)

Yue Li

See Also

mainSeekSingleChrom

Examples

# Retrieve system files
extdata.dir <- system.file("extdata", package="RIPSeeker") 

bamFiles <- list.files(extdata.dir, ".bam$", recursive=TRUE, full.names=TRUE)

bamFiles <- grep("PRC2", bamFiles, value=TRUE)

alignGal <- getAlignGal(bamFiles[1], reverseComplement=TRUE, genomeBuild="mm9")

alignGR <- as(alignGal, "GRanges")

alignGRList <- GRangesList(as.list(split(alignGR, seqnames(alignGR))))

x <- addDummyProb(alignGRList$chrX, binSize=10000)

x

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(RIPSeeker)
Loading required package: S4Vectors
Loading required package: stats4
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


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: GenomeInfoDb
Loading required package: SummarizedExperiment
Loading required package: Biobase
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: Biostrings
Loading required package: XVector
Loading required package: GenomicAlignments
Loading required package: rtracklayer
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/RIPSeeker/addDummyProb.Rd_%03d_medium.png", width=480, height=480)
> ### Name: addDummyProb
> ### Title: Create a dummy GRanges object as a placeholder in case nbh_em
> ###   fails (Internal function)
> ### Aliases: addDummyProb
> 
> ### ** Examples
> 
> # Retrieve system files
> extdata.dir <- system.file("extdata", package="RIPSeeker") 
> 
> bamFiles <- list.files(extdata.dir, ".bam$", recursive=TRUE, full.names=TRUE)
> 
> bamFiles <- grep("PRC2", bamFiles, value=TRUE)
> 
> alignGal <- getAlignGal(bamFiles[1], reverseComplement=TRUE, genomeBuild="mm9")
Processing /home/ddbj/local/lib64/R/library/RIPSeeker/extdata/PRC2/SRR039210_processed_tophat/accepted_hits_noDup_sel_chrX.bam ... All hits are returned with flags.
> 
> alignGR <- as(alignGal, "GRanges")
> 
> alignGRList <- GRangesList(as.list(split(alignGR, seqnames(alignGR))))
> 
> x <- addDummyProb(alignGRList$chrX, binSize=10000)
> 
> x
GRanges object with 16666 ranges and 3 metadata columns:
          seqnames                 ranges strand |     count state_1_postprob
             <Rle>              <IRanges>  <Rle> | <numeric>        <numeric>
      [1]     chrX         [    1, 10000]      * |         0              0.5
      [2]     chrX         [10001, 20000]      * |         0              0.5
      [3]     chrX         [20001, 30000]      * |         0              0.5
      [4]     chrX         [30001, 40000]      * |         0              0.5
      [5]     chrX         [40001, 50000]      * |         0              0.5
      ...      ...                    ...    ... .       ...              ...
  [16662]     chrX [166610001, 166620000]      * |         1              0.5
  [16663]     chrX [166620001, 166630000]      * |         2              0.5
  [16664]     chrX [166630001, 166640000]      * |         3              0.5
  [16665]     chrX [166640001, 166650000]      * |         4              0.5
  [16666]     chrX [166650001, 166650296]      * |         5              0.5
          state_2_postprob
                 <numeric>
      [1]              0.5
      [2]              0.5
      [3]              0.5
      [4]              0.5
      [5]              0.5
      ...              ...
  [16662]              0.5
  [16663]              0.5
  [16664]              0.5
  [16665]              0.5
  [16666]              0.5
  -------
  seqinfo: 1 sequence from an unspecified genome
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>