5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

遺伝研スパコンでRの環境整備する

Last updated at Posted at 2019-06-20

環境

遺伝研スパコン。

試行1. jupyter notebookを試す

まずサーバーにjupyterをインストール

pip install jupyter --user
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-43viUw/ipykernel/
You are using pip version 8.1.2, however version 19.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

よくわからん:thinking: が、pipをアップグレードするといいっぽい
https://ja.stackoverflow.com/questions/46978/pip-でインストールエラー-command-python-setup-py-egg-info-failed
が、まぁAnaconda使った方が楽だよねということでAnacondaを入れる

wget https://repo.anaconda.com/archive/Anaconda3-2019.03-Linux-x86_64.sh
sh Anaconda3-2019.03-Linux-x86_64.sh

あとは参考
に従って進めていくと、変なバグに遭遇

これにも遭遇

sshポートフォワーディングとか色々試したけど結果ダメだった・・・:thinking:
あまり深追いすると泥沼の予感がしたので撤退

試行2. コンテナ使ってRを入れる

rockerがRのコンテナの最強のやつっぽい。
https://hub.docker.com/u/rocker/?page=1
ここからほしいやつを探す。bioinfoっぽいやつが見当たらないので、geo系のpackageがいっぱい入った geospatialを使ってみる(海洋微生物学の研究だと地図描きたいことが結構ある)。色々入ってるのでそれなりに重いが、スクラップ&ビルドを繰り返すような使い方はしないと思うのでこれでいく。
geospatialにはtidyverse などの基本的なやつは全部入っているが、bioinfo特化のやつは流石に入ってないので別途入れる。インストールのためには /usr/local/lib/R/site-library の権限をいじる必要があるが、スパコンだと無理そう。この辺のuser権限周りはdocker <-> singularityのだるいところという感じ。

なので使い方としては
https://github.com/rocker-org/geospatial/blob/master/Dockerfile
のDockerファイルをコピーし、必要なパッケージを書き加えてビルド。

vegan , dichromat を入れるとこんな感じ。

FROM rocker/verse:3.6.0
MAINTAINER YOHEI_KUMAGAI

RUN apt-get update \
  && apt-get install -y --no-install-recommends \
    lbzip2 \
    libfftw3-dev \
    libgdal-dev \
    libgeos-dev \
    libgsl0-dev \
    libgl1-mesa-dev \
    libglu1-mesa-dev \
    libhdf4-alt-dev \
    libhdf5-dev \
    libjq-dev \
    liblwgeom-dev \
    libpq-dev \
    libproj-dev \
    libprotobuf-dev \
    libnetcdf-dev \
    libsqlite3-dev \
    libssl-dev \
    libudunits2-dev \
    netcdf-bin \
    postgis \
    protobuf-compiler \
    sqlite3 \
    tk-dev \
    unixodbc-dev \
  && install2.r --error \
    RColorBrewer \
    RandomFields \
    RNetCDF \
    classInt \
    deldir \
    gstat \
    hdf5r \
    lidR \
    mapdata \
    maptools \
    mapview \
    ncdf4 \
    proj4 \
    raster \
    rgdal \
    rgeos \
    rlas \
    sf \
    sp \
    spacetime \
    spatstat \
    spatialreg \
    spdep \
    geoR \
    geosphere \
    vegan \
    dichromat \
    ## from bioconductor
    && R -e "BiocManager::install('rhdf5')"

gitHubのリポジトリ作ってコイツをupし、docker hubと連携してpackage追加したいときはpushすれば勝手にBuildされるようにする。参考:https://qiita.com/Yohei__K/items/ffbc07454aceb459d6c1

作ったgitHubのリポジトリは以下。
https://github.com/kmooog/R_container

これでとりあえずRの環境をcontainerに閉じ込めて必要に応じてパッケージ取ってくるところまで達成。

本当はこのコンテナからR studio server起動してlocalから入りたかったんだけどなんか動きませんでした。R studio serverはjupyterと比べてweb上に情報少なくてむずい。

Singularity r-for-metagenome-latest.img:~/r/amplicon> /usr/lib/rstudio-server/bin/rstudio-server start
/usr/lib/rstudio-server/bin/rstudio-server: 1: eval: systemctl: not found
Singularity r-for-metagenome-latest.img:~/r/amplicon> /usr/lib/rstudio-server/bin/rstudio-server verify-installation
Server is running and must be stopped before running verify-installation
Singularity r-for-metagenome-latest.img:~/r/amplicon> /usr/lib/rstudio-server/bin/rstudio-server stop
/usr/lib/rstudio-server/bin/rstudio-server: 1: eval: systemctl: not found
rsession: no process found
5
4
6

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?