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

Anh N. Tran1*

1Northwestern University, Illinois, USA

*trannhatanh89@gmail.com

#### 2020-01-18

    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]])
    #> Classes 'tbl_df', 'tbl' and 'data.frame':    337 obs. of  18 variables:
    #>  $ patientId         : chr  "1447" "1452" "1470" "1647" ...
    #>  $ age               : chr  "45" "44" "65" "63" ...
    #>  $ sex               : chr  "Female" "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://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  "M-00100" "M-00100" "M-00100" "M-00100" ...
    #>  $ snomedCode2       : chr  "T-04000" "T-04000" "T-1X700" "T-64300" ...
    #>  $ snomedCode3       : chr  NA NA "T-28000" 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  "Breast" "Breast" "Cartilage tissue" "Duodenum" ...
    #>  $ tissueDescription3: chr  NA NA "Lung" NA ...
    #>  $ tissueDescription4: chr  NA NA NA NA ...
    #>  $ tissueDescription5: chr  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