return_feature {spatialHeatmap} | R Documentation

## Return aSVG Files Relevant to Target Features

### Description

This function parses a collection of aSVG files and returns those containing target features in a data frame. Successful spatial heatmap plotting requires the aSVG features of interest have matching samples (cells, tissues, etc) in the data. To meet this requirement, the returned features could be used to replace target sample counterparts in the data. Alternatively, the target samples in the data could be used to replace matching features in the aSVG through function `update_feature`. Refer to function `spatial_hm` for more details on aSVG files.

### Usage

    return_feature(
      feature,
      species,
      keywords.any = TRUE,
      remote = TRUE,
      dir = NULL,
      svg.path = NULL,
      desc = FALSE,
      match.only = TRUE,
      return.all = FALSE
    )

### Arguments

`feature` | A vector of target feature keywords (case insentitive), which is used to select aSVG files from a collection. E.g. c('heart', 'brain'). If NA or NULL, all features of all SVG files matching `species` are returned.
`species` | A vector of target species keywords (case insentitive), which is used to select aSVG files from a collection. E.g. c('gallus'). If NA or NULL, all SVG files in `dir` are queried.
`keywords.any` | Logical, TRUE or FALSE. Default is TRUE. The internal searching is case-insensitive. The space, dot, hypen, semicolon, comma, forward slash are treated as separators between words and not counted in searching. If TRUE, every returned hit contains at least one word in the `feature` vector and at least one word in the `species` vector, which means all the possible hits are returned. E.g. "prefrontal cortex" in "homo_sapiens.brain.svg" would be returned if `feature=c('frontal')` and `species=c('homo')`. If FALSE, every returned hit contains at least one exact element in the `feature` vector and all exact elements in the `species` vector. E.g. "frontal cortex" rather than "prefrontal cortex" in "homo_sapiens.brain.svg" would be returned if `feature=c('frontal cortex')` and `species=c('homo sapiens', 'brain')`.
`remote` | Logical, FALSE or TRUE. If TRUE (default), the remote EBI aSVG repository https://github.com/ebi-gene-expression-group/anatomogram/tree/master/src/svg and spatialHeatmap aSVG Repository https://github.com/jianhaizhang/spatialHeatmap_aSVG_Repository developed in this project are queried.
`dir` | The directory path of aSVG files. If `remote` is TRUE, the returned aSVG files are saved in this directory. Note existing aSVG files with same names as returned ones are overwritten. If `remote` is FALSE, user-provided (local) aSVG files should be saved in this directory for query. Default is NULL.
`svg.path` | The path of a specific aSVG file. If the provided aSVG file exists, only features of this file are returned and there will be no querying process. Default is NULL.
`desc` | Logical, FALSE or TRUE. Default is FALSE. If TRUE, the feature descriptions from the R package "rols" (Laurent Gatto 2019) are added. If too many features are returned, this process takes a long time.
`match.only` | Logical, TRUE or FALSE. If TRUE (default), only target features are returned. If FALSE, all features in the matching aSVG files are returned, and the matching features are moved on the top of the data frame.
`return.all` | Logical, FALSE or TRUE. Default is FALSE. If TRUE, all features together with all respective aSVG files are returned, regardless of `feature` and `species`.

### Value

A data frame containing information on target features and aSVGs.

### Author(s)

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

### References

Laurent Gatto (2019). rols: An R interface to the Ontology Lookup Service. R package version 2.14.0. http://lgatto.github.com/rols/
Hadley Wickham, Jim Hester and Jeroen Ooms (2019). xml2: Parse XML. R package version 1.2.2. https://CRAN.R-project.org/package=xml2
R Core Team (2019). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. URL https://www.R-project.org/.
Cardoso-Moreira, Margarida, Jean Halbert, Delphine Valloton, Britta Velten, Chunyan Chen, Yi Shao, Angélica Liechti, et al. 2019. "Gene Expression Across Mammalian Organ Development." Nature 571 (7766): 505-9

### Examples

    # This function is able to work on the EBI aSVG repository directly: https://github.com/
    # ebi-gene-expression-group/anatomogram/tree/master/src/svg. The following shows how to
    # download a chicken aSVG containing spatial features of 'brain' and 'heart'. An empty
    # directory is recommended so as to avoid overwriting existing SVG files.
    # Here "~/test" is used.

    # Make an empty directory "~/test" if not exist.
    if (!dir.exists('~/test')) dir.create('~/test')
    # Query the remote EBI aSVG repo.
    feature.df <- return_feature(feature=c('heart', 'brain'), species=c('gallus'), dir='~/test',
    match.only=FALSE, remote=TRUE)
    feature.df
    # The path of downloaded aSVG.
    svg.chk <- '~/test/gallus_gallus.svg'

    # The spatialHeatmap package has a small aSVG collection and can be used to demonstrate the
    # local query.
    # Get the path of local aSVGs from the package.
    svg.dir <- system.file("extdata/shinyApp/example", package="spatialHeatmap")
    # Query the local aSVG repo. The "species" argument is set NULL on purpose so as to illustrate
    # how to select the target aSVG among all matching aSVGs.
    feature.df <- return_feature(feature=c('heart', 'brain'), species=NULL, dir=svg.dir,
    match.only=FALSE, remote=FALSE)
    # All matching aSVGs.
    unique(feature.df$SVG)
    # Select the target aSVG of chicken.
    subset(feature.df, SVG=='gallus_gallus.svg')

[Package spatialHeatmap version 1.2.0 Index]