R: Plot the densities estimated from a mixture model for a copy...
plot
R Documentation
Plot the densities estimated from a mixture model for a copy number polymorphism
Description
Plot estimates of the posterior density for each component and the
overall, marginal density. For batch models, one can additionally
plot batch-specific density estimates.
Usage
plot(x, y, ...)
## S4 method for signature 'DensityModel,ANY'
plot(x, y, ...)
## S4 method for signature 'MarginalModel,ANY'
plot(x, y, ...)
## S4 method for signature 'BatchModel,ANY'
plot(x, y, show.batch = TRUE, ...)
## S4 method for signature 'DensityBatchModel,ANY'
plot(x, show.batch = TRUE, ...)
Arguments
x
a DensityModel-derived object, or a
MixtureModel-derived object.
y
If x is a DensityModel, y is a
numeric vector of the one-dimensional summaries for a given copy
number polymorphism. If x is a MixtureModel, y
is ignored.
...
Additional arguments passed to hist.
show.batch
a logical. If true, batch specific densities
will be plotted.
Value
A plot showing the density estimate
Examples
set.seed(100)
truth <- simulateData(N=2500,
theta=c(-2, -0.4, 0),
sds=c(0.3, 0.15, 0.15),
p=c(0.05, 0.1, 0.8))
mcmcp <- McmcParams(iter=500, burnin=500, thin=2)
model <- MarginalModel(y(truth), k=3, mcmc.params=mcmcp)
model <- CNPBayes:::startAtTrueValues(model, truth)
model <- posteriorSimulation(model)
par(mfrow=c(1,2), las=1)
plot(truth)
plot(model)
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(CNPBayes)
Loading required package: GenomicRanges
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
Loading required package: S4Vectors
Loading required package: stats4
Attaching package: 'S4Vectors'
The following objects are masked from 'package:base':
colMeans, colSums, expand.grid, rowMeans, rowSums
Loading required package: IRanges
Loading required package: GenomeInfoDb
Attaching package: 'CNPBayes'
The following object is masked from 'package:stats':
sigma
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/CNPBayes/plot.Rd_%03d_medium.png", width=480, height=480)
> ### Name: plot
> ### Title: Plot the densities estimated from a mixture model for a copy
> ### number polymorphism
> ### Aliases: plot plot,BatchModel,ANY-method
> ### plot,DensityBatchModel,ANY-method plot,DensityModel,ANY-method
> ### plot,DensityModel,numeric-method plot,MarginalModel,ANY-method
>
> ### ** Examples
>
> set.seed(100)
> truth <- simulateData(N=2500,
+ theta=c(-2, -0.4, 0),
+ sds=c(0.3, 0.15, 0.15),
+ p=c(0.05, 0.1, 0.8))
>
> mcmcp <- McmcParams(iter=500, burnin=500, thin=2)
> model <- MarginalModel(y(truth), k=3, mcmc.params=mcmcp)
> model <- CNPBayes:::startAtTrueValues(model, truth)
> model <- posteriorSimulation(model)
> par(mfrow=c(1,2), las=1)
> plot(truth)
An object of class 'DensityModel'
component densities: list of 3 vectors
overall density: vector of length 250
modes: -2.04, 0
> plot(model)
An object of class 'DensityModel'
component densities: list of 3 vectors
overall density: vector of length 250
modes: -2.07, 0
>
>
>
>
>
> dev.off()
null device
1
>