custom_shiny {spatialHeatmap} | R Documentation

## Create Customized Shiny App of Spaital Heatmap

### Description

This function creates customized Shiny App with user-provided data, aSVG files, and default parameters. Default settings are defined in the "config.yaml" file in the "config" folder of the app, and can be edited directly in a yaml file editor.

### Usage

    custom_shiny(
      ...,
      lis.par = NULL,
      lis.par.tmp = FALSE,
      lis.dld.single = NULL,
      lis.dld.mul = NULL,
      custom = TRUE,
      custom.computed = TRUE,
      example = FALSE,
      app.dir = "."
    )

### Arguments

`...` | Separate lists of paired data matrix and aSVG files, which are included as default datasets in the Shiny app. Each list must have three elements with name slots of "name", "data", and "svg" respectively. For example, list(name='dataset1', data='./data1.txt', svg='./root_shm.svg'). The "name" element (e.g. 'dataset1') is listed under "Step 1: data sets" in the app, while "data" and "svg" are the paths of data matrix and aSVG files. If multiple aSVGs (e.g. growth stages) are included in one list, the respective paths are stored in a vector in the "svg" slot (see example below). After calling this function, the data and aSVGs are copied to the "example" folder in the app. See detailed examples below.
`lis.par` | A list of default parameters of the Shiny app. See `lis.par.tmp` . Default is NULL, which means default parameters are adopted.
`lis.par.tmp` | Logical, TRUE or FALSE. Default is FALSE. If TRUE the template of default paramter list is returned, and users can set customized default values then assign this list to `lis.par` . Note, only the default values in the list can be changed while the hierarchy of the list should be preserved. Otherwise, it cannot be recognized by the internal program.
`lis.dld.single` | A list of paired data matrix and single aSVG file, which would be downloadable on the app for testing. The list should have two elements with name slots of "data" and "svg" respectively, which are the paths of the data matrix and aSVG file repectively. After the function call, the specified data and aSVG are copied to the "example" folder in the app. Note the two name slots should not be changed. E.g. `list(data='./data_download.txt', svg='./root_download_shm.svg')`.
`lis.dld.mul` | A list of paired data matrix and multiple aSVG files, which would be downloadable on the app for testing. The multiple aSVG files could be multiple growth stages of a plant. The list should have two elements with name slots of "data" and "svg" respectively, which are the paths of the data matrix and aSVG files repectively. After the function call, the specified data and aSVGs are copied to the "example" folder in the app. Note the two name slots should not be changed. E.g. list(data='./data_download.txt', svg=c('./root_young_download_shm.svg', './root_old_download_shm.svg')).
`custom` | Logical, TRUE or FALSE. If TRUE (default), the "customData" option under "Step 1: data sets" is included, which allows to upload datasets from local computer.
`custom.computed` | Logical, TRUE or FALSE. If TRUE (default), the "customComputdData" option under "Step 1: data sets" is included, which allows to upload computed datasets from local computer. See `adj_mod`.
`example` | Logical, TRUE or FALSE. If TRUE, the default examples in "spatialHeatmap" package are included in the app as well as those provided to `...` by users.
`app.dir` | The directory to create the Shiny app. Default is current work directory `'.'`.

### Value

If `lis.par.tmp==TRUE`, the template of default paramter list is returned. Otherwise, a customized Shiny app is generated in the path of `app.dir`.

### Author(s)

Jianhai Zhang jzhan067@ucr.edu; zhang.jianhai@hotmail.com
Dr. Thomas Girke thomas.girke@ucr.edu

### References

Jeremy Stephens, Kirill Simonov, Yihui Xie, Zhuoer Dong, Hadley Wickham, Jeffrey Horner, reikoch, Will Beasley, Brendan O'Connor and Gregory R. Warnes (2020). yaml: Methods to Convert R Data to YAML and Back. R package version 2.2.1. https://CRAN.R-project.org/package=yaml
Winston Chang, Joe Cheng, JJ Allaire, Yihui Xie and Jonathan McPherson (2017). shiny: Web Application Framework for R. R package version 1.0.3. https://CRAN.R-project.org/package=shiny

### Examples

    # The pre-packaged examples are used for illustration purpose.
    # Get one data path and one aSVG path and assembly them into a list for creating default dataset.
    data.path1 <- system.file('extdata/shinyApp/example/expr_arab.txt', package='spatialHeatmap')
    svg.path1 <- system.file('extdata/shinyApp/example/arabidopsis_thaliana.shoot_shm.svg',
    package='spatialHeatmap')
    # The list with name slots of "name", "data", and "svg".
    lis.dat1 <- list(name='shoot', data=data.path1, svg=svg.path1)
    # Get one data path and two aSVG paths and assembly them into a list for creating default
    # dataset, which include two growth stages.
    data.path2 <- system.file('extdata/shinyApp/example/random_data_multiple_aSVGs.txt',
    package='spatialHeatmap')
    svg.path2.1 <- system.file('extdata/shinyApp/example/arabidopsis_thaliana.organ_shm1.svg',
    package='spatialHeatmap')
    svg.path2.2 <- system.file('extdata/shinyApp/example/arabidopsis_thaliana.organ_shm2.svg',
    package='spatialHeatmap')
    # The list with name slots of "name", "data", and "svg", where the two aSVG paths are stored
    # in a vector in "svg".
    lis.dat2 <- list(name='growthStage', data=data.path2, svg=c(svg.path2.1, svg.path2.2))
    # Get one data path and one aSVG path and assembly them into a list for creating downloadable
    # dataset.
    data.path.dld1 <- system.file('extdata/shinyApp/example/expr_arab.txt',
    package='spatialHeatmap')
    svg.path.dld1 <- system.file('extdata/shinyApp/example/arabidopsis_thaliana.organ_shm.svg',
    package='spatialHeatmap')
    # The list with name slots of "data", and "svg".
    lis.dld.single <- list(name='organ', data=data.path.dld1, svg=svg.path.dld1)
    # For demonstration purpose, the same data and aSVGs are used to make the list for creating
    # downloadable dataset, which include two growth stages.
    lis.dld.mul <- list(data=data.path2, svg=c(svg.path2.1, svg.path2.2))
    # Retrieve the default parameters.
    lis.par <- custom_shiny(lis.par.tmp=TRUE)
    # Change default values.
    lis.par$shm.img['color', ] <- 'yellow,orange,blue'
    # The default dataset to show upon the app is launched.
    lis.par$default.dataset <- 'shoot'

    if (!dir.exists('~/test_shiny')) dir.create('~/test_shiny')
    # Create custom Shiny app by feeding this function these datasets and parameters.
    custom_shiny(lis.dat1, lis.dat2, lis.par=lis.par, lis.dld.single=lis.dld.single,
    lis.dld.mul=lis.dld.mul, app.dir='~/test_shiny')
    # Lauch the app.
    shiny::runApp('~/test_shiny/shinyApp')

[Package spatialHeatmap version 1.0.0 Index]