Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • a78cb8f
  • /
  • module
  • /
  • savemodules.R
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge
swh:1:cnt:0780d7e5105efac0216056d5d4a6bb5f3c3f18c8
directory badge
swh:1:dir:c2fbeb3a282ae4e712de69c4c8697d75059f7bda

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
savemodules.R
### Author: Franck Soubès
### Bioinformatics Master Degree - University of Bordeaux, France
### Link: https://github.com/GeT-TRiX/MA_Trix_App/
### Where: GET-TRiX's facility
### Application: MATRiX is a shiny application for Mining and functional Analysis of TRanscriptomics data
### Licence: GPL-3.0


#' downloadFiles 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
#'

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


#' selFormat is a shiny widget which aims is to specify the output format
#'
#' @param id Shiny id
#'
#' @return Widget in the gui
#'
#' @export
#'

selFormat <- function(id) {
  ns <- NS(id)
  selectInput(ns("format"), label = NULL, choices = c("png", "eps", "pdf", "svg"))
}

#' downoutputfiles is a shiny module which aims is to export reactive plot
#'
#' @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 w Width of the exported file
#' @param h Height pf the expored file
#' @param cutheat A boolean value
#' @param volcform A boolean value
#' @param hm A boolean value
#' @param clustvenn A boolean value. Default NULL.
#' @param rown A reactive character to display (show) or hide labels in the outputted heatmap
#'
#' @export
#'

downoutputfiles <- function(input, output, session , projectname, suffix = "plot.png",  data , w = 12  , h = 12 ,
                            cutheat = F, volcform = F, hm =F ,  clustvenn = NULL, rown =NULL) {

observe({
  if(!is.null(clustvenn)){
    req(data())
    pdf(NULL)
    if(class(data()) == "graphNEL")
      shinyjs::disable("downloadgraphs")
    else
      shinyjs::enable("downloadgraphs")
    dev.off()
  }
})



output$downloadgraphs  <- downloadHandler(

filename <- function() {

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

content <- function(file) {


  if ( input$format == "pdf")

    pdf(file,
        width = w,
        height = h,
        pointsize = 12)


  else if ( input$format == "png")

      png(
          file,
          width = w,
          height = h,
          units = "in",
          pointsize = 12,
          res = 100)

  else if ( input$format == "svg")

    svg(file,
        width = w,
        height = h,
        pointsize = 12
  )

  else if (cutheat  && input$format == "eps")

    cairo_ps(filename=file, width=10, height=10,pointsize = 12)

  else if(volcform  &&  input$format == "eps")
    cairo_ps(filename=file, width=10, height=10,pointsize = 12, fallback_resolution = 600)

##    ggsave(file,device=cairo_ps, fallback_resolution = 600)

  else
      eps(file,
        width = w,
        height = h,
        pointsize = 12)

  if(hm == T){

    revRowInd <- match(c(1:length(data$hm$rowInd)), data$hm$rowInd)
    revColInd <- match(c(1:length(data$hm$colInd)), data$hm$colInd)
    par(mar=c(5,5,1,1.10))
    if(is.null(data$colgroup))cl = palette(palette)else  cl=palette(data$colgroup)
    heatmap.2(t(data$hm$carpet)[revRowInd, revColInd], Rowv=data$hm$rowDendrogram, Colv=data$hm$colDendrogram, col=data$hm$col, useRaster = T, keysize=1, na.rm=T,  na.color="black",labRow = switch(rown(), hide = NA , show = data$rownames),
              trace = c("none"), layout(lmat =rbind(4:3,2:1),lhei = c(0.05,1), lwid = c(0.1,1)),key=T,density.info="density", scale="row", RowSideColors = data$rows , ColSideColors = data$cols, cexRow =0.9)
    mtext(side=3,sort(levels(data$groups)),adj=1,padj=seq(0,by=1.4,length.out=length(levels(data$groups))),col=cl[(1:length(levels(data$groups)))],cex=1,line=-1)
  } else
    plot(data())


  dev.off()
})

}

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API