# 6. HPAanalyze use case: Download histology images from the Human Protein Atlas

Anh N. Tran1*

1Northwestern University, Illinois, USA

*trannhatanh89@gmail.com

#### 2020-04-27

    library(BiocStyle)
    library(HPAanalyze)
    library(dplyr)

# 1 The case

# 2 The solution

## 2.1 Get the download links

    CCNB1xml <- hpaXmlGet("ENSG00000134057")

    CCNB1_ab <- hpaXmlAntibody(CCNB1xml)
    CCNB1_ab
    #> # A tibble: 4 x 4
    #>   id        releaseVersion releaseDate RRID
    #>   <chr>     <chr>          <chr>       <chr>
    #> 1 CAB000115 1.2            2006-03-13  <NA>
    #> 2 CAB003804 2              2006-10-30  AB_562272
    #> 3 HPA030741 12             2013-12-05  AB_2673586
    #> 4 HPA061448 16             2016-12-04  AB_2684522
    #> # A tibble: 4 x 4
    #>   id        releaseDate releaseVersion RRID
    #>   <chr>     <chr>       <chr>          <chr>
    #> 1 CAB000115 2006-03-13  1.2            <NA>
    #> 2 CAB003804 2006-10-30  2              AB_562272
    #> 3 HPA030741 2013-12-05  12             AB_2673586
    #> 4 HPA061448 2016-12-04  16             AB_2684522

    CCNB1_expr <- hpaXmlTissueExpr(CCNB1xml)
    str(CCNB1_expr[[1]])
    #> tibble [337 × 18] (S3: tbl_df/tbl/data.frame)
    #>  $ patientId         : chr [1:337] "1447" "1452" "1470" "1647" ...
    #>  $ age               : chr [1:337] "45" "44" "65" "63" ...
    #>  $ sex               : chr [1:337] "Female" "Female" "Male" "Male" ...
    #>  $ staining          : chr [1:337] NA NA NA NA ...
    #>  $ intensity         : chr [1:337] NA NA NA NA ...
    #>  $ quantity          : chr [1:337] NA NA NA NA ...
    #>  $ location          : chr [1:337] NA NA NA NA ...
    #>  $ imageUrl          : chr [1:337] "http://images.proteinatlas.org/115/2043_B_2_8.jpg" "http://images.proteinatlas.org/115/2043_B_1_8.jpg" "http://images.proteinatlas.org/115/2043_B_3_8.jpg" "http://images.proteinatlas.org/115/2043_B_1_7.jpg" ...
    #>  $ snomedCode1       : chr [1:337] "M-00100" "M-00100" "M-00100" "M-00100" ...
    #>  $ snomedCode2       : chr [1:337] "T-04000" "T-04000" "T-1X700" "T-64300" ...
    #>  $ snomedCode3       : chr [1:337] NA NA "T-28000" NA ...
    #>  $ snomedCode4       : chr [1:337] NA NA NA NA ...
    #>  $ snomedCode5       : chr [1:337] NA NA NA NA ...
    #>  $ tissueDescription1: chr [1:337] "Normal tissue, NOS" "Normal tissue, NOS" "Normal tissue, NOS" "Normal tissue, NOS" ...
    #>  $ tissueDescription2: chr [1:337] "Breast" "Breast" "Cartilage tissue" "Duodenum" ...
    #>  $ tissueDescription3: chr [1:337] NA NA "Lung" NA ...
    #>  $ tissueDescription4: chr [1:337] NA NA NA NA ...
    #>  $ tissueDescription5: chr [1:337] NA NA NA NA ...
    #> Classes 'tbl_df', 'tbl' and 'data.frame':    331 obs. of  18 variables:
    #>  $ patientId         : chr  "1653" "1721" "1725" "598" ...
    #>  $ age               : chr  "53" "60" "57" "7" ...
    #>  $ sex               : chr  "Male" "Female" "Male" "Male" ...
    #>  $ staining          : chr  NA NA NA NA ...
    #>  $ intensity         : chr  NA NA NA NA ...
    #>  $ quantity          : chr  NA NA NA NA ...
    #>  $ location          : chr  NA NA NA NA ...
    #>  $ imageUrl          : chr  "http://v18.proteinatlas.org/images/115/2043_B_4_5.jpg" "http://v18.proteinatlas.org/images/115/2043_B_6_5.jpg" "http://v18.proteinatlas.org/images/115/2043_B_5_5.jpg" "http://v18.proteinatlas.org/images/115/2043_A_2_2.jpg" ...
    #>  $ snomedCode1       : chr  "M-00100" "M-00100" "M-00100" "M-00100" ...
    #>  $ snomedCode2       : chr  "T-93000" "T-93000" "T-93000" "T-66000" ...
    #>  $ snomedCode3       : chr  NA NA NA NA ...
    #>  $ snomedCode4       : chr  NA NA NA NA ...
    #>  $ snomedCode5       : chr  NA NA NA NA ...
    #>  $ tissueDescription1: chr  "Normal tissue, NOS" "Normal tissue, NOS" "Normal tissue, NOS" "Normal tissue, NOS" ...
    #>  $ tissueDescription2: chr  "Adrenal gland" "Adrenal gland" "Adrenal gland" "Appendix" ...
    #>  $ tissueDescription3: chr  NA NA NA NA ...
    #>  $ tissueDescription4: chr  NA NA NA NA ...
    #>  $ tissueDescription5: chr  NA NA NA NA ...

## 2.2 Download the images

    dir.create("img")
    for (i in 1:nrow(CCNB1_expr[[1]])) {
        download.file(CCNB1_expr[[1]]$imageUrl[i],
                      destfile = paste0("img/", CCNB1_ab$id[1], "_",
                                        CCNB1_expr[[1]]$patientId[i], "_",
                                        CCNB1_expr[[1]]$tissueDescription2[i],
                                        ".jpg"),
                      mode = "wb")
    }

# 3 Copyright

Anh Tran, 2018-2020

Please cite: Tran, A.N., Dussaq, A.M., Kennell, T. et al. HPAanalyze: an R package that facilitates the retrieval and analysis of the Human Protein Atlas data. BMC Bioinformatics 20, 463 (2019) https://doi.org/10.1186/s12859-019-3059-z