Commit ea935f44 authored by dmattek's avatar dmattek
Browse files

Major rev: added clustering

parent b64429ce
## Custom plotting
require(ggplot2)
rhg_cols <- c(
"#771C19",
"#AA3929",
......@@ -24,6 +26,33 @@ md_cols <- c(
"#238443"
)
s.cl.linkage = c("ward.D",
"ward.D2",
"single",
"complete",
"average",
"mcquitty",
"centroid")
s.cl.spar.linkage = c("average",
"complete",
"single",
"centroid")
s.cl.diss = c("euclidean", "maximum", "manhattan", "canberra", "binary", "minkowski")
s.cl.spar.diss = c("squared.distance","absolute.value")
l.col.pal = list(
"White-Orange-Red" = 'OrRd',
"Yellow-Orange-Red" = 'YlOrRd',
"Reds" = "Reds",
"Oranges" = "Oranges",
"Greens" = "Greens",
"Blues" = "Blues",
"Spectral" = 'Spectral'
)
myGgplotTraj = function(dt.arg,
x.arg,
y.arg,
......@@ -115,16 +144,16 @@ myGgplotTraj = function(dt.arg,
userDataGen <- function() {
cat(file=stderr(), 'userDataGen: in\n')
locNtp = 13
locNtp = 40
locNtracks = 5
locNsites = 4
locNwells = 2
dt.nuc = data.table(Metadata_Site = rep(1:locNsites, each = locNtp * locNtracks),
Metadata_Well = rep(1:locNwells, each = locNtp * locNsites * locNtracks / locNwells),
Metadata_Time = rep(1:locNtp, locNsites* locNtracks),
meas_MeanIntensity_cyto = rnorm(locNtp * locNtracks * locNsites, .5, 0.1),
meas_MeanIntensity_nuc = rnorm(locNtp * locNtracks * locNsites, .5, 0.1),
Metadata_RealTime = rep(1:locNtp, locNsites* locNtracks),
objCyto_Intensity_MeanIntensity_imErkCor = rnorm(locNtp * locNtracks * locNsites, .5, 0.1),
objNuc_Intensity_MeanIntensity_imErkCor = rnorm(locNtp * locNtracks * locNsites, .5, 0.1),
TrackLabel = rep(1:(locNtracks*locNsites), each = locNtp))
cat(colnames(dt.nuc))
......@@ -189,4 +218,22 @@ myNorm = function(in.dt,
loc.dt[, c('meas.md', 'meas.mad') := NULL]
return(loc.dt)
}
\ No newline at end of file
}
myGgplotTheme = theme_bw(base_size = 18, base_family = "Helvetica") +
theme(
panel.grid.minor = element_blank(),
panel.grid.major = element_blank(),
axis.line.x = element_line(color = "black", size = 0.25),
axis.line.y = element_line(color = "black", size = 0.25),
axis.text.x = element_text(size = 12, angle = 45, hjust = 1),
axis.text.y = element_text(size = 12),
strip.text.x = element_text(size = 14, face = "bold"),
strip.text.y = element_text(size = 14, face = "bold"),
strip.background = element_blank(),
legend.key = element_blank(),
legend.key.height = unit(1, "lines"),
legend.key.width = unit(2, "lines"),
legend.position = "right"
)
\ No newline at end of file
source('auxfunc.R')
\ No newline at end of file
This diff is collapsed.
......@@ -49,12 +49,18 @@ shinyUI(fluidPage(
),
uiOutput('varSelMeas2'),
tags$hr(),
checkboxInput('chBtimeTrim', 'Trim x-axis', FALSE),
uiOutput('uiSlTimeTrim'),
tags$hr(),
checkboxInput('chBnorm', 'Normalization', FALSE),
uiOutput('uiChBnorm'),
uiOutput('uiSlNorm'),
uiOutput('uiChBnormRobust'),
uiOutput('uiChBnormGroup')
uiOutput('uiChBnormGroup'),
tags$hr(),
checkboxInput('chBoutliers', 'Remove outliers', FALSE),
uiOutput('uiSlOutliers')
),
mainPanel(tabsetPanel(
......@@ -101,7 +107,32 @@ shinyUI(fluidPage(
uiOutput('varSelHighlight'),
br(),
actionButton('butPlotTraj', 'Plot!'),
uiOutput('uiPlotTraj')
uiOutput('uiPlotTraj'),
h4('Download plot'),
fluidRow(
column(
3,
numericInput(
'inPlotTrajDownWidth',
"Width",
10,
min = 1,
width = 100
)
),
column(
3,
numericInput(
'inPlotTrajDownHeight',
"Height",
7,
min = 1,
width = 100
)
),
column(6,
downloadButton('downPlotTraj', 'PDF'))
)
),
tabPanel("Box-plots",
br(),
......@@ -153,7 +184,475 @@ shinyUI(fluidPage(
column(6,
downloadButton('downPlotBox', 'PDF'))
)
#uiOutput('uiPlotBox')
),
tabPanel(
'Hierarchical',
br(),
fluidRow(
column(
6,
selectInput(
"selectPlotHierLinkage",
label = ("Select linkage method:"),
choices = list(
"Ward" = 1,
"Ward D2" = 2,
"Single" = 3,
"Complete" = 4,
"Average" = 5,
"McQuitty" = 6,
"Centroid" = 7
),
selected = 2
),
selectInput(
"selectPlotHierDiss",
label = ("Select type of dissimilarity measure:"),
choices = list("Euclidean" = 1,
"Maximum" = 2,
"Manhattan" = 3,
"Canberra" = 4,
"Binary" = 5,
"Minkowski" = 6),
selected = 1
)
),
column(6,
sliderInput(
'inPlotHierNclust',
'#dendrogram branches to colour',
min = 1,
max = 20,
value = 1,
step = 1,
ticks = TRUE,
round = TRUE
),
checkboxInput('chBPlotHierClSel', 'Manually select clusters to display'),
uiOutput('uiPlotHierClSel')
)
),
br(),
#checkboxInput('inPlotHierSparInteractive', 'Interactive Plot?', value = FALSE),
tabsetPanel(
tabPanel('Heat-map',
fluidRow(
column(3,
checkboxInput('selectPlotHierDend', 'Plot dendrogram and re-order samples', TRUE),
selectInput(
"selectPlotHierPalette",
label = "Select colour palette:",
choices = l.col.pal,
selected = 'Spectral'
),
checkboxInput('inPlotHierRevPalette', 'Reverse colour palette', TRUE),
checkboxInput('selectPlotHierKey', 'Plot colour key', TRUE)
),
column(3,
sliderInput(
'inPlotHierNAcolor',
'Shade of grey for NA values (0 - black, 1 - white)',
min = 0,
max = 1,
value = 0.8,
step = .1,
ticks = TRUE
),
numericInput('inPlotHierHeatMapHeight',
'Display plot height [px]',
value = 600,
min = 100,
step = 100)
),
column(6,
h4('Classic hierarchical clustering')
)
),
fluidRow(
column(
3,
numericInput(
'inPlotHierMarginX',
'Margin below x-axis',
5,
min = 1,
width = 100
)
),
column(
3,
numericInput(
'inPlotHierMarginY',
'Margin right of y-axis',
20,
min = 1,
width = 100
)
),
column(
3,
numericInput(
'inPlotHierFontX',
'Font size row labels',
1,
min = 0,
width = 100,
step = 0.1
)
),
column(
3,
numericInput(
'inPlotHierFontY',
'Font size column labels',
1,
min = 0,
width = 100,
step = 0.1
)
)
),
br(),
h4('Download plot'),
fluidRow(
column(
4,
numericInput(
'inPlotHierWidth',
"Width",
7,
min = 1,
width = 100
)
),
column(
4,
numericInput(
'inPlotHierHeight',
"Height",
6,
min = 1,
width = 100
)
),
column(4,
downloadButton('downPlotHier', 'PDF'))
),
actionButton('butPlotHierHeatMap', 'Plot!'),
plotOutput('outPlotHier')
),
# tabPanel('Heat-map int.',
# helpText("Choose your settings 2")),
tabPanel('Time-courses',
h4('Download plot'),
fluidRow(
column(
4,
numericInput(
'inPlotHierTrajWidth',
"Width",
7,
min = 1,
width = 100
)
),
column(
4,
numericInput(
'inPlotHierTrajHeight',
"Height",
6,
min = 1,
width = 100
)
),
column(4,
downloadButton('downPlotHierTraj', 'PDF'))
),
actionButton('butPlotHierTraj', 'Plot!'),
plotOutput('outPlotHierTraj')),
tabPanel('Cluster dist.',
fluidRow(
column(
8,
h4('Download plot'),
numericInput(
'inPlotHierClDistWidth',
"Width",
7,
min = 1,
width = 100
),
numericInput(
'inPlotHierClDistHeight',
"Height",
6,
min = 1,
width = 100
),
downloadButton('downPlotHierClDist', 'PDF')
)),
actionButton('butPlotHierClDist', 'Plot!'),
plotOutput('outPlotHierClDist'))
)
),
tabPanel(
'Hier. Sparse',
br(),
fluidRow(
column(
6,
selectInput(
"selectPlotHierSparLinkage",
label = ("Select linkage method:"),
choices = list(
"Average" = 1,
"Complete" = 2,
"Single" = 3,
"Centroid" = 4
),
selected = 1
),
selectInput(
"selectPlotHierSparDiss",
label = ("Select type of dissimilarity measure:"),
choices = list("Squared Distance" = 1,
"Absolute Value" = 2),
selected = 1
),
sliderInput(
'inPlotHierSparNclust',
'#dendrogram branches to colour',
min = 1,
max = 30,
value = 1,
step = 1,
ticks = TRUE,
round = TRUE
)
),
column(
6,
checkboxInput('inHierSparAdv',
'Advanced options',
FALSE),
uiOutput(
'uiPlotHierSparNperms'
),
uiOutput(
'uiPlotHierSparNiter'
),
checkboxInput('chBPlotHierSparClSel', 'Manually select clusters to display'),
uiOutput('uiPlotHierSparClSel')
)
),
br(),
#checkboxInput('inPlotHierSparInteractive', 'Interactive Plot?', value = FALSE),
tabsetPanel(
tabPanel('Heat-map',
fluidRow(
column(3,
radioButtons(
"selectPlotHierSparDend",
label = 'Dendrogram',
choices = list(
'Plot dendrogram; order samples accordingly' = 1,
'Don\'t plot dendrogram; retain original ordering' = 2
),
selected = 1
),
selectInput(
"selectPlotHierSparPalette",
label = "Select colour palette:",
choices = l.col.pal,
selected = 'Spectral'
),
checkboxInput('inPlotHierSparRevPalette', 'Reverse colour palette', TRUE),
checkboxInput('selectPlotHierSparKey', 'Plot colour key', TRUE)
),
column(3,
sliderInput(
'inPlotHierSparNAcolor',
'Shade of grey for NA values (0 - black, 1 - white)',
min = 0,
max = 1,
value = 0.8,
step = .1,
ticks = TRUE
)
),
column(6,
br(),
h4(
"Sparse hierarchical clustering using ",
a("sparcl", href = "https://cran.r-project.org/web/packages/sparcl/")
),
p(
'Column labels in the heat-map are additionally labeld according to their \"importance\":'
),
tags$ol(
tags$li("Black - not taken into account"),
tags$li("Blue with \"*\" - low importance (weight factor in (0, 0.1]"),
tags$li("Green with \"**\" - medium importance (weight factor in (0.1, 0.5]"),
tags$li("Red with \"***\" - high importance (weight factor in (0.5, 1.0]")
)
)
),
fluidRow(
column(
3,
numericInput(
'inPlotHierSparMarginX',
'Margin below x-axis',
5,
min = 1,
width = 100
)
),
column(
3,
numericInput(
'inPlotHierSparMarginY',
'Margin right of y-axis',
20,
min = 1,
width = 100
)
),
column(
3,
numericInput(
'inPlotHierSparFontX',
'Font size row labels',
1,
min = 0,
width = 100,
step = 0.1
)
),
column(
3,
numericInput(
'inPlotHierSparFontY',
'Font size column labels',
1,
min = 0,
width = 100,
step = 0.1
)
)
),
br(),
h4('Download plot'),
fluidRow(
column(
4,
numericInput(
'inPlotHierSparWidth',
"Width",
7,
min = 1,
width = 100
)
),
column(
4,
numericInput(
'inPlotHierSparHeight',
"Height",
6,
min = 1,
width = 100
)
),
column(4,
downloadButton('downPlotHierSpar', 'PDF'))
),
numericInput('inPlotHierSparHeatMapHeight',
'Display plot height [px]',
value = 600,
min = 100,
step = 100),
actionButton('butPlotHierSparHeatMap', 'Plot!'),
plotOutput('outPlotHierSpar')
),
# tabPanel('Heat-map int.',
# helpText("Choose your settings 2")),
tabPanel('Time-courses',
h4('Download plot'),
fluidRow(
column(
4,
numericInput(
'inPlotHierSparTrajWidth',
"Width",
7,
min = 1,
width = 100
)
),
column(
4,
numericInput(
'inPlotHierSparTrajHeight',
"Height",
6,
min = 1,
width = 100
)
),
column(4,
downloadButton('downPlotHierSparTraj', 'PDF'))
),
actionButton('butPlotHierSparTraj', 'Plot!'),
plotOutput('outPlotHierSparTraj')),
tabPanel('Cluster dist.',
h4('Download plot'),
fluidRow(
column(
4,
numericInput(
'inPlotHierSparClDistWidth',
"Width",
7,
min = 1,
width = 100
)
),
column(
4,
numericInput(
'inPlotHierSparClDistHeight',
"Height",
6,
min = 1,
width = 100
)
),
column(4,
downloadButton('downPlotHierSparClDist', 'PDF'))
),
actionButton('butPlotHierSparClDist', 'Plot!'),
plotOutput('outPlotHierSparClDist'))
)
)
))
)
......
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