R/mappingBulkUserInterface.R

Defines functions mappingBulkUserInterface

Documented in mappingBulkUserInterface

#' Mapping bulk ui
#'
#' @param id Shiny module identifier
mappingBulkUserInterface <- function(id) {
    nsMapBulk <- shiny::NS(id)
    bslib::layout_sidebar(
      htmltools::tags$head(
        htmltools::tags$style(htmltools::HTML("
        .tooltip-inner {
          max-width: 400px;  /* Adjust the width */
          white-space: normal;  /* Allow text to wrap */
          text-align: left;  /* Optional: aligns text to the left */
          border-radius: 4px !important;  /* Less curvature */
          background-color: #202020;      /* Optional: lighter background */
          color: #FFFFFF;                 /* Optional: darker text for readability */
          border: 1px solid #ccc;         /* Optional: subtle border */
        }
      "))
      ),
      htmltools::tags$style(".selectize-dropdown {position: static}"),
      shinyjs::useShinyjs(), # Enables JavaScript for more interactive features
      bslib::input_dark_mode(id = "dark_mode"), # Toggle for dark mode

        sidebar = bslib::sidebar(
            width = "23%",
            bslib::accordion(
                    bslib::accordion_panel(
                        ## BASIC OPERATIONS
                        "BASIC OPTIONS", icon = bsicons::bs_icon("sliders"),
                        shiny::fluidRow(shiny::column(12,align="center",
                                        htmltools::tags$hr(htmltools::h5("Step 1 - Set input/output")),
                                        htmltools::br())), #close fluidrow
                        # genome index folder
                        shiny::fluidRow(shiny::column(width = 12,shiny::splitLayout(cellWidths = c("90%", "10%"),
                                                               shinyFiles::shinyDirButton(nsMapBulk("BulkIndex"),
                                                                              "Select the folder containing the reference genome index",
                                                                              title = "Select the folder containing the reference genome index.",
                                                                              icon = shiny::icon("download")),
                                                               bslib::tooltip(
                                                                   bsicons::bs_icon("question-circle"),
                                                                   "This folder contains the indexed genome, generated by the previous genome indexing module in bulk mode.",
                                                                   placement = "right"
                                                               )
                        ),
                        # Displays the selected input directory path
                        shiny::verbatimTextOutput(nsMapBulk("MappingPathIndexBulk")), ## index folder selected
                        )), #close fluidrow
                        shiny::fluidRow(shiny::column(width = 12,shiny::splitLayout(cellWidths = c("90%", "10%"),
                                                               shinyFiles::shinyDirButton(nsMapBulk("BulkReads"),
                                                                              "Choose the folder that stores the read files",
                                                                              title = "Please select the folder where the sample files (FASTQ format) are stored.",
                                                                              icon = shiny::icon("download")),
                                                               bslib::tooltip(
                                                                   bsicons::bs_icon("question-circle"),
                                                                   "This is the input folder containing the raw read files in FASTQ format, which can be either compressed or uncompressed. Supported file extensions include:
                                                                                                             filename1_1.fastq
                                                                                                             filename1_2.fastq
                                                                                                             filename1_1.fastq.gz
                                                                                                             filename1_2.fastq.gz
                                                                                                             filename1_1.fq
                                                                                                             filename1_2.fq
                                                                                                             filename1_1.fq.gz
                                                                                                             filename1_2.fq.gz.",
                                                                   placement = "right"
                                                               )
                        ),
                        # Displays the selected input directory path
                        shiny::verbatimTextOutput(nsMapBulk("MappingPathProcessedReadsBulk")), ## reads folder selected
                        )), #close fluidrow
                        shiny::fluidRow(shiny::column(width = 12,shiny::splitLayout(cellWidths = c("90%", "10%"),
                                                               shinyFiles::shinyDirButton(nsMapBulk("BulkBam"),
                                                                              "Select alignment output folder",
                                                                              title = "Select the output folder where the alignments onto the genome will be stored.",
                                                                              icon = shiny::icon("download")),
                                                               bslib::tooltip(
                                                                   bsicons::bs_icon("question-circle"),
                                                                   "This folder will store the read alignment files",
                                                                   placement = "right"
                                                               )
                        ),
                        # Displays the selected input directory path
                        shiny::verbatimTextOutput(nsMapBulk("MappingPathOutputBulk")), ## result folder selected
                        )) #close fluidrow
                    ), #close accordion panel
                    ## ADVANCED OPERATIONS
                    bslib::accordion_panel(
                        "ADVANCED OPTIONS", icon = bsicons::bs_icon("sliders"),
                        shiny::fluidRow(shiny::column(12,align="center",
                                        htmltools::tags$hr(htmltools::h5("Miscellaneous")),
                                        htmltools::br())),
                        ## parallelization
                        shiny::fluidRow(shiny::column(width = 12,shiny::splitLayout(cellWidths = c("90%", "10%"),
                                                                        shiny::sliderInput(inputId = nsMapBulk("MappingProcessBulk"),
                                                                           label = "Parallelization",
                                                                           min = 1,
                                                                           max = parallel::detectCores(logical = TRUE),
                                                                           value = 2,
                                                                           step = 1),
                                                               bslib::tooltip(
                                                                   bsicons::bs_icon("question-circle"),
                                                                   "Parallel computation.
                                           Choose the number of CPU cores to analize samples in parallel.
                                           '2' by default",
                                                                   placement = "right"
                                                               )
                        ))), #close fluidrow
                        shiny::fluidRow(shiny::column(width = 12,shiny::splitLayout(cellWidths = c("90%", "10%"),
                                                                        shiny::sliderInput(inputId = nsMapBulk("MappingThreadsBulk"),
                                                                           label = "Number of subprocesses",
                                                                           value = 2,
                                                                           min = 1,
                                                                           max = as.integer(parallel::detectCores(logical = TRUE)),
                                                                           step = 1),
                                                               bslib::tooltip(
                                                                   bsicons::bs_icon("question-circle"),
                                                                   "Set the number of subprocesses to divide the analysis into.
                                                                           '2' by default.",
                                                                   placement = "right"
                                                               )
                        ))), #close fluidrow
                        shiny::fluidRow(shiny::column(width = 12,shiny::splitLayout(cellWidths = c("90%", "10%"),
                                                                        shiny::radioButtons(inputId = nsMapBulk("MappingFormatBulk"),
                                                                            label = "Output format",
                                                                            choices = c("BAM", "SAM"), selected = "BAM"),
                                                               bslib::tooltip(
                                                                   bsicons::bs_icon("question-circle"),
                                                                   "Choose whether to generate a compressed binary alignment file (BAM) or an uncompressed output (SAM).
                                                                           'BAM' by default.",
                                                                   placement = "right"
                                                               )
                        ))), #close fluidrow
                        shiny::fluidRow(shiny::column(width = 12,shiny::splitLayout(cellWidths = c("90%", "10%"),
                                                               shiny::radioButtons(inputId = nsMapBulk("MappingBulkPhredScore"),
                                                                            label = "Phred score",
                                                                            choices = c(33, 64), selected = 33),
                                                               bslib::tooltip(
                                                                   bsicons::bs_icon("question-circle"),
                                                                   "Specify the base-calling Phred score format (33 or 64) used to define the quality of your FASTQ input data.
                                                                           '33' by default",
                                                                   placement = "right"
                                                               )
                        ))), #close fluidrow
                        shiny::fluidRow(shiny::column(width = 12,shiny::splitLayout(cellWidths = c("90%", "10%"),
                                                                        shiny::numericInput(inputId = nsMapBulk("MappingNumberSubreadsBulk"),
                                                                            label = "Number of subreads", value = 14, step = 1),
                                                               bslib::tooltip(
                                                                   bsicons::bs_icon("question-circle"),
                                                                   "Specify the number of subreads (short reads for optimal map location) to extract for each input read.
                                                                           A higher number of subreads may increase both processing time and mapping accuracy.
                                                                           '14' by default.",
                                                                   placement = "right"
                                                               )
                        ))), #close fluidrow
                        shiny::fluidRow(shiny::column(width = 12,shiny::splitLayout(cellWidths = c("90%", "10%"),
                                                                        shiny::numericInput(inputId = nsMapBulk("MappingConsensusThresholdBulk"),
                                                                            label = "Consensus threshold", value = 1, step = 1),
                                                               bslib::tooltip(
                                                                   bsicons::bs_icon("question-circle"),
                                                                   "Specify the consensus threshold, which defines the minimum number of consensus subreads required to report a hit. Consensus subreads are those that agree on the same location in the reference genome for the read (seed-and-vote strategy).
                                                                           Increasing the required number of consensus subreads may reduce the number of mapped reads.
                                                                           '1' by default.",
                                                                   placement = "right"
                                                               )
                        ))), #close fluidrow
                        shiny::fluidRow(shiny::column(width = 12,shiny::splitLayout(cellWidths = c("90%", "10%"),
                                                               shiny::numericInput(inputId = nsMapBulk("MappingMaxMismatchBulk"),
                                                                            label = "Mismatch number", value = 3, step = 1),
                                                               bslib::tooltip(
                                                                   bsicons::bs_icon("question-circle"),
                                                                   "Specify the maximum number of mismatches allowed in the alignment. Mismatches in soft-clipped regions are not counted.
                                                                           '3' by default.",
                                                                   placement = "right"
                                                               )
                        ))), #close fluidrow
                        shiny::fluidRow(shiny::column(width = 12,shiny::splitLayout(cellWidths = c("90%", "10%"),
                                                               shiny::radioButtons(inputId = nsMapBulk("MappingUniqueOnlyBulk"),
                                                                            label = "Exclude reads that map to multiple locations",
                                                                            choices = c("TRUE", "FALSE"), selected = "FALSE"),
                                                               bslib::tooltip(
                                                                   bsicons::bs_icon("question-circle"),
                                                                   "Specify if only uniquely mapped reads should be included in the alignment file (setting TRUE).
                                                                           'FALSE' by default.",
                                                                   placement = "right"
                                                               )
                        ))), #close fluidrow
                        shiny::fluidRow(shiny::column(width = 12,shiny::splitLayout(cellWidths = c("90%", "10%"),
                                                                        shiny::numericInput(inputId = nsMapBulk("MappingMultiMapMaxBulk"),
                                                                            label = "Max multi-mapped reads", value = 1, step = 1),
                                                               bslib::tooltip(
                                                                   bsicons::bs_icon("question-circle"),
                                                                   "When both uniquely mapped and multimapped reads are included, set the maximum number of equally best mapping locations per read.
                                                                           '1' by default.",
                                                                   placement = "right"
                                                               )
                        ))), #close fluidrow
                        shiny::fluidRow(shiny::column(width = 12,shiny::splitLayout(cellWidths = c("90%", "10%"),
                                                                        shiny::numericInput(inputId = nsMapBulk("MappingIndelLengthBulk"),
                                                                            label = "Indel length", value = 5, max = 200, step = 1),
                                                               bslib::tooltip(
                                                                   bsicons::bs_icon("question-circle"),
                                                                   "Specify the maximum number of insertions/deletions (indels) allowed in the alignment.
                                                                           '5' by default.",
                                                                   placement = "right"
                                                               )
                        ))), #close fluidrow
                        shiny::fluidRow(shiny::column(width = 12,shiny::splitLayout(cellWidths = c("90%", "10%"),
                                                                        shiny::numericInput(inputId = nsMapBulk("MappingMinFragLengthBulk"),
                                                                            label = "Min fragment length", value = 50, step = 1),
                                                               bslib::tooltip(
                                                                   bsicons::bs_icon("question-circle"),
                                                                   "Set the minimum fragment length as a numeric value.
                                                                           '50' by default.",
                                                                   placement = "right"
                                                               )
                        ))), #close fluidrow
                        shiny::fluidRow(shiny::column(width = 12,shiny::splitLayout(cellWidths = c("90%", "10%"),
                                                                        shiny::numericInput(inputId = nsMapBulk("MappingMaxFragLengthBulk"),
                                                                            label = "Max fragment length", value = 600, step = 1),
                                                               bslib::tooltip(
                                                                   bsicons::bs_icon("question-circle"),
                                                                   "Set the maximum fragment length as a numeric value.
                                                                           '600' by default.",
                                                                   placement = "right"
                                                               )
                        ))), #close fluidrow
                        shiny::fluidRow(shiny::column(width = 12,shiny::splitLayout(cellWidths = c("90%", "10%"),
                                                               shiny::radioButtons(inputId = nsMapBulk("MappingPeOrientationBulk"),
                                                                            label = "Paired-ends orientation",
                                                                            choices = c("fr", "rf", "ff"), selected = "fr"),
                                                               bslib::tooltip(
                                                                   bsicons::bs_icon("question-circle"),
                                                                   "Specify the orientation of the paired reads. 'f' denotes the forward strand and 'r' denotes the reverse strand. The default is 'fr', meaning the first read is on the forward strand and the second on the reverse strand.",
                                                                   placement = "right"
                                                               )
                        ))), #close fluidrow
                        shiny::fluidRow(shiny::column(width = 12,shiny::splitLayout(cellWidths = c("90%", "10%"),
                                                               shiny::radioButtons(inputId = nsMapBulk("MappingKeepOrderBulk"),
                                                                            label = "Keep the order of FASTQ files (applies only for BAM output)",
                                                                            choices = c("TRUE", "FALSE"), selected = "FALSE"),
                                                               bslib::tooltip(
                                                                   bsicons::bs_icon("question-circle"),
                                                                   "Choose whether to preserve the order of reads in the BAM output as they appear in the input file.
                                                                           Reads from the same pair will always be placed next to each other, regardless of this setting.
                                                                           'FALSE' by default.",
                                                                   placement = "right"
                                                               )
                        ))), #close fluidrow
                        shiny::fluidRow(shiny::column(width = 12,shiny::splitLayout(cellWidths = c("90%", "10%"),
                                                               shiny::radioButtons(inputId = nsMapBulk("MappingSortByCoordinatesBulk"),
                                                                            label = "Sort read by their mapping locations (applies only for BAM output)",
                                                                            choices = c("TRUE", "FALSE"), selected = "FALSE"),
                                                               bslib::tooltip(
                                                                   bsicons::bs_icon("question-circle"),
                                                                   "Decide whether reads should be sorted by their mapping locations in the output.
                                                                           This option is applicable for BAM output only.
                                                                           A BAI index file will also be generated for each BAM file, allowing direct loading into genome browsers like IGB or IGV.
                                                                           'FALSE' by default.",
                                                                   placement = "right"
                                                               )
                        ))), #close fluidrow
                        shiny::fluidRow(shiny::column(width = 12,shiny::splitLayout(cellWidths = c("90%", "10%"),
                                                               shiny::radioButtons(inputId = nsMapBulk("MappingAllJunctionsBulk"),
                                                                            label = "Reporting all splice junctions",
                                                                            choices = c("TRUE", "FALSE"), selected = "FALSE"),
                                                               bslib::tooltip(
                                                                   bsicons::bs_icon("question-circle"),
                                                                   "hoose if all discovered junctions, including exon-exon junctions and gene fusions, should be reported. Setting this option to TRUE does not require the presence of donor/acceptor sites.
                                                                           'FALSE' by default.",
                                                                   placement = "right"
                                                               )
                        ))), #close fluidrow
                        shiny::fluidRow(shiny::column(width = 12,shiny::splitLayout(cellWidths = c("90%", "10%"),
                                                               shinyFiles::shinyDirButton(nsMapBulk("MappingTemporaryFolderBulk"),
                                                                              "Choose an empty folder to store temporary files",
                                                                              title = "Folder for temporary files",
                                                                              icon = shiny::icon("download")),
                                                               bslib::tooltip(
                                                                   bsicons::bs_icon("question-circle"),
                                                                   "Select an empty folder to store temporary files. This folder and its contents will be deleted after the analysis is complete.",
                                                                   placement = "right"
                                                               )

                        ), #close cellwidths
                        # Displays the selected input directory path
                        shiny::verbatimTextOutput(nsMapBulk("MappingPathTempBulk")) ## temporary folder selected
                        )), #close fluidrow
                    ) #close accordion panel
            ), #close accordion
            shiny::fluidRow(shiny::column(12,align="center",
                            htmltools::tags$hr(htmltools::h5("Step 2 - Run mapping analysis for bulk RNA-seq")),
                            htmltools::br())),
            ## running button
            shiny::fluidRow(
              shiny::actionButton(inputId = nsMapBulk("RunBulk"), label = "Run",
                             icon = shiny::icon(name = "bookmark"),
                             class = "btn-primary"),
                ## killing button
                shinyjs::disabled(
                    shiny::actionButton(nsMapBulk("StopMappingBulk"), "Kill", icon = shiny::icon("fire"),
                                 class = "btn-warning"))
            ) #close fluidrow
        ), #close sidebar
        ## MAIN PANEL
        ## DROPDOWN BUTTON
        shinyWidgets::dropdownButton(
            inputId = nsMapBulk("MappingBulkMydropdown"),
            label = "Info",
            size = "sm",
            status = "info",
            circle = FALSE,
            htmltools::h3(shiny::strong("Mapping process")),
            htmltools::br(),
            htmltools::h5(shiny::strong("WHEN TO PERFORM")),
            htmltools::h5("The mapping step should be performed after genome indexing and before the summarization step to align the read dataset to the reference genome(s)."),
            htmltools::br(),
            htmltools::h6(shiny::strong("WHAT IT DOES")),
            htmltools::h6("During this step, RNA-seq reads are aligned to the indexed reference genome to identify transcripts. Mapping allows for the detection of novel genes or transcripts and requires a spliced or gapped mapper, as reads may span exon-exon junctions. The module also detects novel splice junctions, including those resulting from sequencing errors, differences with the reference, or the search for non-canonical junctions and fusion transcripts."),
            htmltools::br(),
            htmltools::h6(shiny::strong("OPERATIONAL INSTRUCTIONS")),
            htmltools::h6(shiny::strong("Step 1")),
            htmltools::h6("- Select the folder containing the indexed genome"),
            htmltools::h6("- Select the folder containing sample files: Ensure that the folder chosen contains the filtered read data in FASTQ format, as this is required for alignment processing"),
            htmltools::h6("- Choose an empty output folder that will be used for storing the alignment files in either BAM or SAM format, unmapped reads in FASTA format, and other text format document."),
            htmltools::h6(shiny::strong("Step 2")),
            htmltools::h6("- Start the analysis by clicking the 'Run' button."),
            htmltools::br(),
            htmltools::h6(shiny::strong("RESULTS")),
            htmltools::h6("Inside the selected folder, the following output files will be generated for each sample:"),
            htmltools::h6("- an alignment file (BAM/SAM format);"),
            htmltools::h6("- a text document reporting detected polymorphism between read and the reference genome (VCF format);"),
            htmltools::h6("- a text document reporting detected exon-exon junctions (BED format);"),
            htmltools::h6("- a text document summarizing the mapping analysis statistics;"),
            htmltools::h6("- unmapped reads (gzip compressed FASTQ format)."),
            htmltools::br(),
            htmltools::h6(shiny::strong("ADDITIONAL NOTES")),
            htmltools::h6("You can permanently kill the analysis by clicking the 'Kill' button."),
            htmltools::h6("Optionally, you can configure advanced parameters, including 'Miscellaneous' and 'Gene annotation', for further customization."),
            htmltools::br()
        ),
        htmltools::br(),
        # text output
        shiny::verbatimTextOutput(nsMapBulk("MappingBulkProcessstatus")),
        ## reassuring table
        DT::DTOutput(nsMapBulk("MappingBulkReassure"))
    ) #close layout sidebar
}

Try the inDAGO package in your browser

Any scripts or data that you put into this service are public.

inDAGO documentation built on Aug. 8, 2025, 7:47 p.m.