Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ggmuller plots #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion OncoSimulR/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ License: GPL (>= 3)
URL: https://github.com/rdiaz02/OncoSimul, https://popmodels.cancercontrol.cancer.gov/gsr/packages/oncosimulr/
BugReports: https://github.com/rdiaz02/OncoSimul/issues
Depends: R (>= 3.3.0)
Imports: Rcpp (>= 0.12.4), parallel, data.table, graph, Rgraphviz, gtools, igraph, methods, RColorBrewer, grDevices, car, dplyr, smatr, ggplot2, ggrepel, nem
Imports: Rcpp (>= 0.12.4), parallel, data.table, graph, Rgraphviz, gtools, igraph, methods, RColorBrewer, grDevices, car, dplyr, smatr, ggplot2, ggrepel, nem, ggmuller
Suggests: BiocStyle, knitr, Oncotree, testthat (>= 1.0.0), rmarkdown, bookdown, pander
LinkingTo: Rcpp
VignetteBuilder: knitr
Expand Down
1 change: 1 addition & 0 deletions OncoSimulR/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ importFrom("dplyr", "full_join", "left_join", "right_join", "%>%", "mutate",
importFrom("smatr", "ma") ## for major axis regression in some tests
importFrom("car", "linearHypothesis")
importFrom("nem", "transitive.reduction")
importFrom("ggmuller", "get_Muller_df", "Muller_plot", "Muller_pop_plot")
## importFrom("slam", "simple_triplet_zero_matrix", ## "colapply_simple_triplet_matrix",
## "col_sums")

Expand Down
458 changes: 259 additions & 199 deletions OncoSimulR/R/OncoSimulR.R

Large diffs are not rendered by default.

28 changes: 13 additions & 15 deletions OncoSimulR/R/stacked-plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@



## plot.stream makes a "stream plot" where each y series is plotted
## plot.stream makes a "stream plot" where each y series is plotted
## as stacked filled polygons on alternating sides of a baseline.

## Arguments include:
## 'x' - a vector of values
## 'y' - a matrix of data series (columns) corresponding to x
## 'order.method' = c("as.is", "max", "first")
## 'order.method' = c("as.is", "max", "first")
## "as.is" - plot in order of y column
## "max" - plot in order of when each y series reaches maximum value
## "first" - plot in order of when each y series first value > 0
## 'center' - if TRUE, the stacked polygons will be centered so that the middle,
## i.e. baseline ("g0"), of the stream is approximately equal to zero.
## Centering is done before the addition of random wiggle to the baseline.
## i.e. baseline ("g0"), of the stream is approximately equal to zero.
## Centering is done before the addition of random wiggle to the baseline.
## 'frac.rand' - fraction of the overall data "stream" range used to define the range of
## random wiggle (uniform distrubution) to be added to the baseline 'g0'
## 'spar' - setting for smooth.spline function to make a smoothed version of baseline "g0"
Expand All @@ -43,11 +43,11 @@
## '...' - other plot arguments

plot.stream2 <- function(
x, y,
x, y,
order.method = "as.is", frac.rand=0.1, spar=0.2,
center=TRUE,
ylab="", xlab="",
border = NULL, lwd=1,
ylab="", xlab="",
border = NULL, lwd=1,
col=rainbow(length(y[1,])),
ylim=NULL,
log = "",
Expand All @@ -60,7 +60,7 @@ plot.stream2 <- function(
border <- as.vector(matrix(border, nrow=ncol(y), ncol=1))
col <- as.vector(matrix(col, nrow=ncol(y), ncol=1))
lwd <- as.vector(matrix(lwd, nrow=ncol(y), ncol=1))

if(order.method == "max") {
ord <- order(apply(y, 2, which.max))
y <- y[, ord]
Expand Down Expand Up @@ -98,7 +98,7 @@ plot.stream2 <- function(
mid <- apply(outer.lims, 1,
function(r) mean(c(max(r, na.rm=TRUE),
min(r, na.rm=TRUE)), na.rm=TRUE))

## center and wiggle
if(center) {
g0 <- -mid + runif(length(x),
Expand Down Expand Up @@ -133,15 +133,13 @@ plot.stream2 <- function(
}
}



## plot.stacked makes a stacked plot where each y series is plotted on top
## of the each other using filled polygons

## Arguments include:
## 'x' - a vector of values
## 'y' - a matrix of data series (columns) corresponding to x
## 'order.method' = c("as.is", "max", "first")
## 'order.method' = c("as.is", "max", "first")
## "as.is" - plot in order of y column
## "max" - plot in order of when each y series reaches maximum value
## "first" - plot in order of when each y series first value > 0
Expand All @@ -151,10 +149,10 @@ plot.stream2 <- function(
## '...' - other plot arguments

plot.stacked2 <- function(
x, y,
x, y,
order.method = "as.is",
ylab="", xlab="",
border = NULL, lwd=1,
ylab="", xlab="",
border = NULL, lwd=1,
col=rainbow(length(y[1,])),
ylim=NULL,
log = "",
Expand Down
23 changes: 16 additions & 7 deletions OncoSimulR/man/plot.oncosimul.Rd
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
and clones with different number of drivers are plotted in different
colours. Plots can alternatively display genotypes instead of drivers.

Plots available are line plots, stacked area, and stream plots.
Plots available are line plots, stacked area, stream plots and Muller plots.

}

Expand Down Expand Up @@ -53,7 +53,9 @@
srange = c(0.4, 1),
vrange = c(0.8, 1),
breakSortColors = "oe",
legend.ncols = "auto", ...)
legend.ncols = "auto",
muller.type = "frequency",
...)

\method{plot}{oncosimulpop}(x,
ask = TRUE,
Expand Down Expand Up @@ -88,6 +90,7 @@
vrange = c(0.8, 1),
breakSortColors = "oe",
legend.ncols = "auto",
muller.type = "frequency",
...)

}
Expand All @@ -109,22 +112,29 @@
will be an unmanageable mess). The default is "drivers".
}

\item{type}{One of "line", "stacked", "stream".
\item{type}{One of "line", "stacked", "stream", "muller".

If "line", you are shown lines for each genotype or clone. This
means that to get an idea of the total population size you need to
use \code{plotDrivers = TRUE} with \code{addtot = TRUE}, or do the
visual calculation in your head.

If "stacked" a stacked area plot. If "stream" a stream plot. Since
these stack areas, you immediately get the total population. But that
also means you cannot use \code{log}.
If "stacked" a stacked area plot. If "stream" a stream plot. If "muller"
a Muller plot. Since these stack areas, you immediately get the total
population. But that also means you cannot use \code{log}.

The default is to use "line" for \code{show = "drivers"} and
"stacked" for \code{show = "genotypes"}.

}

\item{muller.type}{One of "frequency", "population".

If "frequency", it shows the frecuency of each clone. If "population"",
shows changes in population sizes.

The default is to use "frequecy".
}

\item{col}{ Colour of the lines/areas. For \code{show = "drivers"}
each type of clone (where type is defined by number of drivers) has
Expand Down Expand Up @@ -306,7 +316,6 @@
entries, and two for more than six.
}



\item{\dots}{
Other arguments passed to \code{plots}. For instance, \code{main}.
Expand Down
Loading