Skip to content

Commit

Permalink
Some tweaks to the shinyCOMPASS launcher; plot axis labels for single…
Browse files Browse the repository at this point in the history
…-facetting case
  • Loading branch information
kevinushey committed Mar 25, 2014
1 parent a808016 commit e2e622b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: COMPASS
Type: Package
Title: Combinatorial Polyfunctionality Analysis of Single Cells
Version: 1.1.5-1
Version: 1.1.5-2
Date: 2014-02-11
Authors@R: c( person("Lynn", "Lin", role="aut", email="llin@fhcrc.org"),
person("Kevin", "Ushey", role=c("aut", "cre"), email="kushey@fhcrc.org"),
Expand Down
18 changes: 15 additions & 3 deletions R/shinyCOMPASS.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
##' @param facet1,facet2,facet3 Default values for facets in the Shiny app.
##' Each should be the name of a single vector in the metadata.
##' @param main A title to give to the heatmap and subset histogram plots.
##' @param launch Boolean; if \code{TRUE} we launch the Shiny application.
##' Otherwise, the user can launch it manually by navigating to the directory
##' \code{dir} and running \code{shiny::runApp()}.
##' @param ... Optional arguments passed to \code{shiny::runApp}.
##' @seealso \code{\link{shinyCOMPASSDeps}}, for identifying packages that you
##' need in order to run the Shiny application.
Expand All @@ -26,7 +29,7 @@
##' options(example.ask=TRUE)
##' }
shinyCOMPASS <- function(x, dir=NULL, meta.vars, facet1="None", facet2="None",
facet3="None", main=NA, ...) {
facet3="None", main=NA, launch=TRUE, ...) {

if (length(shinyCOMPASSDeps(verbose=FALSE))) {
message("Error: Can't run the Shiny application as required packages ",
Expand Down Expand Up @@ -54,6 +57,8 @@ shinyCOMPASS <- function(x, dir=NULL, meta.vars, facet1="None", facet2="None",
on.exit(unlink(dir, recursive=TRUE))
}

dir <- path.expand(dir)

## Keep only the metadata variables specified
iid <- x$data$individual_id
sid <- x$data$sample_id
Expand Down Expand Up @@ -95,7 +100,14 @@ shinyCOMPASS <- function(x, dir=NULL, meta.vars, facet1="None", facet2="None",
dir.create( file.path(dir, "data"), showWarnings=FALSE )
saveRDS(x, file=file.path(dir, "data", "data.rds"))

message("Starting the Shiny application...")
runApp(file.path(dir), ...)
message("The files necessary for launching the COMPASS Shiny application have ",
"been copied to '", dir, "'.")

if (launch) {
message("Starting the Shiny application...")
runApp(file.path(dir), ...)
} else {
file.path(dir)
}

}
16 changes: 8 additions & 8 deletions inst/shiny/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -365,23 +365,23 @@ shinyServer( function(input, output, session) {

} else if (!is.null(facet1)) {

p <- ggplot(pf, aes_string(x="factor(1)", y="Score", fill=facet1)) +
p <- ggplot(pf, aes_string(y="Score", x=facet1, fill=facet1)) +
geom_boxplot(outlier.size = 0) +
geom_point(position=position_jitterdodge()) +
facet_wrap(~ FunctionalityType, scales="free_y") +
xlab("") +
theme(
axis.text.x=element_blank(),
axis.ticks.x=element_blank()
)
xlab("")

} else {

p <- ggplot(pf, aes_string(x="factor(1)", y="Score")) +
geom_boxplot(outlier.size = 0) +
geom_point(position=position_jitter()) +
geom_point(position=position_jitter(width=0.1)) +
facet_wrap(~ FunctionalityType, scales="free_y") +
xlab("")
xlab("") +
theme(
axis.text.x=element_blank(),
axis.ticks.x=element_blank()
)

}

Expand Down
7 changes: 6 additions & 1 deletion man/shinyCOMPASS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
\title{Start a Shiny Application for Visualizing COMPASS Results}
\usage{
shinyCOMPASS(x, dir = NULL, meta.vars, facet1 = "None", facet2 = "None",
facet3 = "None", main = NA, ...)
facet3 = "None", main = NA, launch = TRUE, ...)
}
\arguments{
\item{x}{An object of class \code{COMPASSResult}.}
Expand All @@ -25,6 +25,11 @@ shinyCOMPASS(x, dir = NULL, meta.vars, facet1 = "None", facet2 = "None",
\item{main}{A title to give to the heatmap and subset
histogram plots.}

\item{launch}{Boolean; if \code{TRUE} we launch the Shiny
application. Otherwise, the user can launch it manually
by navigating to the directory \code{dir} and running
\code{shiny::runApp()}.}

\item{...}{Optional arguments passed to
\code{shiny::runApp}.}
}
Expand Down

0 comments on commit e2e622b

Please sign in to comment.