## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(
  collapse=TRUE,
  comment="#>",
  warning=FALSE,
  error=FALSE,
  eval=FALSE
)

## ----library, message=FALSE, warning=FALSE, error=FALSE-----------------------
# library(HPAanalyze)
# library(dplyr)

## ----Search1------------------------------------------------------------------
# hpaSearch(search = "TP53")
# 
# #> # A tibble: 1 x 3
# #>   Gene  `Gene synonym` Ensembl
# #>   <chr> <chr>          <chr>
# #> 1 TP53  LFS1, p53      ENSG00000141510

## ----Search2------------------------------------------------------------------
# nrow(hpaSearch(search = "TP53"))
# #> [1] 45

## ----Search3------------------------------------------------------------------
# hpaSearch(search = "TP53", exact = TRUE)
# 
# #> # A tibble: 1 x 3
# #>   Gene  `Gene synonym` Ensembl
# #>   <chr> <chr>          <chr>
# #> 1 TP53  LFS1, p53      ENSG00000141510

## ----Search4------------------------------------------------------------------
# hpaSearch(search = "TP53", columns = c("g", "eg", "pc", "subloc"))
# hpaSearch(search = "TP53", columns = "g,eg,pc,subloc")

## ----Search5------------------------------------------------------------------
# cd_markers <- hpaSearch(
#   search = "protein_class:CD markers AND normal_expression:Cerebral cortex;Any;Not detected,Low AND prognostic:Glioma;Unfavourable",
#   columns = c("g", "gs", "eg")
# )
# cd_markers
# 
# #> # A tibble: 6 x 3
# #>   Gene  `Gene synonym`         Ensembl
# #>   <chr> <chr>                  <chr>
# #> 1 CD81  TAPA-1, TAPA1, TSPAN28 ENSG00000110651
# #> 2 NRP1  CD304, NRP1            ENSG00000099250
# #> 3 PRNP  ASCR, CD230, PRIP      ENSG00000171867
# #> 4 SDC1  CD138, SDC, SYND1      ENSG00000115884
# #> 5 THY1  CD90                   ENSG00000154096
# #> # ... with 1 more row

## ----Search6------------------------------------------------------------------
# ## Visualize the search hits with the hpaVis family
# latest_datasets <- hpaDownload()
# 
# hpaVis(data = latest_datasets,
#        targetGene = cd_markers$Gene,
#        targetTissue = "cerebral cortex",
#        targetCancer = "glioma")
# 
# ## ...or pull the full xml for each hit
# cd_markers_xml <- lapply(cd_markers$Ensembl, hpaXmlGet)
# names(cd_markers_xml) <- cd_markers$Gene
# 
# cd_markers_protclass <- lapply(cd_markers_xml, hpaXmlProtClass)

