Commit 29ac9794 authored by fsoubes's avatar fsoubes
Browse files

add matrix

parent 037145f3
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
File added
#!/bin/bash
Rscript -e 'library(methods); shiny::runApp(".", launch.browser=TRUE)'
This diff is collapsed.
This diff is collapsed.
#Source https://stackoverflow.com/questions/33839543/shiny-server-session-time-out-doesnt-work
# but seems to not work
inactivity <- "function idleTimer() {
var t = setTimeout(logout, 5000);
window.onmousemove = resetTimer; // catches mouse movements
window.onmousedown = resetTimer; // catches mouse movements
window.onclick = resetTimer; // catches mouse clicks
window.onscroll = resetTimer; // catches scrolling
window.onkeypress = resetTimer; //catches keyboard actions
function logout() {
window.close(); //close the window
}
function resetTimer() {
clearTimeout(t);
t = setTimeout(logout, 5000); // time is in milliseconds (1000 is 1 second)
}
}
idleTimer();"
#The following html are sourced from https://github.com/aghozlane/shaman/blob/master/css/owncss.R
spincss <- "
#plot-container {
z-index: 0;
position: relative;
}
#loading-spinner {
position: absolute;
left: 50%;
top: 50%;
z-index: -1;
margin-top: 33px; /* half of the spinner's height */
margin-left: -33px; /* half of the spinner's width */
}
.recalculating {
z-index: -2;
background-color: #fff;
}
"
Errorcss <-
".shiny-output-error { visibility: visible; color: #3c8dbc;}
.shiny-output-error:before {
color: #3c8dbc;
visibility: visible;
#content: 'An error occurred. Please contact us at franck.soubes@inra.fr'; }
content: 'ok'; }
}
"
appCSS <- "
#loading-content {
position: absolute;
background: #182b42;
opacity: 0.9;
z-index: 100;
left: 0;
right: 0;
top: 30px;
height: 100%;
text-align: center;
color: #FFFFFF;
}
#loading-content-bar {
position: absolute;
background: #182b42;
opacity: 0.9;
z-index: 100;
left: 0;
right: 0;
height: 100%;
text-align: center;
color: #FFFFFF;
}
"
gaugeCSS <- "
.html-widget.gauge svg {
height: 100%;
margin-top: -10px;
margin-bottom: -40px;
}
"
#' addNews is a function that render a pretty table for news
#'
#' @param date
#' @param title
#' @param text
#' @author Amine Ghozlane
#' Source https://github.com/aghozlane/shaman/blob/master/Rfunctions/Data_Management.R
#'
#' @return
#' @export
#'
#' @examples
#'
addNews <- function(date ="",title="",text="")
{
res=list()
res$r1 = paste("<b><font size='+1'>",date,"</font></b>", " - ", "<b><font size='+1'>",title,"</font></b><br/>")
res$r2 = paste("<p><font color='grey'>",text,"</font></p><hr/>")
return(HTML(unlist(res)))
}
#InfoBoxCSS <- "
#.info-box:hover,
#.info-box:hover .info-box-icon {
#background-color: #aaa !important;
#}
#.info-box:active,
#.info-box:active .info-box-icon {
#background-color: #ccc !important;
#}
#"
@import url("//fonts.googleapis.com/css?family=Lobster|Cabin:400,700");
@import url("//fonts.googleapis.com/css?family=Tangerine|Inconsolata|Droid+Sans");
h1 {
font-family: 'Lobster', cursive;
font-weight: 500;
line-height: 1.5;
color: #ad1d28;
position: static;
}
ul li {
font-family: 'Inconsolata', cursive;
font-weight: 500;
line-height: 1.5;
color: black;
position: static;
font-size: 18px;
}
.skin-blue .sidebar-menu > li.active > a,.skin-blue .sidebar-menu > li:hover > a {
color:#fff;
background:#3c8dbc;
border-left-color:#3c8dbc
}
h2 {
font-family: 'Lobster', cursive;
font-weight: 500;
line-height: 1.5;
color: #ad1d28;
position: relative;
left: 15px
}
#container {
font-size: 20px;
}
p {
/*
font-family: 'Inconsolata', cursive;*/
font-weight: 500;
font-size: 18px;
line-height: 1.5;
color: black;
position: static;
}
.skin-blue .main-header .logo {
background-color:#1D4D68;
}
/* navbar (rest of the header) */
.skin-blue .main-header .navbar {
background-color:#1D4D68;
}
/* main sidebar */
.skin-blue .main-sidebar {
background-color:#1D4D68;
}
/*
#homepage .nav-tabs-custom>.tab-content{background:#fff;padding:10px;border-bottom-right-radius:3px;border-bottom-left-radius:3px}*/
.nav-tabs-custom>.tab-content{background:#3c8dbc;padding:10px;border-bottom-right-radius:3px;border-bottom-left-radius:3px}
#homepage .nav-tabs-custom>.tab-content{background:#fff;padding:10px;border-bottom-right-radius:3px;border-bottom-left-radius:3px}
#upload .nav-tabs-custom>.tab-content{background:#fff;padding:10px;border-bottom-right-radius:3px;border-bottom-left-radius:3px}
#ACP .nav-tabs-custom>.tab-content{background:#ecf0f5;padding:10px;border-bottom-right-radius:3px;border-bottom-left-radius:3px}
#barplotvenn .élément {
width: 100%;
height: 30%;
}
#advancedjvenn .btn{
border: none;
outline: none;
padding: 6px 11px;
cursor: pointer;
background-color: #337ab7;
}
#advancedjvenn .élément{
color:black;
}
#advancedjvenn .active, .btn:hover {
background-color: #666;
color: white;
}
#mytextvolc p{
font-weight: 700;
font-size: 14px;
line-height: 1.5;
color: white;
position: static;
}
.nav-tabs-custom > .nav-tabs > li.active:hover > a, .nav-tabs-custom > .nav-tabs > li.active > a {
background-color: #3c8dbc;
color: #3c8dbc;
}
.content-wrapper, .right-side {
min-height: 100%;
background-color: #ecf0f5;
z-index: 800;
}
.irs-bar { height: 8px; top: 25px; border-top: 1px solid #337ab7; border-bottom: 1px solid #337ab7; background: #337ab7; } .irs-bar-edge { height: 8px; top: 25px; width: 14px; border: 1px solid #337ab7; border-right: 0; background: #337ab7; border-radius: 16px 0 0 16px; -moz-border-radius: 16px 0 0 16px; }
.irs-max {
color: #fff;
font-size: 10px;
line-height: 1.333;
text-shadow: none;
top: 0;
padding: 1px 3px;
background: rgba(0,0,0,0.1);
border-radius: 3px;
-moz-border-radius: 3px;
}
.irs-min {
color: #fff;
font-size: 10px;
line-height: 1.333;
text-shadow: none;
top: 0;
padding: 1px 3px;
background: rgba(0,0,0,0.1);
border-radius: 3px;
-moz-border-radius: 3px;
}
.irs-grid-text {
bottom: 5px;
color: #fff;
}
.nav-tabs-custom .nav-tabs li.active:hover a, .nav-tabs-custom .nav-tabs li.active a {
background-color: transparent;
border-color: transparent;
}
.nav-tabs-custom .nav-tabs li.active {
border-top-color: #FFF;
}
div.outer {
height: calc(100vh - 80px);
padding: 0;
margin: 0;
min-height: 500px
}
@media all and (max-width:768px){
div.outer {
position: fixed;
top: 70px;
left: 0;
right: 0;
bottom: 0;
overflow: hidden;
padding: 0;
}
}
.dt-button.buttons-columnVisibility {
background: #FF0000 !important;
color: white !important;
opacity: 0.5;
}
.dt-button.buttons-columnVisibility.active {
background: black !important;
color: white !important;
opacity: 1;
}
#Video {
position: relative;
padding-bottom: 100%; /* 16:9 */
height: 0;
}
.iframe-box {
max-width: 1280px; /* video width */
max-height: 720px; /* video height */
}
.fittobox { /* give fit to box an aspect ratio */
display: inline-block; /* let it be styled thusly */
padding: 0; /* get rid of pre-styling */
margin: 0;
width: 100%; /* take up full width available */
padding-top: 56.25%; /* give aspect ratio of 16:9; "720 / 1280 = 0.5625" */
height: 0px; /* don't want it to expand beyond padding */
position: relative; /* allow for absolute positioning of child elements */
}
.fittobox > iframe {
position: absolute; /* expand to fill */
top: 0px;
left: 0px;
right: 0px;
bottom: 0px;
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
"";"Grp"
"LWT_Ctrl2";"LWT_CTRL"
"LWT_CARBO5";"LWT_CARBO"
"LKO_Ctrl3";"LKO_CTRL"
"LKO_CARBO1";"LKO_CARBO"
"LKO_CARBO4";"LKO_CARBO"
"LKO_Ctrl6";"LKO_CTRL"
"LWT_CARBO2";"LWT_CARBO"
"LWT_Ctrl5";"LWT_CTRL"
"LWT_CARBO1";"LWT_CARBO"
"LWT_Ctrl6";"LWT_CTRL"
"LKO_CARBO5";"LKO_CARBO"
"LKO_Ctrl1";"LKO_CTRL"
"LKO_Ctrl4";"LKO_CTRL"
"LKO_CARBO2";"LKO_CARBO"
"LWT_Ctrl3";"LWT_CTRL"
"LWT_CARBO4";"LWT_CARBO"
"LKO_CARBO3";"LKO_CARBO"
"LKO_Ctrl5";"LKO_CTRL"
"LWT_CARBO6";"LWT_CARBO"
"LWT_Ctrl4";"LWT_CTRL"
"LWT_Ctrl1";"LWT_CTRL"
"LWT_CARBO3";"LWT_CARBO"
"LKO_Ctrl2";"LKO_CTRL"
"LKO_CARBO6";"LKO_CARBO"
# Author: Kevin Blighe
# Title: Publication-ready volcano plots with enhanced colouring and labelign
# Github: https://github.com/kevinblighe/EnhancedVolcano
# Modified by Franck Soubès (add topgenes)
EnhancedVolcano <- function(
toptable,
lab,
x,
y,
selectLab = NULL,
displaylab = NULL,
topgenes = NULL,
xlim = c(min(toptable[,x], na.rm=TRUE),
max(toptable[,x], na.rm=TRUE)),
ylim = c(0, max(-log10(toptable[,y]), na.rm=TRUE) + 5),
xlab = bquote(~Log[2]~ "fold change"),
ylab = bquote(~-Log[10]~italic(P)),
axisLabSize = 16,
pCutoff = 0.05,
pLabellingCutoff = pCutoff,
FCcutoff = 2.0,
title = "",
titleLabSize = 16,
transcriptPointSize = 0.8,
transcriptLabSize = 2.0,
col = c("grey30", "forestgreen", "royalblue", "red2"),
colAlpha = 1/2,
legend = c("NS","Log2 FC","P","P & Log2 FC"),
legendPosition = "top",
legendLabSize = 10,
legendIconSize = 3.0,
DrawConnectors = FALSE,
widthConnectors = 0.5,
colConnectors = "black",
cutoffLineType = "longdash",
cutoffLineCol = "black",
cutoffLineWidth = 0.4)
{
if(!requireNamespace("ggplot2")) {
stop("Please install ggplot2 first.", call.=FALSE)
}
if(!requireNamespace("ggrepel")) {
stop("Please install ggrepel first.", call.=FALSE)
}
if(!is.numeric(toptable[,x])) {
stop(paste(x[i], " is not numeric!", sep=""))
}
if(!is.numeric(toptable[,y])) {
stop(paste(x[i], " is not numeric!", sep=""))
}
requireNamespace("ggplot2")
requireNamespace("ggrepel")
requireNamespace("dplyr")
i <- xvals <- yvals <- Sig <- NULL
toptable <- as.data.frame(toptable)
toptable$Sig <- "NS"
toptable$Sig[(abs(toptable[,x]) > FCcutoff)] <- "FC"
toptable$Sig[(toptable[,y]<pCutoff)] <- "P"
toptable$Sig[(toptable[,y]<pCutoff) &
(abs(toptable[,x])>FCcutoff)] <- "FC_P"
toptable$Sig <- factor(toptable$Sig,
levels=c("NS","FC","P","FC_P"))
# if(!is.na(topgenes) ){
# toptable$abs <- unlist(abs(toptable[x]))
# myval <- toptable %>% dplyr::select(GeneName,abs) %>% top_n(.,topgenes)
# selectLab <- as.character(myval$GeneName)
# }
# if(!is.na(displaylab) ){
#
# myval <- toptable %>% dplyr::select(GeneName) %>% filter(GeneName == displaylab)
# selectLab <- as.character(myval$GeneName)
#
# }
if(is.na(topgenes) && !is.na(displaylab) ){
selectLab <- as.character(displaylab)
}
else{
toptable$abs <- unlist(abs(toptable[x]))
myval <- toptable %>% dplyr::select(GeneName,abs) %>% top_n(.,topgenes)
selectLab <- as.character(myval$GeneName)
}
if(is.na(topgenes) && is.na(displaylab))
selectLab <- NULL
if (min(toptable[,y], na.rm=TRUE) == 0) {
warning("One or more P values is 0. Converting to minimum possible value...", call. = FALSE)
toptable[which(toptable[,y] == 0), y] <- .Machine$double.xmin
}
toptable$lab <- lab
toptable$xvals <- toptable[,x]
toptable$yvals <- toptable[,y]
if (!is.null(selectLab)) {
names.new <- rep("", length(toptable$lab))
indices <- which(toptable$lab %in% selectLab)
names.new[indices] <- as.character(toptable$GeneName[indices])
print(names.new[indices])
toptable$lab <- names.new
}
tot = subset(toptable,
toptable[,y]<pLabellingCutoff &
abs(toptable[,x])>FCcutoff)[,"lab"]
plot <- ggplot2::ggplot(toptable,
ggplot2::aes(x=xvals, y=-log10(yvals))) +
ggplot2::geom_point(ggplot2::aes(color=factor(Sig)),
alpha=colAlpha, size=transcriptPointSize) +
ggplot2::scale_color_manual(values=c(NS=col[1],
FC=col[2],
P=col[3],
FC_P=col[4]),
labels=c(NS=legend[1],
FC=paste(legend[2], sep=""),
P=paste(legend[3], sep=""),
FC_P=paste(legend[4], sep=""))) +
ggplot2::theme_bw(base_size=24) +
ggplot2::theme(
legend.background=ggplot2::element_rect(),
plot.title=ggplot2::element_text(angle=0,
size=titleLabSize,
face="bold",
vjust=1),
panel.grid.major=ggplot2::element_blank(),
panel.grid.minor=ggplot2::element_blank(),
axis.text.x=ggplot2::element_text(angle=0,
size=axisLabSize,
vjust=1),
axis.text.y=ggplot2::element_text(angle=0,
size=axisLabSize,
vjust=1),
axis.title=ggplot2::element_text(size=axisLabSize),
legend.position=legendPosition,
legend.key=ggplot2::element_blank(),
legend.key.size=ggplot2::unit(0.5, "cm"),
legend.text=ggplot2::element_text(
size=legendLabSize),
title=ggplot2::element_text(
size=legendLabSize),
legend.title=ggplot2::element_blank()) +
ggplot2::guides(colour = ggplot2::guide_legend(
override.aes=list(size=legendIconSize))) +
ggplot2::xlab(xlab) +
ggplot2::ylab(ylab) +
ggplot2::xlim(xlim[1], xlim[2]) +
ggplot2::ylim(ylim[1], ylim[2]) +
ggplot2::ggtitle(title) +
ggplot2::geom_vline(xintercept=c(-FCcutoff, FCcutoff),
linetype=cutoffLineType,
colour=cutoffLineCol,
size=cutoffLineWidth) +
ggplot2::geom_hline(yintercept=-log10(pCutoff),
linetype=cutoffLineType,
colour=cutoffLineCol,
size=cutoffLineWidth)
if (DrawConnectors == TRUE) {
plot <- plot + ggrepel::geom_text_repel(max.iter = 100,
data=subset(toptable,
toptable[,y]<pLabellingCutoff &
abs(toptable[,x])>FCcutoff),
ggplot2::aes(label=subset(toptable,
toptable[,y]<pLabellingCutoff &
abs(toptable[,x])>FCcutoff)[,"lab"]),
size = transcriptLabSize,
segment.color = colConnectors,
segment.size = widthConnectors,
vjust = 1.0)
} else if (DrawConnectors == FALSE && !is.null(selectLab)) {
plot <- plot + ggplot2::geom_text(data=subset(toptable,
toptable[,y]<pLabellingCutoff &
abs(toptable[,x])>FCcutoff),
ggplot2::aes(label=subset(toptable,
toptable[,y]<pLabellingCutoff &
abs(toptable[,x])>FCcutoff)[,"lab"]),
size = transcriptLabSize,
check_overlap = T,
vjust = 1.0)
} else if (DrawConnectors == FALSE && is.null(selectLab)) {
plot <- plot + ggplot2::geom_text(data=subset(toptable,
toptable[,y]<pLabellingCutoff &
abs(toptable[,x])>FCcutoff),
ggplot2::aes(label=subset(toptable,