id_to_sequence_position: id_to_sequence_positon

View source: R/selected_position.R

id_to_sequence_positionR Documentation

id_to_sequence_positon

Description

id_to_sequence_positon converts selected columns in the gene.alignment.tables visualisation to positions in the original sequence dataset.

Usage

id_to_sequence_position(id, shiny.input)

Arguments

id

InputID of the format aDTXXXXX_n_m_columns_selected from the datatables generated for the gene.alignment.table visualisation

shiny.input

The input object of the Shiny app

Examples


## Not run: 

## create a set of reactiveValues to store the selected column ids
selected_col_values <- reactiveValues() 

## observe all input values matching the format aDTXXXXX_n_m_columns_selected
observe({
if (!is.null(input[[paste0(alignment.dt.unique.id,
                           "_1_",
                           table_width,
                           "_rows_current")]])) {
  selected_col_values[["previous"]] <-
    isolate(selected_col_values[["current"]])
  
  all_inputs <- isolate(reactiveValuesToList(input))
  
  inputs_selected_cols <-
    grepl(
      paste0(
        alignment.dt.unique.id,
        "_[0-9]{1,}_[0-9]{1,}_columns_selected"
      ),
      names(all_inputs)
    )
  
  inputs_with_nulls <- all_inputs[inputs_selected_cols]
  
 inputs_selected_cols <-
   setNames(inputs_with_nulls, names(all_inputs)[inputs_selected_cols])
 
  selected_positions <-
    lapply(names(inputs_selected_cols), function(id) {
      id_to_sequence_position(id, shiny.input = input)
    }) %>%
    unlist()
  
  selected_positions
} else {
  if (is.null(selected_col_values[["current"]])){
    selected_positions <- NULL
  }
  else {
    selected_positions <- selected_col_values[["current"]]
  }
}

selected_col_values[["current"]] <- selected_positions
})


## End(Not run)


martinjhnhadley/gene.alignment.tables documentation built on June 19, 2022, 11:56 a.m.