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,
      lis.dld.st = NULL,
      example = TRUE,
      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 existing 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. The data and aSVG should only include the spatial dimension, no temporal dimension. 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')).
`lis.dld.st` | 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. Compared with `lis.dld.single`, the only difference is the data and aSVG include spatial and temporal dimension. See the example section for details. 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')`.
`example` | Logical, TRUE or FALSE. If TRUE (default), 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 examples build on pre-packaged examples in spatialHeatmap.

    # 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 the paths of spatiotemporal data and aSVG files and assembly them into a list for
    # creating default dataset.
    data.path.st <- system.file('extdata/shinyApp/example/expr_coleoptile_samTimeCon.txt',
    package='spatialHeatmap')
    svg.path.st <- system.file('extdata/shinyApp/example/oryza.sativa_coleoptile.ANT_shm.svg',
    package='spatialHeatmap')
    # The list with name slots of "name", "data", and "svg".
    lis.dat.st <- list(name='spatiotemporal', data=data.path.st, svg=svg.path.st)

    # 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 of two growth stages.
    lis.dld.mul <- list(data=data.path2, svg=c(svg.path2.1, svg.path2.2))

    # For demonstration purpose, the same spatiotemporal data and aSVG are used to create the
    # downloadable spatiotemporal dataset.
    lis.dld.st <- list(data=data.path.st, svg=svg.path.st)

    # 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.dat.st, lis.par=lis.par, lis.dld.single=lis.dld.single,
    lis.dld.mul=lis.dld.mul, lis.dld.st=lis.dld.st, app.dir='~/test_shiny')
    # Lauch the app.
    shiny::runApp('~/test_shiny/shinyApp')

    # The customized Shiny app is able to take database backend as well. Examples are
    # demonstrated in the function "write_hdf5".

[Package spatialHeatmap version 1.2.0 Index]