RNA-seq のDEG解析ツールTCC-GUI をUbuntu 18.04LTSでインストールする際のエラー対策

- [RNA-seq 発現変動遺伝子解析：salmonとTCC-GUIを使って](https://qiita.com/chaoi/items/ba30a0e85218325813fe#5--%E7%99%BA%E7%8F%BE%E9%87%8F%E3%81%AE%E7%BE%A4%E9%96%93%E6%AF%94%E8%BC%83%E3%83%BC-quantsf-%E3%82%92tximport-%E3%81%A7%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E6%95%B4%E5%BD%A2%E3%81%97tcc-gui-%E3%81%B8%E6%B5%81%E3%81%97%E8%BE%BC%E3%82%80)という記事の補足です。


###前回の記事では
####macOS mojave上で
1. salmonを用いることにより、alighnerを使用せず、転写物配列のインデックスを利用して、readsをカウントする
2. TCC-GUIを用いて、PCA分析、クラスタリング、シルエット分析、これらの可視化、発現変動遺伝子(DEG)抽出を行う

ことを目的に実際の作業ログを記しました。

###今回の記事は
####Ubuntu 18.04LTS上でTCC-GUIを動かせるようにするための補足記事です。RStudio上でインストールする際のエラーとその解決法を尋ねられたのでメモとして残します。

####環境
R version 3.6.2 (2019-12-12) 
RStudio　Version 1.2.1335
Ubuntu 18.04.4 LTS


##RStudioでインストールしようとして出たエラー①
[GitHubに書かれたインストールコマンド](https://github.com/swsoyee/TCC-GUI)

```R:R
# Check "BiocManager"
if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")

# Package list
libs <- c("shiny", "shinydashboard", "shinyWidgets", "plotly", "dplyr", "DT", "heatmaply", "tidyr","utils","rmarkdown","data.table","RColorBrewer", "knitr", "cluster", "shinycssloaders", "shinyBS", "MASS", "TCC")

# Install packages if missing
for (i in libs){
  if( !is.element(i, .packages(all.available = TRUE)) ) {
     BiocManager::install(i, suppressUpdates=TRUE)
  }
}

```
を実行すると以下のエラーがでた。

```R
Bioconductor version 3.9 (BiocManager 1.30.4), R 3.6.2 (2019-12-12)
Installing package(s) 'plotly'
also installing the dependencies ‘curl’, ‘openssl’, ‘httr’

 URL 'https://cloud.r-project.org/src/contrib/curl_4.3.tar.gz' を試しています 
Content type 'application/x-gzip' length 673779 bytes (657 KB)
==================================================
downloaded 657 KB

 URL 'https://cloud.r-project.org/src/contrib/openssl_1.4.1.tar.gz' を試しています 
Content type 'application/x-gzip' length 1206885 bytes (1.2 MB)
==================================================
downloaded 1.2 MB

 URL 'https://cloud.r-project.org/src/contrib/httr_1.4.1.tar.gz' を試しています 
Content type 'application/x-gzip' length 158465 bytes (154 KB)
==================================================
downloaded 154 KB

 URL 'https://cloud.r-project.org/src/contrib/plotly_4.9.1.tar.gz' を試しています 
Content type 'application/x-gzip' length 3552408 bytes (3.4 MB)
==================================================
downloaded 3.4 MB

* installing *source* package ‘curl’ ...
**  パッケージ ‘curl’ の解凍および MD5 サムの検証に成功しました 
** using staged installation
Package libcurl was not found in the pkg-config search path.
Perhaps you should add the directory containing `libcurl.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libcurl' found
Package libcurl was not found in the pkg-config search path.
Perhaps you should add the directory containing `libcurl.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libcurl' found
Using PKG_CFLAGS=
Using PKG_LIBS=-lcurl
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libcurl was not found. Try installing:
 * deb: libcurl4-openssl-dev (Debian, Ubuntu, etc)
 * rpm: libcurl-devel (Fedora, CentOS, RHEL)
 * csw: libcurl_dev (Solaris)
If libcurl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libcurl.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘curl’
* removing ‘/home/fuga/R/x86_64-pc-linux-gnu-library/3.6/curl’
* installing *source* package ‘openssl’ ...
**  パッケージ ‘openssl’ の解凍および MD5 サムの検証に成功しました 
** using staged installation
Using PKG_CFLAGS=
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because openssl was not found. Try installing:
 * deb: libssl-dev (Debian, Ubuntu, etc)
 * rpm: openssl-devel (Fedora, CentOS, RHEL)
 * csw: libssl_dev (Solaris)
 * brew: openssl@1.1 (Mac OSX)
If openssl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a openssl.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘openssl’
* removing ‘/home/fuga/R/x86_64-pc-linux-gnu-library/3.6/openssl’
ERROR: dependencies ‘curl’, ‘openssl’ are not available for package ‘httr’
* removing ‘/home/fuga/R/x86_64-pc-linux-gnu-library/3.6/httr’
ERROR: dependency ‘httr’ is not available for package ‘plotly’
* removing ‘/home/fuga/R/x86_64-pc-linux-gnu-library/3.6/plotly’

The downloaded source packages are in
	‘/tmp/RtmpykvcWz/downloaded_packages’
installation path not writeable, unable to update packages: class, codetools, foreign,
  lattice, nnet, spatial
Update old packages: 'BH', 'bibtex', 'bio3d', 'BiocManager', 'bit', 'blob', 'broom',
  'callr', 'caTools', 'cli', 'data.table', 'DBI', 'dendextend', 'digest', 'doRNG',
  'dplyr', 'DT', 'e1071', 'exactRankTests', 'fansi', 'fields', 'ggpubr', 'glmnet',
  'gplots', 'HDF5Array', 'hexbin', 'Hmisc', 'hms', 'htmlTable', 'htmltools',
  'htmlwidgets', 'igraph', 'jsonlite', 'kernlab', 'KernSmooth', 'knitr', 'latticeExtra',
  'MASS', 'mime', 'mvtnorm', 'openxlsx', 'pillar', 'pkgbuild', 'pkgmaker', 'plyr',
  'prettyunits', 'promises', 'purrr', 'pvclust', 'R.oo', 'R.utils', 'R6', 'Rcpp',
  'RcppArmadillo', 'RcppEigen', 'rhdf5', 'Rhdf5lib', 'Rhtslib', 'rlang', 'rmarkdown',
  'rngtools', 'rrBLUP', 'RSpectra', 'RSQLite', 'scales', 'segmented', 'shiny',
  'shinycssloaders', 'shinyFiles', 'shinyWidgets', 'spam', 'stringi', 'testthat',
  'tidyr', 'tidyselect', 'tinytex', 'TSP', 'vcfR', 'vctrs', 'webshot', 'xfun', 'yaml',
  'zoo'
Update all/some/none? [a/s/n]: 

```



##エラー対策①
一旦ここでRStudioのセッションを保存せず閉じる。

ここで以下に着目
#### libcurl
```R
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libcurl was not found. Try installing:
 * deb: libcurl4-openssl-dev (Debian, Ubuntu, etc)
 * rpm: libcurl-devel (Fedora, CentOS, RHEL)
 * csw: libcurl_dev (Solaris)
If libcurl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libcurl.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
```
####  openssl
```R
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because openssl was not found. Try installing:
 * deb: libssl-dev (Debian, Ubuntu, etc)
 * rpm: openssl-devel (Fedora, CentOS, RHEL)
 * csw: libssl_dev (Solaris)
 * brew: openssl@1.1 (Mac OSX)
If openssl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a openssl.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
```
##### この2つのエラーゆえに　httr, plotlyもエラー
```R
ERROR: dependencies ‘curl’, ‘openssl’ are not available for package ‘httr’
* removing ‘/home/fuga/R/x86_64-pc-linux-gnu-library/3.6/httr’
ERROR: dependency ‘httr’ is not available for package ‘plotly’
* removing ‘/home/fuga/R/x86_64-pc-linux-gnu-library/3.6/plotly’
```
####「端末」を起動して 2つのANTICONF ERRORの記載をもとに以下を実行
```bash:shell
sudo apt install libcurl4-openssl-dev libssl-dev
```

##RStudioでインストールしようとして出たエラー②
再度、RStudioを起動し、上記インストールコマンドを再実行すると別のエラーが出た。

```R
Bioconductor version 3.9 (BiocManager 1.30.10), R 3.6.2 (2019-12-12)
Installing package(s) 'TCC'
also installing the dependencies ‘XML’, ‘annotate’, ‘genefilter’, ‘geneplotter’, ‘DESeq’, ‘DESeq2’

 URL 'https://cloud.r-project.org/src/contrib/XML_3.99-0.3.tar.gz' を試しています 
Content type 'application/x-gzip' length 968543 bytes (945 KB)
==================================================
downloaded 945 KB

 URL 'https://bioconductor.org/packages/3.9/bioc/src/contrib/annotate_1.62.0.tar.gz' を試しています 
Content type 'application/x-gzip' length 1870418 bytes (1.8 MB)
==================================================
downloaded 1.8 MB

 URL 'https://bioconductor.org/packages/3.9/bioc/src/contrib/genefilter_1.66.0.tar.gz' を試しています 
Content type 'application/x-gzip' length 1419350 bytes (1.4 MB)
==================================================
downloaded 1.4 MB

 URL 'https://bioconductor.org/packages/3.9/bioc/src/contrib/geneplotter_1.62.0.tar.gz' を試しています 
Content type 'application/x-gzip' length 1435430 bytes (1.4 MB)
==================================================
downloaded 1.4 MB

 URL 'https://bioconductor.org/packages/3.9/bioc/src/contrib/DESeq_1.36.0.tar.gz' を試しています 
Content type 'application/x-gzip' length 1692053 bytes (1.6 MB)
==================================================
downloaded 1.6 MB

 URL 'https://bioconductor.org/packages/3.9/bioc/src/contrib/DESeq2_1.24.0.tar.gz' を試しています 
Content type 'application/x-gzip' length 2056901 bytes (2.0 MB)
==================================================
downloaded 2.0 MB

 URL 'https://bioconductor.org/packages/3.9/bioc/src/contrib/TCC_1.24.0.tar.gz' を試しています 
Content type 'application/x-gzip' length 3105981 bytes (3.0 MB)
==================================================
downloaded 3.0 MB

* installing *source* package ‘XML’ ...
**  パッケージ ‘XML’ の解凍および MD5 サムの検証に成功しました 
** using staged installation
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for sed... /bin/sed
checking for pkg-config... /usr/bin/pkg-config
checking for xml2-config... no
Cannot find xml2-config
ERROR: configuration failed for package ‘XML’
* removing ‘/home/fuga/R/x86_64-pc-linux-gnu-library/3.6/XML’
ERROR: dependency ‘XML’ is not available for package ‘annotate’
* removing ‘/home/fuga/R/x86_64-pc-linux-gnu-library/3.6/annotate’
ERROR: dependency ‘annotate’ is not available for package ‘genefilter’
* removing ‘/home/fuga/R/x86_64-pc-linux-gnu-library/3.6/genefilter’
ERROR: dependency ‘annotate’ is not available for package ‘geneplotter’
* removing ‘/home/fuga/R/x86_64-pc-linux-gnu-library/3.6/geneplotter’
ERROR: dependencies ‘genefilter’, ‘geneplotter’ are not available for package ‘DESeq’
* removing ‘/home/fuga/R/x86_64-pc-linux-gnu-library/3.6/DESeq’
ERROR: dependencies ‘genefilter’, ‘geneplotter’ are not available for package ‘DESeq2’
* removing ‘/home/fuga/R/x86_64-pc-linux-gnu-library/3.6/DESeq2’
ERROR: dependencies ‘DESeq’, ‘DESeq2’ are not available for package ‘TCC’
* removing ‘/home/fuga/R/x86_64-pc-linux-gnu-library/3.6/TCC’

The downloaded source packages are in
	‘/tmp/Rtmpnqzr7i/downloaded_packages’
Installation path not writeable, unable to update packages: foreign
 警告メッセージ: 
1:  install.packages(...) で: 
  installation of package ‘XML’ had non-zero exit status
2:  install.packages(...) で: 
  installation of package ‘annotate’ had non-zero exit status
3:  install.packages(...) で: 
  installation of package ‘genefilter’ had non-zero exit status
4:  install.packages(...) で: 
  installation of package ‘geneplotter’ had non-zero exit status
5:  install.packages(...) で: 
  installation of package ‘DESeq’ had non-zero exit status
6:  install.packages(...) で: 
  installation of package ‘DESeq2’ had non-zero exit status
7:  install.packages(...) で: 
  installation of package ‘TCC’ had non-zero exit status
```


##エラー対策②
ここで、以下の表記に着目

`Cannot find xml2-config
ERROR: configuration failed for package ‘XML’`

その下のERRORも読むと、xml2-configが見つからないことが依存性の関係で問題のようだ。
そこでRStudioを一旦終了してから「端末」で以下を実行。

```bash:shell
sudo apt install libxml2-dev
```

①ではcurlはすでにインストールされていたのにエラーが出ていた。「○○がない」って怒られた際、「○○」がインストールされている場合、「○○-dev(devはdevianの意味)」をインストールすれば解決するのか？正確なところ、ご存知の方がいればコメントいただけるとありがたいです。

##インストール成功

RStudioを起動し、冒頭のインストールコマンドを再実行すると直接出力の最後は以下のようになって

```R
* installing *source* package ‘TCC’ ...
** using staged installation
** R
** data
** inst
** byte-compile and prepare package for lazy loading
Creating a new generic function for ‘calcNormFactors’ in package ‘TCC’
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (TCC)

The downloaded source packages are in
	‘/tmp/Rtmpsh0qrI/downloaded_packages’
Installation path not writeable, unable to update packages: foreign
> 
```



最後まで一気にインストールを行えた。


##TCC-GUIの起動を確認
###Method 1 : 毎回起動時にGitHubからダウンロードする方法。
```R:R
shiny::runGitHub("TCC-GUI", "swsoyee", subdir = "TCC-GUI", launch.browser = TRUE)
```

ブラウザが起動し、TCC-GUIの最初のベージが表示された
###Method 2 : ソースコードをGitHubから自分でダウンロードしローカルに保存しておき、これを起動する方法。
RStudioを起動する前に以下の準備を行う。
githubからダウンロードしたファイル
`TCC-GUI-master.zip`
を以下のディレクトリに展開
`/home/hoge/tools/TCC-GUI/TCC-GUI-master`
######RStudioを起動, コンソールで以下の作業。
まず実行ディレクトリへ移動

```R:R
setwd("~/tools/TCC-GUI/")
```

以下のコマンドで実行

```R:R
shiny::runApp("TCC-GUI-master//TCC-GUI", launch.browser = TRUE)
```



以下がコンソールに表示されたあとブラウザ上にTCC-GUIが起動。
サンプルデータで実行してみたが、Method1より動きがキビキビしている印象。
ソースコードのサイズは 21.4 MBと小さく、ネット接続なしに起動できるのでmacOSでも、こちらがおすすめ。

```R
Loading required package: shiny

Attaching package: ‘shinydashboard’

The following object is masked from ‘package:graphics’:

    box

Loading required package: ggplot2

Attaching package: ‘plotly’

The following object is masked from ‘package:ggplot2’:

    last_plot

The following object is masked from ‘package:stats’:

    filter

The following object is masked from ‘package:graphics’:

    layout


Attaching package: ‘dplyr’

The following objects are masked from ‘package:stats’:

    filter, lag

The following objects are masked from ‘package:base’:

    intersect, setdiff, setequal, union

Loading required package: DESeq
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: ‘BiocGenerics’

The following objects are masked from ‘package:parallel’:

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ, clusterExport,
    clusterMap, parApply, parCapply, parLapply, parLapplyLB, parRapply,
    parSapply, parSapplyLB

The following objects are masked from ‘package:dplyr’:

    combine, intersect, setdiff, union

The following objects are masked from ‘package:stats’:

    IQR, mad, sd, var, xtabs

The following objects are masked from ‘package:base’:

    anyDuplicated, append, as.data.frame, basename, cbind, colnames, dirname,
    do.call, duplicated, eval, evalq, Filter, Find, get, grep, grepl,
    intersect, is.unsorted, lapply, Map, mapply, match, mget, order, paste,
    pmax, pmax.int, pmin, pmin.int, Position, rank, rbind, Reduce, rownames,
    sapply, setdiff, sort, table, tapply, union, unique, unsplit, which,
    which.max, which.min

Loading required package: Biobase
Welcome to Bioconductor

    Vignettes contain introductory material; view with 'browseVignettes()'. To
    cite Bioconductor, see 'citation("Biobase")', and for packages
    'citation("pkgname")'.

Loading required package: locfit
locfit 1.5-9.1 	 2013-03-22
Loading required package: lattice
    Welcome to 'DESeq'. For improved performance, usability and functionality,
    please consider migrating to 'DESeq2'.
Loading required package: DESeq2
Loading required package: S4Vectors
Loading required package: stats4

Attaching package: ‘S4Vectors’

The following objects are masked from ‘package:dplyr’:

    first, rename

The following object is masked from ‘package:plotly’:

    rename

The following object is masked from ‘package:base’:

    expand.grid

Loading required package: IRanges

Attaching package: ‘IRanges’

The following objects are masked from ‘package:dplyr’:

    collapse, desc, slice

The following object is masked from ‘package:plotly’:

    slice

Loading required package: GenomicRanges
Loading required package: GenomeInfoDb
Loading required package: SummarizedExperiment
Loading required package: DelayedArray
Loading required package: matrixStats

Attaching package: ‘matrixStats’

The following objects are masked from ‘package:Biobase’:

    anyMissing, rowMedians

The following object is masked from ‘package:dplyr’:

    count

Loading required package: BiocParallel

Attaching package: ‘DelayedArray’

The following objects are masked from ‘package:matrixStats’:

    colMaxs, colMins, colRanges, rowMaxs, rowMins, rowRanges

The following objects are masked from ‘package:base’:

    aperm, apply, rowsum


Attaching package: ‘DESeq2’

The following objects are masked from ‘package:DESeq’:

    estimateSizeFactorsForMatrix, getVarianceStabilizedData,
    varianceStabilizingTransformation

Loading required package: edgeR
Loading required package: limma

Attaching package: ‘limma’

The following object is masked from ‘package:DESeq2’:

    plotMA

The following object is masked from ‘package:DESeq’:

    plotMA

The following object is masked from ‘package:BiocGenerics’:

    plotMA

Loading required package: baySeq
Loading required package: abind

Attaching package: ‘baySeq’

The following object is masked from ‘package:dplyr’:

    groups

The following object is masked from ‘package:plotly’:

    groups

Loading required package: ROC

Attaching package: ‘TCC’

The following object is masked from ‘package:edgeR’:

    calcNormFactors


Attaching package: ‘DT’

The following objects are masked from ‘package:shiny’:

    dataTableOutput, renderDataTable

Loading required package: viridis
Loading required package: viridisLite
Registered S3 method overwritten by 'seriation':
  method         from 
  reorder.hclust gclus

======================
Welcome to heatmaply version 1.0.0

Type citation('heatmaply') for how to cite the package.
Type ?heatmaply for the main documentation.

The github page is: https://github.com/talgalili/heatmaply/
Please submit your suggestions and bug-reports at: https://github.com/talgalili/heatmaply/issues
Or contact: <tal.galili@gmail.com>
======================


Attaching package: ‘heatmaply’

The following object is masked from ‘package:BiocGenerics’:

    normalize

data.table 1.12.8 using 4 threads (see ?getDTthreads).  Latest news: r-datatable.com

Attaching package: ‘data.table’

The following object is masked from ‘package:SummarizedExperiment’:

    shift

The following object is masked from ‘package:GenomicRanges’:

    shift

The following object is masked from ‘package:IRanges’:

    shift

The following objects are masked from ‘package:S4Vectors’:

    first, second

The following objects are masked from ‘package:dplyr’:

    between, first, last


Attaching package: ‘tidyr’

The following object is masked from ‘package:S4Vectors’:

    expand


Attaching package: ‘MASS’

The following object is masked from ‘package:dplyr’:

    select

The following object is masked from ‘package:plotly’:

    select


Listening on http://127.0.0.1:4896
```