Skip to content

Commit

Permalink
version 0.4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
shajoezhu authored and cran-robot committed Sep 1, 2017
1 parent 8577195 commit 77d781c
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 29 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
@@ -1,7 +1,7 @@
Package: DEploid
Type: Package
Title: Deconvolute Mixed Genomes with Unknown Proportions
Version: 0.4.3
Version: 0.4.4
Authors@R: c(
person("Joe", "Zhu", role=c("aut", "cre", "cph"), email="joe.zhu@well.ox.ac.uk"),
person('Jacob', 'Almagro-Garcia', role=c('aut', 'cph')),
Expand Down Expand Up @@ -35,7 +35,7 @@ LinkingTo: Rcpp
RoxygenNote: 6.0.1
Date: 2017-08-09
NeedsCompilation: yes
Packaged: 2017-08-09 20:21:48 UTC; joezhu
Packaged: 2017-09-01 00:24:49 UTC; joezhu
Author: Joe Zhu [aut, cre, cph],
Jacob Almagro-Garcia [aut, cph],
Gil McVean [aut, cph],
Expand All @@ -46,4 +46,4 @@ Author: Joe Zhu [aut, cre, cph],
Lutz Kettner [com, cph]
Maintainer: Joe Zhu <joe.zhu@well.ox.ac.uk>
Repository: CRAN
Date/Publication: 2017-08-09 20:57:59 UTC
Date/Publication: 2017-09-01 03:09:29 UTC
14 changes: 7 additions & 7 deletions MD5
@@ -1,15 +1,15 @@
fe25858d173d799b7791b1fbe643d5f7 *DESCRIPTION
d7f3808fb8f81f4820023f8f3ff6d73f *NAMESPACE
ab020c6fd247593f19934b13a0f9e82d *DESCRIPTION
60325fac7a82f3e45ef81515447c8dc1 *NAMESPACE
3f730ab29544fc1d63946a50242f3a42 *R/DEploidR.R
7efdf7afe8931c93c9c3cdf32a85fb6b *R/RcppExports.R
856a9b3317faac53312a512e049ca0f9 *R/dEploid.R
d4b1f3fe520bf3f984aa578b928f72a4 *R/dEploidPlotly.R
5a2e60ac3ffc29399ffaa1a2308ba8ae *R/dEploidPlotly.R
db8dd67bf1ee95720e0b4deeefe17540 *README.md
4b8735c3042553d77ef67496617e1a7a *build/vignette.rds
461e2dc267742100128d50cd74e757e2 *inst/CITATION
01c90976b229646ca9b46399709688e3 *inst/doc/dEploid-Arguments.R
2cbf6a6a60e07984981e6a2329578f8e *inst/doc/dEploid-Arguments.Rmd
7ad5bd544e465ca7736c57e0bde7815d *inst/doc/dEploid-Arguments.html
a9c2ba5451ed9582be1822d1ef3c9467 *inst/doc/dEploid-Arguments.html
2cad08193815864d8a26f8ac768ef199 *inst/extdata/PG0390-C.test.alt
07eccfaeb952de9e0460bcc12d457b22 *inst/extdata/PG0390-C.test.ref
cdc601c1d8d4eec2bc80512eb8ee6b6b *inst/extdata/PG0390-C.test.vcf.gz
Expand All @@ -26,12 +26,12 @@ d5231f506efc96d0257c95faf60f4c1a *man/extractCoverageFromTxt.Rd
1d929973d73c6742bd223e1ffc07b15c *man/haplotypePainter.Rd
d27b68362961277a9dae5718e025b2ee *man/histWSAF.Rd
c15c6c7d70701d6d454e46553ec8f3fb *man/plotAltVsRef.Rd
1bfe1926e788ab81b303eb1ab89f25bf *man/plotAltVsRefPlotly.Rd
4a719f9ddd20b1604d7ac33f64c9c251 *man/plotAltVsRefPlotly.Rd
2e3ce3260c47e734c3d0aa28cd153abf *man/plotHistWSAFPlotly.Rd
aa2e2c6ae4087fd61777c9fa17742152 *man/plotObsExpWSAF.Rd
ab1b443b0af8bf81d85e063f3556e80f *man/plotObsExpWSAFPlotly.Rd
8f91e514e27c39a978351e2a9976ddc6 *man/plotProportions.Rd
bcffcc1d30293e4abb6fcc1ef3c39d08 *man/plotWSAFVsPLAFPlotly.Rd
499310d8b94430a9ff1172326bf9f3d5 *man/plotWSAFVsPLAFPlotly.Rd
57351dea18413509031f78bd2b106dae *man/plotWSAFvsPLAF.Rd
c3adb6d6823db1b19840143fa58ba349 *src/DEploid/codeCogs/asympt_expn.h
9c4cc52f7742819084a453fef38e0288 *src/DEploid/codeCogs/errorfn.h
Expand Down Expand Up @@ -99,7 +99,7 @@ c5cc16e00e5cd1b8150a274c1fcfd3ad *src/init.c
d9780788cb9e10ae63d0cfb4ce81703d *src/r_random_generator.h
eedb9b59a5a966b63e9e82308caf7349 *src/test_exports.cpp
e095660d571c0f3ef91ce1211ecb7f76 *tests/testthat.R
3982e688fb6c251a018d4616267f493a *tests/testthat/test-DEploid_tools.R
2254c18f55a17646c9bd234fb1e80183 *tests/testthat/test-DEploid_tools.R
e6096201933e4b6042e165bca5d80db7 *tests/testthat/test-dEploid.R
f66b335af2d854e56592824fc8df7a0a *tests/testthat/test-r_random-generator.R
2cbf6a6a60e07984981e6a2329578f8e *vignettes/dEploid-Arguments.Rmd
2 changes: 1 addition & 1 deletion NAMESPACE
Expand Up @@ -4,7 +4,7 @@ importFrom("graphics", "abline", "barplot", "hist", "plot", "points", "axis", "l
importFrom("utils", "read.table")
importFrom(Rcpp,evalCpp)
importFrom("magrittr", "%>%")
importFrom("plotly", "plot_ly", "layout")
importFrom("plotly", "plot_ly", "layout", "add_trace")
useDynLib(DEploid, .registration = TRUE)
export(dEploid)
export(plotProportions)
Expand Down
56 changes: 42 additions & 14 deletions R/dEploidPlotly.R
Expand Up @@ -9,6 +9,8 @@
#'
#' @param title Figure title, "Alt vs Ref" by default
#'
#' @param potentialOutliers Index of potential outliers.
#'
#' @export
#'
#' @examples
Expand All @@ -23,16 +25,28 @@
#' PG0390CoverageV = extractCoverageFromVcf(vcfFile)
#' plotAltVsRefPlotly(PG0390CoverageV$refCount, PG0390CoverageV$altCount)
#'
plotAltVsRefPlotly <- function(ref, alt, title = "Alt vs Ref"){
plotAltVsRefPlotly <- function(ref, alt, title = "Alt vs Ref",
potentialOutliers = c()){
ratios <- ref / (ref + alt + 0.0000001)
legendName <- "Ref/(Ref+Alt) Ratio"
plot_ly(x = ref, y = alt, type = "scatter", mode = "markers",
refvsalt <- data.frame(ref, alt)
refvsalt$ref.out <- ifelse(rownames(refvsalt) %in%
potentialOutliers, ref, NA)
refvsalt$alt.out <- ifelse(rownames(refvsalt) %in%
potentialOutliers, alt, NA)
refvsalt$outlier <- ifelse(is.na(refvsalt$ref.out),
"outlier", "normal")
plot_ly(data = refvsalt, x = ~ref, y = ~alt,
type = "scatter", mode = "markers", name = "normal",
color = ratios, colors = c("#de2d26", "#2b8cbe"), alpha = 0.8,
marker = list(size = 3, line = list(color = "black", width = 0.1),
colorbar = list(title = legendName)
),
marker = list(size = 3, colorbar = list(title = legendName)),
showlegend = F,
text = paste("RefCount: ", ref, " ; ", "AltCount: ", alt)) %>%
layout(margin = list(l = 65, r = 25, b = 50, t = 80, pad = 0),
add_trace(x = ~ref.out, y = ~alt.out, name = "outlier",
type = "scatter", mode = "markers", symbol = I("x"),
marker = list(size = 4, color = "black"), showlegend = F) %>%
layout(autosize = F, width = 650, height = 500,
margin = list(l = 65, r = 25, b = 50, t = 80, pad = 0),
title = title, font = list(size = 18, colot = "black"),
legend = list(font = list(size = 5)),
xaxis = list(title = "Reference # Reads", range = c(-5, 200),
Expand Down Expand Up @@ -94,7 +108,7 @@ plotHistWSAFPlotly <- function(obsWSAF, exclusive = TRUE,
title = "Histogram 0<WSAF<1"){
tmpWSAFIndex <- 1:length(obsWSAF)
if (exclusive){
tmpWSAFIndex <- which( ( (obsWSAF < 1) * (obsWSAF > 0)) == 1)
tmpWSAFIndex <- which(((obsWSAF < 1) * (obsWSAF > 0)) == 1)
}
xb <- list(
start = 0,
Expand Down Expand Up @@ -132,6 +146,8 @@ plotHistWSAFPlotly <- function(obsWSAF, exclusive = TRUE,
#'
#' @param title Figure title, "WSAF vs PLAF" by default
#'
#' @param potentialOutliers Index of potential outliers.
#'
#' @export
#'
#' @examples
Expand All @@ -157,14 +173,26 @@ plotHistWSAFPlotly <- function(obsWSAF, exclusive = TRUE,
#' PG0390CoverageV$altCount)
#'
plotWSAFVsPLAFPlotly <- function(plaf, obsWSAF, ref, alt,
title = "WSAF vs PLAF"){
plot_ly(x = plaf, y = obsWSAF, type = "scatter", mode = "markers",
marker = list(size = 2,
color = "#c64343",
line = list(color = "rgba(152, 0, 0, .8)",
width = 1)),
title = "WSAF vs PLAF",
potentialOutliers = c()){
wsafvsplaf <- data.frame(plaf, obsWSAF)
wsafvsplaf$plaf.out <- ifelse(rownames(wsafvsplaf) %in%
potentialOutliers, plaf, NA)
wsafvsplaf$obsWSAF.out <- ifelse(rownames(wsafvsplaf) %in%
potentialOutliers, obsWSAF, NA)
wsafvsplaf$outlier <- ifelse(is.na(wsafvsplaf$plaf.out),
"outlier", "normal")
plot_ly(data = wsafvsplaf, x = ~plaf, y = ~obsWSAF,
type = "scatter", mode = "markers",
marker = list(size = 2, color = "#f47142",
line = list(color = "#fc6f3c", width = 1)),
text = paste("RefCount: ", ref, " ; ", "AltCount: ", alt)) %>%
layout(margin = list(l = 65, r = 25, b = 50, t = 80, pad = 0),
add_trace(x = ~plaf.out, y = ~obsWSAF.out, name = "outlier",
type = "scatter", mode = "markers", symbol = I("x"),
marker = list(size = 6, color = "black"),
showlegend = F) %>%
layout(autosize = F, width = 500, height = 500,
margin = list(l = 65, r = 25, b = 50, t = 80, pad = 0),
title = title, font = list(size = 18, colot = "black"),
xaxis = list(title = "PLAF", range = c(0, 1),
titlefont = list(size = 18, color = "black"),
Expand Down
4 changes: 2 additions & 2 deletions inst/doc/dEploid-Arguments.html
Expand Up @@ -12,7 +12,7 @@

<meta name="author" content="Sha Zhu" />

<meta name="date" content="2017-08-09" />
<meta name="date" content="2017-09-01" />

<title>Command Line Arguments</title>

Expand Down Expand Up @@ -70,7 +70,7 @@

<h1 class="title toc-ignore">Command Line Arguments</h1>
<h4 class="author"><em>Sha Zhu</em></h4>
<h4 class="date"><em>2017-08-09</em></h4>
<h4 class="date"><em>2017-09-01</em></h4>



Expand Down
4 changes: 3 additions & 1 deletion man/plotAltVsRefPlotly.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion man/plotWSAFVsPLAFPlotly.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions tests/testthat/test-DEploid_tools.R
Expand Up @@ -43,6 +43,7 @@ test_that("computeObsWSAF", {
test_that("WSAF Related", {
obsWSAF <- computeObsWSAF(PG0390CoverageVcf$altCount,
PG0390CoverageVcf$refCount)
potentialOutliers <- c(5, 12, 25, 30, 35, 50)
expect_that(histWSAF(obsWSAF), is_a("histogram"))
png("histWSAF.png")
histWSAF(obsWSAF)
Expand All @@ -52,6 +53,8 @@ test_that("WSAF Related", {
if (htmlwidgets:::pandoc_available()){
htmlwidgets::saveWidget(p, file = "histWSAFPlotly.html")
}

####
expect_null(plotWSAFvsPLAF(plaf, obsWSAF))
png("WSAFvsPLAF.png")
plotWSAFvsPLAF(plaf, obsWSAF)
Expand All @@ -67,6 +70,29 @@ test_that("WSAF Related", {
if (htmlwidgets:::pandoc_available()){
htmlwidgets::saveWidget(p, file = "WSAFvsPLAFPlotly.html")
}

###
expect_null(plotWSAFvsPLAF(plaf, obsWSAF,
potentialOutliers = potentialOutliers))
png("WSAFvsPLAFOutlier.png")
plotWSAFvsPLAF(plaf, obsWSAF, potentialOutliers = potentialOutliers)
dev.off()
expect_null(plotWSAFvsPLAF(plaf, obsWSAF, expWSAF,
potentialOutliers = potentialOutliers))
expect_that(inherits(plotWSAFVsPLAFPlotly(plaf, obsWSAF,
PG0390CoverageVcf$refCount,
PG0390CoverageVcf$altCount,
potentialOutliers =
potentialOutliers),
"plotly"), is_true())
p <- plotWSAFVsPLAFPlotly(plaf, obsWSAF,
PG0390CoverageVcf$refCount,
PG0390CoverageVcf$altCount,
potentialOutliers = potentialOutliers)
if (htmlwidgets:::pandoc_available()){
htmlwidgets::saveWidget(p, file = "WSAFvsPLAFPlotlyOutlier.html")
}
###
expect_null(plotObsExpWSAF(obsWSAF, expWSAF))
png("ObsExpWSAF.png")
plotObsExpWSAF(obsWSAF, expWSAF)
Expand Down Expand Up @@ -97,6 +123,28 @@ test_that("plotAltVsRef", {
})


test_that("plotAltVsRefWithOutliers", {
potentialOutliers <- c(1, 10, 20, 30, 40)
expect_null(plotAltVsRef(PG0390CoverageVcf$refCount,
PG0390CoverageVcf$altCount,
potentialOutliers = potentialOutliers))
png("AltVsRefOutlier.png")
plotAltVsRef(PG0390CoverageVcf$refCount, PG0390CoverageVcf$altCount,
potentialOutliers = potentialOutliers )
dev.off()
expect_that(inherits(plotAltVsRefPlotly(PG0390CoverageVcf$refCount,
PG0390CoverageVcf$altCount,
potentialOutliers = potentialOutliers),
"plotly"), is_true())
p <- plotAltVsRefPlotly(PG0390CoverageVcf$refCount,
PG0390CoverageVcf$altCount,
potentialOutliers = potentialOutliers)
if (htmlwidgets:::pandoc_available()){
htmlwidgets::saveWidget(p, file = "plotAltVsRefPlotlyOutlier.html")
}
})


test_that("plotProportion", {
expect_that(plotProportions(PG0390Deconv$Proportions, ""), is_a("numeric"))
})

0 comments on commit 77d781c

Please sign in to comment.