Skip to content

Commit

Permalink
add getdegenes to MATRiX
Browse files Browse the repository at this point in the history
  • Loading branch information
fsoubes committed Mar 8, 2019
1 parent 1cc5448 commit 85dc44c
Show file tree
Hide file tree
Showing 23 changed files with 444 additions and 317 deletions.
9 changes: 4 additions & 5 deletions function/decideTestTrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@
#'
#' @export

decTestTRiX <- function(adj,logfc,pval, DEGcutoff = 0.05 ,FC = 1,cutoff_meth = "FDR",maxDE = NULL,contrast = 1:ncol(adj))

{
decTestTRiX <- function(adj,logfc,pval, DEGcutoff = 0.05 ,FC = 1,cutoff_meth = "FDR",maxDE = NULL,contrast = 1:ncol(adj)){
## select probes with cutoff_meth<= DEGcutoff and FoldChange > FC and nbr of selected probes < maxDE (if nb FC selected >maxDE)


if (length(contrast) == 1)
contrast = c(contrast, contrast)



if (is.na(maxDE) || is.null(maxDE))
maxDE = nrow(adj)

Expand All @@ -41,18 +40,19 @@ decTestTRiX <- function(adj,logfc,pval, DEGcutoff = 0.05 ,FC = 1,cutoff_meth = "
pList = adj[, contrast]



if(cutoff_meth=="None")
pList= pval[,contrast]


## select on pvalue
DEp = pList <= DEGcutoff



## select on FC
DEFC = 2 ** abs(logfc[, contrast]) >= FC


## reduce selection to maxDE
if (any(colSums(DEFC) > maxDE)) {

Expand Down Expand Up @@ -84,7 +84,6 @@ decTestTRiX <- function(adj,logfc,pval, DEGcutoff = 0.05 ,FC = 1,cutoff_meth = "
DEsel = which(rowSums(DEsel, na.rm = T) > 0)
elements= list(DEsel, length(DEsel))


return(elements)

}
2 changes: 0 additions & 2 deletions function/vennplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ Vennfinal <- function(myl,adj, cex=1, cutoffpval, cutofffc, statimet, meandup =
#'

myventocsv <- function(myven, adj){

max.length <- max(sapply(myven, length))
myven %>% lapply(function(v){ c(v, rep("", max.length-length(v)))}) %>% setNames(names(adj)) %>% as.data.frame()
}
Expand All @@ -221,7 +220,6 @@ myventocsv <- function(myven, adj){


mysetventocsv <- function(myven){

max.length <- max(sapply(myven, length))
myven %>%lapply(function(v){ c(v, rep("", max.length-length(v)))}) %>% as.data.frame()
}
Expand Down
4 changes: 2 additions & 2 deletions global.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ source("./module/Selgroup.R")
source("./module/enrichmodule.R")
source("./module/groupcol.R")
source("./module/magnificentables.R")
source("./module/tablexport.R")

source("./module/Savemoduletable.R")
source("./module/getdegenes.R")


################################
Expand Down
21 changes: 21 additions & 0 deletions man/cutoffElements.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions man/downloadFilestab.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions man/downoutputables.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions man/getDegenes.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions man/tracketCutoff.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

85 changes: 85 additions & 0 deletions module/Savemoduletable.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#' downloadFilestab is a shiny widget which aims is to download a reactive plot
#'
#' @param id Shiny id
#' @param label Shiny label
#'
#' @return Widget in the gui
#'
#' @export
#'

downloadFilestab <- function(id, label = "Save your Scree plot") {
ns <- NS(id)
downloadButton(ns("downloadtable"), label , style ="color: #fff; background-color: #337ab7; border-color: #2e6da4")
}



#' downoutputables is a shiny module which aims is to export reactive table
#'
#' @param input Internal
#' @param output Internal
#' @param session Internal
#' @param projectname A reactive character (MA project or session data)
#' @param suffix A character
#' @param data A reactive expression to be plot
#' @param cont A reactive character vector of the selected comparison(s)
#' @param case A numeric value
#' @param xlsx A boolean value
#'
#' @export
#'

downoutputables <- function(input, output, session , projectname, suffix = "plot.csv", data = NULL , cont = NULL, xlsx = F , case ) {



output$downloadtable <- downloadHandler(

filename <- function() {

paste0(basename(file_path_sans_ext(projectname())), suffix , sep ='')},


content <- function(file) {

if(!xlsx)
write.table(try(switch(case,
myventocsv(data() ,cont()),
mysetventocsv(setvglobalvenn(data(), cont(), dll =T )),
data())),
file,
na = "",
row.names = F,
col.names = T,
append = TRUE,
sep = ";"
)
else
withProgress(message = 'Creation of the xlsx table:',
value = 0, {
n <- NROW(50)
for (i in 1:n) {
incProgress(1 / n, detail = "Please wait...")
}


library(xlsx)

for (i in 1:length(data())) {
if (i == 1)
write.xlsx(file = file,data()[[i]],
sheetName = paste("Cluster", i))
else
write.xlsx(
file = file,
data()[[i]],
sheetName = paste("Cluster", i),
append = TRUE
)
}
})

})

}
20 changes: 14 additions & 6 deletions module/Selgroup.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,42 +38,50 @@ checkboxElements <- function(id){
#'

boxChooser <- function(input, output, session, label, data, group, case, empty =F) {

isinline <- reactiveValues(inline = F)

observe({
req(group()[[2]]$Grp)
isinline$format <- ifelse(length(levels(group()[[2]]$Grp)) >= 6, T, F)
})

output$usercheck <- renderUI({

ns <- session$ns
groupinline <- ifelse(length(levels(group()[[2]]$Grp)) >= 6, T, F)
case = ifelse(empty, 2, 1)
checkboxGroupInput(
ns("box"),
label,
choices =data(),
selected = switch(case,data(), NULL),
inline = ifelse(length(levels(group()[[2]]$Grp)) > 6, T, F)
inline = isinline$format
)

})

#Select all the contrasts
observeEvent(input$allcomphm, {
groupinline = ifelse(length(levels(group()[[2]]$Grp)) > 6, T, F)
#groupinline = ifelse(length(levels(group()[[2]]$Grp)) >= 6, T, F)
updateCheckboxGroupInput(
session,
"box",
label ,
choices = data(),
selected = data(),
inline = groupinline
inline = isinline$format
)
})

#Unselect all the contrasts
observeEvent(input$nocomphm, {
groupinline = ifelse(length(levels(group()[[2]]$Grp)) > 6, T, F)
#groupinline = ifelse(length(levels(group()[[2]]$Grp)) >= 6, T, F)
updateCheckboxGroupInput(session,
"box",
label ,
choices = data(),
inline= groupinline
inline= isinline$format
)
})

Expand Down
Loading

0 comments on commit 85dc44c

Please sign in to comment.