Commit 9d1f5677 authored by dmattek's avatar dmattek

added: rotated x-axis labels

parent 554bb9a8
......@@ -40,15 +40,19 @@ install.packages(c("shiny", "shinyjs",
```
**Note**
As of July 2018, *sparcl* has been removed from CRAN. If you don't need sparse hierarchical clustering, you can simply comment the line `library(sparcl)` in `server.R` file or install it from the [archive](https://cran.r-project.org/web/packages/sparcl/index.html).
As of July 2018, *sparcl* has been removed from CRAN. If you don't need sparse hierarchical clustering, you can simply comment the line `library(sparcl)` in `server.R` file or install it from the [archive](https://cran.r-project.org/web/packages/sparcl/index.html):
**Additionally**, a time series analysis package need to be installed from [GitHub](https://github.com/dmattek/tca-package):
```
install_url('https://cran.r-project.org/src/contrib/Archive/sparcl/sparcl_1.0.3.tar.gz')
```
**Additionally**, a time series analysis package needs to be installed from [GitHub](https://github.com/dmattek/tca-package):
```
install_github("dmattek/tca-package")
```
The `install_github` function is available in *devtools* package:
The `install_url` and `install_github` functions are available in *devtools* package:
```
install.packages("devtools")
......
......@@ -170,6 +170,22 @@ getClCol <- function(in.dend, in.k) {
#####
## Common plotting functions
# Build Function to Return Element Text Object
# From: https://stackoverflow.com/a/36979201/1898713
rotatedAxisElementText = function(angle, position='x', size = 12){
angle = angle[1];
position = position[1]
positions = list(x=0, y=90, top=180, right=270)
if(!position %in% names(positions))
stop(sprintf("'position' must be one of [%s]",paste(names(positions),collapse=", ")), call.=FALSE)
if(!is.numeric(angle))
stop("'angle' must be numeric",call.=FALSE)
rads = (-angle - positions[[ position ]])*pi/180
hjust = round((1 - sin(rads)))/2
vjust = round((1 + cos(rads)))/2
element_text(size = 12, angle = angle, vjust = vjust, hjust = hjust)
}
myGgplotTheme =
theme_bw(base_size = 8, base_family = "Helvetica") +
theme(
......
......@@ -31,7 +31,6 @@ modBoxPlotUI = function(id, label = "Plot Box-plots") {
),
selected = 'top'
),
checkboxInput(ns('chBxAxisLabelsRotate'), 'Rotate x-axis labels?'),
uiOutput(ns('uiPlotBoxNotches')),
uiOutput(ns('uiPlotBoxOutliers')),
uiOutput(ns('uiPlotBoxDodge')),
......@@ -56,7 +55,11 @@ modBoxPlotUI = function(id, label = "Plot Box-plots") {
min = 100,
width = '100px',
step = 50
)
),
radioButtons(ns("rBAxisLabelsRotate"), "X-axis labels:",
c("horizontal" = 0,
"45deg" = 45,
"90 deg" = 90))
)
),
......@@ -238,15 +241,9 @@ modBoxPlot = function(input, output, session,
ylab('') +
ggplotTheme() +
#myGgplotTheme +
theme(legend.position = input$selPlotBoxLegendPos)
if (input$chBxAxisLabelsRotate)
p.out = p.out +
theme(axis.text.x = element_text(size = 12, angle = 45, hjust = 1))
else
p.out = p.out +
theme(axis.text.x = element_text(size = 12))
theme(legend.position = input$selPlotBoxLegendPos,
axis.text.x = element_text(size = 12, angle = as.numeric(input$rBAxisLabelsRotate), hjust = ifelse(input$rBAxisLabelsRotate == 0, 0, 1)))
return(p.out)
}
......
......@@ -2,6 +2,10 @@ modClDistPlotUI = function(id, label = "Plot Fractions WIthin Clusters") {
ns <- NS(id)
tagList(
radioButtons(ns("rBAxisLabelsRotate"), "X-axis labels:",
c("horizontal" = 0,
"45deg" = 45,
"90 deg" = 90)),
actionButton(ns('butPlotClDist'), 'Plot!'),
plotOutput(ns('outPlotClDist'), height = '800px', width = 'auto'),
downPlotUI(ns('downPlotClDist'), "Download PDF")
......@@ -45,11 +49,18 @@ modClDistPlot = function(input, output, session, in.data, in.cols = NULL, in.fna
#limits = in.cols()$cl.no)
loc.rads = as.numeric(input$rBAxisLabelsRotate) * pi / 180
loc.hjust = 0.5*(1-sin(loc.rads))
loc.vjust = 0.5*(1-cos(loc.rads))
p.out = p.out +
scale_y_continuous(labels = percent) +
ylab("percentage of cells\n") +
xlab("") +
ggplotTheme()
ggplotTheme() +
theme(
axis.text.x = rotatedAxisElementText(as.numeric(input$rBAxisLabelsRotate))
)
#myGgplotTheme
return(p.out)
......
......@@ -18,7 +18,7 @@ library(dendextend) # for color_branches
library(colorspace) # for palettes (used to colour dendrogram)
library(RColorBrewer)
# sparcl temporarily unavailable on CRAN
#library(sparcl) # sparse hierarchical and k-means
library(sparcl) # sparse hierarchical and k-means
library(scales) # for percentages on y scale
library(dtw) # for dynamic time warping
library(imputeTS) # for interpolating NAs
......
......@@ -142,13 +142,13 @@ shinyUI(fluidPage(
tabPanel(
'Hierarchical',
clustHierUI('tabClHier')
)
),
# sparse hierarchical clustering package sparcl temporarily unavailable from CRAN
# tabPanel(
# 'Hierarchical Sparse',
# clustHierSparUI('tabClHierSpar')
#)
tabPanel(
'Hierarchical Sparse',
clustHierSparUI('tabClHierSpar')
)
))
)
))
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment