Skip to content

Commit

Permalink
Merge pull request #84 from databio/staging
Browse files Browse the repository at this point in the history
bug fixes
  • Loading branch information
vpnagraj authored Apr 27, 2018
2 parents 04eb2f9 + 5391264 commit 0c5e255
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 395 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ apps/LOLAweb/cache
apps/LOLAweb/shinylog
apps/LOLAweb/results
apps/LOLAweb/userSets
apps/LOLAweb/scratch.R
61 changes: 53 additions & 8 deletions apps/LOLAweb/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,8 @@ ui <- list(
column(DT::dataTableOutput("res"), width = 12)
),
tabPanel("Run summary",
conditionalPanel(condition = "output.res",
h4("Run summary"),
tableOutput("run_sum"), style = "font-size:18px;")
)
),
id = "result-tabs")))
)
Expand Down Expand Up @@ -590,15 +588,42 @@ server <- function(input, output, session) {
# need to make sure user set is discrete even if coded as number
resRedefined$userSet = as.character(resRedefined$userSet)

gd_data <- utils::data(package="GenomicDistributions")$results[,"Item"]

# calculate distribution over chromosomes for plotting
genDist = aggregateOverGenomeBins(userSets, input$refgenome)
if (paste0("chromSizes_", input$refgenome) %in% gd_data) {

genDist = aggregateOverGenomeBins(userSets, input$refgenome)

} else {

genDist = NULL

}

# calculate distances to TSSs
TSSDist = TSSDistance(userSets, input$refgenome)
if (paste0("TSS_", input$refgenome) %in% gd_data) {

TSSDist = TSSDistance(userSets, input$refgenome)


} else {

TSSDist = NULL

}

# distribution of overlaps for a query set to genomic partitions
gp = genomicPartitions(userSets, input$refgenome)
if (paste0("geneModels_", input$refgenome) %in% gd_data) {

gp = genomicPartitions(userSets, input$refgenome)

} else {

gp = NULL

}

})

run_sum <-
Expand Down Expand Up @@ -1140,7 +1165,17 @@ server <- function(input, output, session) {

genDist <- rawdat_res$genDist

plotGenomeAggregate(genomeAggregate = genDist)
if (is.null(genDist)) {

NULL

} else {

plotGenomeAggregate(genomeAggregate = genDist) +
guides(fill=guide_legend(title="User set"),
col = guide_legend(title="User set"))

}

}

Expand All @@ -1158,8 +1193,18 @@ server <- function(input, output, session) {

TSSDist <- rawdat_res$TSSDist

plotFeatureDist(TSSDist, featureName="TSS")

if (is.null(TSSDist)) {

NULL

} else {

plotFeatureDist(TSSDist, featureName="TSS") +
guides(fill=guide_legend(title="User set"),
col = guide_legend(title="User set"))

}

}

output$dist_plot <- renderPlot({
Expand Down
9 changes: 5 additions & 4 deletions apps/LOLAweb/misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ plot_input <- function(res, metric, ylabel, sortcol) {
if(grepl("rnk", sortcol, ignore.case = TRUE)) {

# need to order data frame by sort col if it's a rank
dat <- res[order(as.data.frame(res)[,sortcol]), ]
res <- res[order(as.data.frame(res)[,sortcol]), ]

# now construct base layer for plot with reverse on the sort
p <- ggplot(dat, aes(reorder(axis_label,
p <- ggplot(res, aes(reorder(axis_label,
rev(eval(parse(text = sortcol)))), eval(parse(text = metric)), fill = userSet, group = id))

} else {
Expand All @@ -48,14 +48,15 @@ plot_input <- function(res, metric, ylabel, sortcol) {
}

# Make label size dynamic based on number of entries in the table.
label_size = 9 + ( 8 * (1 - NROW(dat)/50) )
label_size = 9 + ( 8 * (1 - NROW(res)/50) )
p +
geom_bar(stat="identity", position="dodge") +
xlab("Description") +
ylab(ylabel) +
coord_flip() +
theme_ns() +
theme(axis.text=element_text(size=label_size))
theme(axis.text=element_text(size=label_size)) +
guides(fill=guide_legend(title="User set"))

}

Expand Down
Loading

0 comments on commit 0c5e255

Please sign in to comment.