Skip to content

Commit e93520b

Browse files
committedAug 16, 2015
cleanup formatting a bit
1 parent 2e2aec7 commit e93520b

File tree

5 files changed

+124
-39
lines changed

5 files changed

+124
-39
lines changed
 

‎NAMESPACE

+3
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@ export(basic_filter)
1212
export(bs_sigma_summary)
1313
export(counts_to_fpkm)
1414
export(counts_to_tpm)
15+
export(enclosed_brush)
1516
export(get_quantile)
1617
export(melt_bootstrap_sleuth)
1718
export(models)
1819
export(norm_factors)
1920
export(plot_bootstrap)
21+
export(plot_group_density)
2022
export(plot_ma)
2123
export(plot_mean_var)
2224
export(plot_pca)
25+
export(plot_sample_density)
2326
export(plot_scatter)
2427
export(plot_transcript)
2528
export(plot_transcript_variability)

‎R/plots.R

+21-4
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,11 @@ plot_pca <- function(obj,
127127
#' @param trans a string pointing to a function to use for the transformation.
128128
#' @param grouping a string from the columns of \code{sample_to_covariates} in
129129
#' the sleuth object for which to group and color by
130-
#' @param offset the offset so that transformations such as log don't compute -Inf. If NULL, then will not add an offset (one could also use
131-
#' @param
132-
plot_gorup_density <- function(obj,
130+
#' @param offset the offset so that transformations such as log don't compute
131+
#' -Inf. If NULL, then will not add an offset
132+
#' @return a \code{ggplot2} object
133+
#' @export
134+
plot_group_density <- function(obj,
133135
use_filtered = TRUE,
134136
units = 'est_counts',
135137
trans = 'log',
@@ -166,6 +168,21 @@ plot_gorup_density <- function(obj,
166168
p
167169
}
168170

171+
#' Plot sample density
172+
#'
173+
#' Plot the density of one particular sample
174+
#'
175+
#' @param obj a \code{sleuth} object
176+
177+
#' @param which_sample a character string matching a sample in
178+
#' \code{obj$sample_to_covariates}
179+
#' @param use_filtered if TRUE, use filtered data. Otherwise use all data
180+
#' @param units either \code{'est_counts'} or \code{'tpm'}
181+
#' @param trans a string pointing to a function to use for the transformation.
182+
#' @param offset the offset so that transformations such as log don't compute
183+
#' -Inf. If NULL, then will not add an offset
184+
#' @return a \code{ggplot2} object
185+
#' @export
169186
plot_sample_density <- function(obj,
170187
which_sample = obj$sample_to_covariates$sample[1],
171188
use_filtered = TRUE,
@@ -245,7 +262,7 @@ plot_scatter <- function(obj,
245262
sample_y <- paste0( trans, '( ', sample_y)
246263
}
247264

248-
if ( offset != 0 ) {
265+
if ( (!is.null(offset) && !is.na(offset)) && offset != 0 ) {
249266
off <- deparse(eval(offset))
250267
sample_x <- paste0(sample_x, ' + ', off)
251268
sample_y <- paste0(sample_y, ' + ', off)

‎R/shiny.R

+37-35
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,39 @@ sleuth_interact <- function(obj, select_trans = FALSE, ...) {
2929
a('sleuth', href = 'http://pimentel.github.io/sleuth', target = '_blank',
3030
style = 'color: black;'),
3131

32-
tabPanel('diagnostics'),
32+
tabPanel('diagnostics',
33+
####
34+
fluidRow(
35+
column(4,
36+
selectInput('sample_x', label = 'x-axis: ',
37+
choices = samp_names,
38+
selected = samp_names[1])
39+
),
40+
column(4,
41+
selectInput('sample_y', label = 'y-axis: ',
42+
choices = samp_names,
43+
selected = samp_names[2])
44+
),
45+
column(2,
46+
textInput('trans', label = 'transform: ',
47+
value = 'log')),
48+
column(2,
49+
numericInput('scatter_offset', label = 'offset: ', value = 1))
50+
),
51+
fluidRow(
52+
column(2,
53+
selectInput('scatter_units', label = 'units: ',
54+
choices = c('est_counts', 'tpm'),
55+
selected = 'est_counts')),
56+
column(2,
57+
checkboxInput('scatter_filt', label = 'filter',
58+
value = TRUE)),
59+
column(2,
60+
numericInput('scatter_alpha', label = 'opacity:', value = 0.2,
61+
min = 0, max = 1, step = 0.01))
62+
),
63+
plotOutput('scatter')
64+
),
3365

3466
navbarMenu('summaries',
3567
####
@@ -137,38 +169,6 @@ sleuth_interact <- function(obj, select_trans = FALSE, ...) {
137169
plotOutput('mv_plt')
138170
),
139171

140-
####
141-
tabPanel('scatter plots',
142-
fluidRow(
143-
column(4,
144-
selectInput('sample_x', label = 'x-axis: ',
145-
choices = samp_names,
146-
selected = samp_names[1])
147-
),
148-
column(4,
149-
selectInput('sample_y', label = 'y-axis: ',
150-
choices = samp_names,
151-
selected = samp_names[2])
152-
),
153-
column(2,
154-
textInput('trans', label = 'transform: ',
155-
value = 'log')),
156-
column(2,
157-
numericInput('scatter_alpha', label = 'opacity:', value = 0.2,
158-
min = 0, max = 1, step = 0.01))
159-
),
160-
fluidRow(
161-
column(2,
162-
selectInput('scatter_units', label = 'units: ',
163-
choices = c('est_counts', 'tpm'),
164-
selected = 'est_counts')),
165-
column(2,
166-
checkboxInput('scatter_filt', label = 'filter',
167-
value = TRUE)),
168-
column(2,
169-
numericInput('scatter_offset', label = 'offset: ', value = 1))
170-
),
171-
plotOutput('scatter')),
172172

173173
####
174174
tabPanel('DE table',
@@ -200,7 +200,7 @@ sleuth_interact <- function(obj, select_trans = FALSE, ...) {
200200
output$summary_dt <- renderDataTable(summary(obj))
201201

202202
output$condition_density <- renderPlot({
203-
plot_density(obj,
203+
plot_group_density(obj,
204204
grouping = input$cond_dens_grp,
205205
units = input$cond_dens_units,
206206
use_filtered = input$cond_dens_filt,
@@ -223,7 +223,8 @@ sleuth_interact <- function(obj, select_trans = FALSE, ...) {
223223
plot_scatter(obj, input$sample_x, input$sample_y,
224224
trans = input$trans, point_alpha = input$scatter_alpha,
225225
units = input$scatter_units,
226-
use_filtered = input$scatter_filt)
226+
use_filtered = input$scatter_filt,
227+
offset = input$scatter_offset)
227228
})
228229

229230
###
@@ -353,6 +354,7 @@ sleuth_interact <- function(obj, select_trans = FALSE, ...) {
353354
shinyApp(ui = p_layout, server = server_fun)
354355
}
355356

357+
#' @export
356358
enclosed_brush <- function(df, brush) {
357359
xvar <- brush$mapping$x
358360
yvar <- brush$mapping$y

‎man/plot_group_density.Rd

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
% Generated by roxygen2 (4.1.1): do not edit by hand
2+
% Please edit documentation in R/plots.R
3+
\name{plot_group_density}
4+
\alias{plot_group_density}
5+
\title{Plot density}
6+
\usage{
7+
plot_group_density(obj, use_filtered = TRUE, units = "est_counts",
8+
trans = "log", grouping = setdiff(colnames(obj$sample_to_covariates),
9+
"sample"), offset = 1)
10+
}
11+
\arguments{
12+
\item{obj}{a \code{sleuth} object}
13+
14+
\item{use_filtered}{if TRUE, use filtered data. otherwise use all data}
15+
16+
\item{units}{either 'est_counts' or 'tpm'}
17+
18+
\item{trans}{a string pointing to a function to use for the transformation.}
19+
20+
\item{grouping}{a string from the columns of \code{sample_to_covariates} in
21+
the sleuth object for which to group and color by}
22+
23+
\item{offset}{the offset so that transformations such as log don't compute
24+
-Inf. If NULL, then will not add an offset}
25+
}
26+
\value{
27+
a \code{ggplot2} object
28+
}
29+
\description{
30+
Plot the density of a some grouping
31+
}
32+

‎man/plot_sample_density.Rd

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
% Generated by roxygen2 (4.1.1): do not edit by hand
2+
% Please edit documentation in R/plots.R
3+
\name{plot_sample_density}
4+
\alias{plot_sample_density}
5+
\title{Plot sample density}
6+
\usage{
7+
plot_sample_density(obj, which_sample = obj$sample_to_covariates$sample[1],
8+
use_filtered = TRUE, units = "est_counts", trans = "log", offset = 1)
9+
}
10+
\arguments{
11+
\item{obj}{a \code{sleuth} object}
12+
13+
\item{which_sample}{a character string matching a sample in
14+
\code{obj$sample_to_covariates}}
15+
16+
\item{use_filtered}{if TRUE, use filtered data. Otherwise use all data}
17+
18+
\item{units}{either \code{'est_counts'} or \code{'tpm'}}
19+
20+
\item{trans}{a string pointing to a function to use for the transformation.}
21+
22+
\item{offset}{the offset so that transformations such as log don't compute
23+
-Inf. If NULL, then will not add an offset}
24+
}
25+
\value{
26+
a \code{ggplot2} object
27+
}
28+
\description{
29+
Plot the density of one particular sample
30+
}
31+

0 commit comments

Comments
 (0)
Please sign in to comment.