From bf7d3d746ab26e57f0d7a4f379d299f2390ab55b Mon Sep 17 00:00:00 2001 From: ssnn-airr <20683719+ssnn-airr@users.noreply.github.com> Date: Mon, 6 May 2024 12:53:09 +0200 Subject: [PATCH] added logo and made esthetic changes to web --- .Rbuildignore | 3 +- .../templates/project/project_files/index.Rmd | 4 +- .../templates/project/project_files/logo.png | Bin 1691 -> 0 bytes .../templates/project/project_files/logo.svg | 145 ++++++++++++++++ inst/shiny-app/server.R | 161 ++++++++---------- inst/shiny-app/ui.R | 117 +++++++------ inst/shiny-app/www/logo.png | Bin 1498 -> 0 bytes inst/shiny-app/www/logo.svg | 145 ++++++++++++++++ inst/shiny-app/www/repcred.css | 20 ++- logo/logo.R | 46 +++++ profiling/profile.R | 47 +++++ 11 files changed, 539 insertions(+), 149 deletions(-) delete mode 100644 inst/rstudio/templates/project/project_files/logo.png create mode 100644 inst/rstudio/templates/project/project_files/logo.svg delete mode 100644 inst/shiny-app/www/logo.png create mode 100644 inst/shiny-app/www/logo.svg create mode 100644 logo/logo.R create mode 100644 profiling/profile.R diff --git a/.Rbuildignore b/.Rbuildignore index 3fc8943..3370d5f 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -13,4 +13,5 @@ binder docker LICENSE ^.*\.code-workspace -^R/\.repcred-package.R \ No newline at end of file +^R/\.repcred-package.R +^logo \ No newline at end of file diff --git a/inst/rstudio/templates/project/project_files/index.Rmd b/inst/rstudio/templates/project/project_files/index.Rmd index e5b12a8..5e88ae0 100644 --- a/inst/rstudio/templates/project/project_files/index.Rmd +++ b/inst/rstudio/templates/project/project_files/index.Rmd @@ -17,7 +17,9 @@ output: toc: scroll_highlight: yes collapse: subsection - depth: 4 + depth: 4 + before: | + download: yes sharing: no keep_md: true diff --git a/inst/rstudio/templates/project/project_files/logo.png b/inst/rstudio/templates/project/project_files/logo.png deleted file mode 100644 index 2749c1b96c8d7d0ddb90789c4c7e9a07f6757589..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001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^u6Fnu23XlUA3;!X}QjR+?gyw#a|}z;9XC z8N;=+E8$6mgQQf-asGeo`*&|G3Z9%7WWZLk@5Z;|8Ui<1rA%-Cv)lIe80Uj}wsl{o z?T=wkv-4cPb;}3A3)^{PVz!&4^6$9A$Tpwn<`mhJ{=p}nHhee!wT#E0fV*V<&b_AJ z3x6>zS+V*EZ$SY^&r{9nyN~b2zTNw`dfCnU{F6J1wrDe*xehFi*pj^6T^Rm@;DWu& zCj&(|3p^r=85sDEfH31!Z9ZwBAbW|YuPggw9%%s{VXcF~8-X#o(9^{+1XxmCas(D< z9ES}K?0=rvB;VN*XYI))C&_7GJ44Qge;NDb=9dS*BvheramyrB;nD*#0=sDt!?D=| zwYDGA1xOA`Ms*vKO!G^_!Q%=3WyjHj5y`1oJRuXsA;voILGg}$VEi$7y85}Sb4q9e E0E%G}9smFU diff --git a/inst/rstudio/templates/project/project_files/logo.svg b/inst/rstudio/templates/project/project_files/logo.svg new file mode 100644 index 0000000..47b3e3f --- /dev/null +++ b/inst/rstudio/templates/project/project_files/logo.svg @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/inst/shiny-app/server.R b/inst/shiny-app/server.R index b91adaa..4384055 100644 --- a/inst/shiny-app/server.R +++ b/inst/shiny-app/server.R @@ -1,90 +1,77 @@ server <- function(input, output) { - - original_help_text = "Repcred is an R program that allows you to see visually statistics and information about your repertoire." - output$help_info <- renderText({paste("

Repcred

\n",original_help_text)}) - - - dataValues <- reactiveValues( - repcred_report_path=NULL - ) - - - - observe({ - - val= input$input_chk - - if(val==TRUE){ - output$condInput <- renderUI({ fileInput("genome", "Choose germline reference FASTA File", - multiple = TRUE, - accept = c("text/tab-separated-values",".fasta",".fna",".ffn",".frn",".fa","text/plain")) - }) - } - - if(val==FALSE){ - output$condInput <- renderUI({}) - } - - - }) - - help_text="The repertoire file should contain the speficied rows as set out by the AIRR guidelines.Please be aware some stats will be unable to be run if there is missing data in some columns. This is mainly the sumrep stats , if there are specific stats you need makesure the related columns that are required are filled." - help_text2 = "Many of the statistics can be run without a genome file but the genome file does allow missing genes to be pin pointed and gene usage to be analysed." - - observeEvent(input$help, { - output$help_info <- renderText({paste("

Repertoire File

\n",help_text,"\n

Genome File

\n",help_text2)}) - - - }) - - observeEvent(input$go, { - output$openResultsBtn <- renderUI({ - - #req(input$file1) - withProgress( - tryCatch( - { - dataValues$repcred_report_path <- repcred_report(input$file1$datapath, - genome_file=input$genome$datapath, - #sumrep = input$sumrep, - downsample = input$input_downsample) - - }, - error = function(e) { - stop(e) + + dataValues <- reactiveValues( + repcred_report_path=NULL + ) + + observe({ + + val= input$input_chk + + if(val==TRUE){ + output$condInput <- renderUI({ fileInput("genome", + "Choose germline reference FASTA File", + multiple = TRUE, + accept = c("text/tab-separated-values",".fasta",".fna",".ffn",".frn",".fa","text/plain")) + }) + } + + if(val==FALSE){ + output$condInput <- renderUI({}) + } + + }) + + help_text2 = "Many of the statistics can be run without a genome file but the genome file does allow missing genes to be pin pointed and gene usage to be analysed." + + observeEvent(input$go, { + output$openResultsBtn <- renderUI({ + + #req(input$file1) + withProgress( + tryCatch( + { + dataValues$repcred_report_path <- repcred_report(input$file1$datapath, + genome_file=input$genome$datapath, + #sumrep = input$sumrep, + downsample = input$input_downsample) + + }, + error = function(e) { + stop(e) + } + ), + message="Analyzing repertoire..." + ) + + if (!is.null(dataValues$repcred_report_path)) { + + #repcred::replaceChapterClassType(dataValues$repcred_report_path) + shiny::addResourcePath(basename(dirname(dataValues$repcred_report_path)),dirname(dataValues$repcred_report_path)) + + output$downloadResults <- downloadHandler( + filename = function() { + "report.zip" + }, + content = function(fname) { + zip(zipfile=fname, files=dirname(dataValues$repcred_report_path)) + if(file.exists(paste0(fname, ".zip"))) {file.rename(paste0(fname, ".zip"), fname)} + }, + contentType = "application/zip" + ) + + div( + actionButton(inputId='openResultsBtn', + label= 'Open analysis results', + icon = icon("link"), + style="color: #fff; background-color: #f39c12; border-color: #f39c12", + onclick =paste0("window.open('",file.path(".",basename(dirname(dataValues$repcred_report_path)),basename(dataValues$repcred_report_path)),"', '_blank')") + ), + downloadButton("downloadResults") + ) } - ), - message="Analyzing repertoire..." - ) - - if (!is.null(dataValues$repcred_report_path)) { - - #repcred::replaceChapterClassType(dataValues$repcred_report_path) - shiny::addResourcePath(basename(dirname(dataValues$repcred_report_path)),dirname(dataValues$repcred_report_path)) - - output$downloadResults <- downloadHandler( - filename = function() { - "report.zip" - }, - content = function(fname) { - zip(zipfile=fname, files=dirname(dataValues$repcred_report_path)) - if(file.exists(paste0(fname, ".zip"))) {file.rename(paste0(fname, ".zip"), fname)} - }, - contentType = "application/zip" - ) - - div( - actionButton(inputId='openResultsBtn', - label= 'Open analysis results', - icon = icon("link"), - style="color: #fff; background-color: #f39c12; border-color: #f39c12", - onclick =paste0("window.open('",file.path(".",basename(dirname(dataValues$repcred_report_path)),basename(dataValues$repcred_report_path)),"', '_blank')") - ), - downloadButton("downloadResults") - ) - } - }) - }) - - + }) + }) + + } \ No newline at end of file diff --git a/inst/shiny-app/ui.R b/inst/shiny-app/ui.R index 7ce05a3..a47285d 100755 --- a/inst/shiny-app/ui.R +++ b/inst/shiny-app/ui.R @@ -1,56 +1,67 @@ # Define UI options(shiny.maxRequestSize = 0) -ui <- fluidPage( - - tags$head( - tags$link(rel = "stylesheet", type = "text/css", href = "repcred.css") - ), - - # Sidebar layout - sidebarLayout( - sidebarPanel(align="center", - # App title - fluidRow(titlePanel("Repcred"), - #Help Button - actionButton("help" , "Help")), - br(), - # Input - fileInput("file1", "Choose TSV File (REQUIRED)", - multiple = FALSE, - accept = c("text/tab-separated-values", - ".tsv",".csv",".tab", "text/plain")), - #Downsampled input - checkboxInput("input_downsample", "Downsampled repertoire?", value = TRUE ), - #Genome fasta file upload - checkboxInput("input_chk", "Upload germline reference set?", value = FALSE ), - uiOutput("condInput"), - - #selectInput("sumrep" , "Select Sumrep stats to run. Full stats takes longer to run but gives pairwise statistics , Basic statistics is faster but contains less statistics." , choices=c("Full sumrep stats" , "Basic sumrep stats")), - - - - - actionButton("go", "Run analysis"), - - # Output - uiOutput("openResultsBtn") - - ), - - - mainPanel = ({ - htmlOutput("help_info") - } - ) - - ) - - - - ) - - - - - +ui <- fluidPage( + + tags$head( + tags$link(rel = "stylesheet", type = "text/css", href = "repcred.css") + ), + + tags$script( + HTML( + "$(function () { + $('[data-toggle=tooltip]').tooltip(); + });" + ) + ), + + # App title + fluidRow( + id="div-main", + tags$img(src = "logo.svg", width = "100px"), + tags$h1("Rep-Cred"), + tags$strong("Credibility of a repertoire"), + tags$p("Summary statistics and graphical information to quickly asses the quality of a repertoire."), + tabsetPanel( + tabPanel("Rep-Cred", + br(), + # Input + fileInput("file1", + "Choose repertoire (.tsv) (REQUIRED)", + multiple = FALSE, + accept = c("text/tab-separated-values", + ".tsv",".csv",".tab", "text/plain")), + # helpText( "Note: The repertoire file should contain the ", + # "speficied rows as set out by the AIRR guidelines.", + # "Please be aware some stats will be unable to be ", + # "run if there is missing data in some columns. ", + # "This is mainly the sumrep stats , if there are ", + # "specific stats you need makesure the related ", + # "columns that are required are filled."), + + # Downsample + checkboxInput("input_downsample", "Downsample repertoire?", value = TRUE ), + # helpText( "Note: Whether to downsample the input repertoire", + # "to 5000 sequences."), + + # Genome fasta file upload + checkboxInput("input_chk", "Upload germline reference set?", value = FALSE ), + # helpText( "Note: Many of the statistics can be run without ", + # "a genome file but the genome file does allow ", + # "missing genes to be pin pointed and gene usage ", + # "to be analysed."), + + # Sumrep + uiOutput("condInput"), + #selectInput("sumrep" , "Select Sumrep stats to run. Full stats takes longer to run but gives pairwise statistics , Basic statistics is faster but contains less statistics." , choices=c("Full sumrep stats" , "Basic sumrep stats")), + actionButton("go", "Run analysis"), + + # Output + uiOutput("openResultsBtn") + + ), + tabPanel("Help"), + tabPanel("About") + ) + ) +) diff --git a/inst/shiny-app/www/logo.png b/inst/shiny-app/www/logo.png deleted file mode 100644 index 960857b5d722a56ee0b1c0c1dd611024e79e8cf0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1498 zcmeAS@N?(olHy`uVBq!ia0vp^?La(-g9%99nxfCjz`*pbDkP#LD6w3jpeR2rGbdG{ zq_QAYA+;hije()!*4ycUo9<}vxc-lHoz|eza-_&$#;P|7)8=y@oBM9M`Q#;&=C8~O zW{XNtysunPYVrT4)gkeiCzG6lKF1XG?FjO0)wYsbzk1EAq^PgE?tGKjd&@bqx*<_$ zOVQsgyPk*N_mRf5&F>q2;VvJ4$m@pO&#srmd9>h%6i`jMG>t4#kI;bwTJYv0Ti)ulsO6TmAAD!)IyAU3D*8_Bh1Ye3nY|DcXEYhhgEyoiBxc=tsB^*;D&v&4oYj*aT_{MFNc*CL#WHSNk14E zgP!&&SazoH9XnT?Ym>a?*`}grna6Ij2xvv}4V#I9d$MVRGQ(>S|f>3T1b#2!OI(TA^$utq>?1qy@}|Y7cRNYKI#| mp?09FFkEt!iJ;SLvKXySvzW55ZwLf>ox#)9&t;ucLK6Td@0{5H diff --git a/inst/shiny-app/www/logo.svg b/inst/shiny-app/www/logo.svg new file mode 100644 index 0000000..47b3e3f --- /dev/null +++ b/inst/shiny-app/www/logo.svg @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/inst/shiny-app/www/repcred.css b/inst/shiny-app/www/repcred.css index 6cd6485..eb310f2 100644 --- a/inst/shiny-app/www/repcred.css +++ b/inst/shiny-app/www/repcred.css @@ -1,14 +1,20 @@ #div-main { - position:fixed; - top: calc(35%); - left: calc(35%); + margin: 0; + // position: fixed; + position: absolute; + top: calc(50%); + left: calc(50%); + -ms-transform: translate(-50%, -50%); + transform: translate(-50%, -50%); } .shiny-notification { - position:fixed; - top: calc(55%); - left: calc(35%); - width: 300px; + position: absolute; + top: calc(50%); + left: calc(50%); + -ms-transform: translate(-50%, -50%); + transform: translate(-50%, -50%); + //width: 300px; } .book .book-summary { diff --git a/logo/logo.R b/logo/logo.R new file mode 100644 index 0000000..15eb38f --- /dev/null +++ b/logo/logo.R @@ -0,0 +1,46 @@ +# install.packages("hexSticker") +library(hexSticker) +library(ggplot2) +library(emojifont) +emojifont::load.fontawesome() +sysfonts::font_add_google("Noto Sans Mono") + + +subplot <- ggplot(data.frame(x=0, y=0), + aes(x,y)) + + geom_text(label=fontawesome('fa-thumbs-up'), + family='fontawesome-webfont', + color="white", + size=20) + + theme_void() + +sticker(subplot, + package="Rep-Cred", + p_size=8, + p_color = "#FFFFFF", + p_family = "Noto Sans Mono", + p_fontface = "bold", + s_x=1, s_y=0.8, s_width=1, s_height=1, + h_fill = "#1881C2", + h_color = "#000000", + spotlight = F, + white_around_sticker = F, + filename=file.path(here::here(), + "inst","shiny-app","www", + "logo.svg")) + + +sticker(subplot, + package="Rep-Cred", + p_size=8, + p_color = "#FFFFFF", + p_family = "Noto Sans Mono", + p_fontface = "bold", + s_x=1, s_y=0.8, s_width=1, s_height=1, + h_fill = "#1881C2", + h_color = "#000000", + spotlight = F, + white_around_sticker = F, + filename=file.path(here::here(), + "inst","rstudio","templates","project","project_files", + "logo.svg")) diff --git a/profiling/profile.R b/profiling/profile.R new file mode 100644 index 0000000..ea98dc2 --- /dev/null +++ b/profiling/profile.R @@ -0,0 +1,47 @@ +# Imports +library(repcred) +library(profvis) + +repertoire <- normalizePath(file.path("test_repertoires","p1974_d60.tsv")) + +outdir <- file.path("profiling","out","test1_down-T") +prof1d <- profvis({ + dir.create(outdir, recursive = T) + outdir <- normalizePath(outdir) + opt <- list( + REP=repertoire, + OUTDIR=outdir, + GENOME=NULL, + DOWN=TRUE, + FORMAT="html" + ) + report <- render_report(rep=opt$REP, + outdir=opt$OUTDIR, + genome = opt$GERM, + downsample = opt$DOWN, + format=opt$FORMAT) + +}) +htmlwidgets::saveWidget(prof1d, file.path(outdir,"prof1d.html")) + + +outdir <- file.path("profiling","out","test1_down-F") +prof1 <- profvis({ + dir.create(outdir, recursive = T) + outdir <- normalizePath(outdir) + opt <- list( + REP=repertoire, + OUTDIR=outdir, + GENOME=NULL, + DOWN=FALSE, + FORMAT="html" + ) + report <- render_report(rep=opt$REP, + outdir=opt$OUTDIR, + genome = opt$GERM, + downsample = opt$DOWN, + format=opt$FORMAT) + +}) +save(prof1, file=file.path(outdir, prof1)) +htmlwidgets::saveWidget(prof1, "prof1.html") \ No newline at end of file