Skip to content

Commit

Permalink
add start to go
Browse files Browse the repository at this point in the history
  • Loading branch information
fsoubes committed May 18, 2018
1 parent 35006a9 commit fbfdd90
Show file tree
Hide file tree
Showing 8 changed files with 6,048 additions and 120 deletions.
2 changes: 1 addition & 1 deletion function/formating.R
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ heatmtoclust = function( hmp01_All, exprData, pval, myval= 5){
mygen = as.integer(row.names(final))

heatmclust = pval %>%
select (X,GeneName) %>%
dplyr::select (X,GeneName) %>%
filter( X %in% mygen) %>%
left_join(data.frame(X=mygen), . , by="X") %>%
arrange(-row_number())
Expand Down
Empty file modified myip.sh
100644 → 100755
Empty file.
11 changes: 11 additions & 0 deletions server.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
###############################
######## Loading functions #
###############################

source("function/heatmtruncated.R")
source("function/formating.R")
source("function/PCA.R")
Expand All @@ -6,9 +10,16 @@ source("function/decideTestTrix.R")
source("function/vennplot.R")
source("function/create_forked_task.R")
source("function/cutheat.R")

###############################
######## creating graph log #
###############################


# options(shiny.reactlog=TRUE)
# showReactLog(time = TRUE)


shinyServer(server <- function(input, output, session) {

###############################
Expand Down
70 changes: 65 additions & 5 deletions server/heatmapshiny.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@




#' rowname is a reactive function which aim is to hide or show the rownames
#'
#' @param input$rowname a boolean radio button input
Expand Down Expand Up @@ -38,18 +37,75 @@ colname <- reactive({

heatmapobj <- NULL # declare outside the observeEvent
formatidus <- NULL
hmbis <- reactiveValues()
hmobj <- reactiveValues()


observe({

heatid <- input$matrixapp
if (grepl("Heatmap", heatid)) {
formatidus <<- length(formated())
formatidus <<- length(formated()) # doit trouver une autre valeur que formated pour donner la taille
if (formatidus < 2000)
source(file.path("server", "plotreact.R"), local = TRUE)$value #
else
source(file.path("server", "plotreact2.R"), local = TRUE)$value #
else
source(file.path("server", "plotreact2.R"), local = TRUE)$value #
}



# observe({
# obj <- hmobj$hm
# print(obj)
#
# })


output$save <- downloadHandler(filename <- function() {
paste0(basename(file_path_sans_ext("myfile")),
'_heatmap.',
input$form,
sep = '')
},
content <- function(file) {
if (input$form == "emf")

emf(
file,
width = 7,
height = 7,
pointsize = 12,
coordDPI = 300
)

else if (input$form == "png")
png(
file,
width = 900,
height = 1200,
units = "px",
pointsize = 12,
res = 100
)
else
eps(file,
width = 7,
height = 7)

if (!is.null(formated()))
withProgress(message = 'Saving heatmap:',
value = 0, {
n <- NROW(formated())
for (i in 1:n) {
incProgress(1 / n, detail = "Please wait...")
}
heatmapfinal(isplot = F)
})
dev.off()

})


output$downloadcut <- downloadHandler(
filename = function() {
paste(basename(file_path_sans_ext(input$filename)),
Expand All @@ -62,9 +118,13 @@ observe({
}
)

output$clustering <- renderDataTable(heatmapfinal(isplot = T)) # Summary of the significant genes depending on the pvalue with FC set to (1.2,2,4,6,10)
output$clustering <-
renderDataTable(heatmapfinal(isplot = T)) # Summary of the significant genes depending on the pvalue with FC set to (1.2,2,4,6,10)
})


obsC <- observe(quote({ print(formatidus) }), quoted = TRUE)

# cutedhm <- reactive({
# req(hm())
# cut02 = cut(hm()$rowDendrogram, h = input$cutheatm)
Expand Down
82 changes: 20 additions & 62 deletions server/plotreact.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@
#'


shinyjs::disable("heatm")

heatmapfinal <- function(isplot = T) {

plotHeatmaps(
hmbis()[[1]],
formated(),
formated(),
droplevels(new_group()$Grp),
workingPath = wd_path,
my_palette = colorRampPalette(c(
Expand All @@ -52,6 +55,7 @@ heatmapfinal <- function(isplot = T) {
gpcolr = hmbis()[[6]],
distfunTRIX = hmbis()[[2]]
)

}

#' hmbis is an event reactive function that pre-computed hierarchical clustering on microarray data
Expand All @@ -72,12 +76,11 @@ heatmapfinal <- function(isplot = T) {


hmbis <- reactive( {
#hmbis <- eventReactive(input$heatm, {

isolate( # isolate in order to avoid that reactive values update the heatmap

#isolate( # isolate in order to avoid that reactive values update the heatmap
truncatedhat(
data.matrix(new_data()),
formated(),
isolate(formated()),
droplevels(new_group()$Grp),
workingPath = wd_path,
k = input$clusters,
Expand All @@ -86,81 +89,36 @@ hmbis <- reactive( {
Coldistfun = input$dist,
meanGrp = input$meangrp
)
)

#)
})

#heatmapobj <<- hmbis() # a static variable

hm <- reactive({
heatmapfinal(isplot = F)
})


output$distPlot <- renderPlot({
isolate({
#isolate({
if (!is.null(formated()))
withProgress(message = 'Plotting heatmap:', # Add sliderbar when loading heatmap
value = 0,
{
n <- NROW(formated()) #number of row in the formated dataframe

if (n >2000)
return(isolate(heatmapfinal(isplot = F)))
for (i in 1:n) {
incProgress(1 / n, detail = "Please wait...")
}
hmbis()
isolate(hmbis())
heatmapfinal(isplot = F)
})
})
#hmobj$hm <- (hm())

})
}, width = 900 , height = 1200, res = 100)


output$save <- downloadHandler(filename <- function() {
paste0(basename(file_path_sans_ext("myfile")),
'_heatmap.',
input$form,
sep = '')
},
content <- function(file) {
if (input$form == "emf")

emf(
file,
width = 7,
height = 7,
pointsize = 12,
coordDPI = 300
)

else if (input$form == "png")
png(
file,
width = 900,
height = 1200,
units = "px",
pointsize = 12,
res = 100
)
else
eps(file,
width = 7,
height = 7)

if (!is.null(formated()))
withProgress(message = 'Saving heatmap:',
value = 0,
{
n <- NROW(formated())

for (i in 1:n) {
incProgress(1 / n, detail = "Please wait...")
}

heatmapfinal(isplot = F)

})

dev.off()


})




59 changes: 7 additions & 52 deletions server/plotreact2.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@
#'
#' @export
#'



shinyjs::enable("heatm")



heatmapfinal <- function(isplot = T) {
plotHeatmaps(
heatmapobj[[1]],
Expand All @@ -55,6 +58,7 @@
}



#' hmbis is an event reactive function that pre-computed hierarchical clustering on microarray data
#'
#' @param new_data a data frame with all the individuals selected
Expand Down Expand Up @@ -109,53 +113,4 @@
}, width = 900 , height = 1200, res = 100)


output$save <- downloadHandler(filename <- function() {
paste0(basename(file_path_sans_ext("myfile")),
'_heatmap.',
input$form,
sep = '')
},
content <- function(file) {
if (input$form == "emf")

emf(
file,
width = 7,
height = 7,
pointsize = 12,
coordDPI = 300
)

else if (input$form == "png")
png(
file,
width = 900,
height = 1200,
units = "px",
pointsize = 12,
res = 100
)
else
eps(file,
width = 7,
height = 7)

if (!is.null(formated()))
withProgress(message = 'Saving heatmap:',
value = 0,
{
n <- NROW(formated())

for (i in 1:n) {
incProgress(1 / n, detail = "Please wait...")
}

heatmapfinal(isplot = F)

})

dev.off()


})


Loading

0 comments on commit fbfdd90

Please sign in to comment.