Galaxy 入門 === ###### tags: `生物資訊` ###### tags: `生物資訊`, `生物資訊計算平台`, `Galaxy`, `基因體` <br> 目錄 [TOC] <br> ## AWS - 尋找適合做「**生物資訊**」的 EC2 (Elastic Compute Cloud) 規格 - 考量重點: 1. 記憶體夠大 2. 儲存空間大 - ### [Amazon EC2 定價](https://aws.amazon.com/tw/ec2/pricing/on-demand/) - 一般用途 – 最新一代 | | vCPU | ECU | 記憶體 (GiB) | 執行個體儲存體 (GB) | Linux/UNIX 使用量 | | ----------- | -- | ----- | ------- | ----- | -------------- | | m4.4xlarge | 16 | 53.5 | 64 GiB | 僅 EBS | 每小時 0.80 USD | | m4.10xlarge | 40 | 124.5 | 160 GiB | 僅 EBS | 每小時 2.00 USD | - ECU - EC2 Computer Units (EC2 運算單位) - 一般用途,只有上面這兩款適合用於生物資訊 - 主要原因: - 記憶體夠多(夠多?) - 備註:m5規格,8xlarge 以上,記憶體都 128GB 以上 - 另外可以加購 EBS 儲存(Elastic Block Store) 依照分析的資料量來選購適合的空間 <br> - 運算優化 - 記憶體最大只有 60GB, 不予考慮(?) - 備註:目前最新規格,皆有配備更大的記憶體空間,最大是192GB - 記憶體優化 - 需要加購儲存空間 - ### 未來趨勢 - #### 國際趨勢 - 國外近年來,發表不少使用 Amazon 雲端服務,來完成大量生物資訊計算論文 - 部份生物資訊工具,直接放在 Amazon 雲端服務上發展 - #### 國內趨勢 - 國內沒有這樣的研究 - 可能原因 - **頻寬不夠理想** 因為生物資訊的資料量太大了,光把檔案上傳到雲端就很耗時間和金錢 - **擔心資料安全的問題** 人類基因定序涉及到個人隱私 <br> ## Galaxy - ### 關於 - 生物資訊計算平台、生物計算架構 - 由賓州大學開發出來 - 到目前為止,發展最成功的「**開放式生物計算雲端平台**」 - ### 特點 - 大多數的生物資訊工具,可以藉由『**瀏覽器**」來操作 - 使用者不需要學習太多 Linux 指令,只要了解生物計算的流程就會使用 - 研究流程,在 Galaxy 上一樣可實現 - 使用 workflow 概念,把流程中的每樣工具串接起來 - 輸出入資料,使用者皆可預先定義 - 建立過程,不需要繁瑣的程式碼 - ### 使用概觀 - #### Galaxy 原始碼 - https://github.com/galaxyproject/galaxy - #### Galaxy 網址 - https://usegalaxy.org/ - #### 註冊與登錄 - https://usegalaxy.org/login - 註冊完後,需要去收 mail 來啟用帳號,否則在上傳檔案時會有錯誤訊息 ``` Warning: Error executing tool: Action requires account activation. ``` - #### 可佈署到 - Linux - Mac - Amazon 雲端服務 - 專案名稱:[CloudMan](https://galaxyproject.org/cloudman/) (舊名稱:Galaxy Cloud) ![](https://galaxyproject.org/images/galaxy-logos/cloudman-logo.jpg) - 已有映像檔AMIs(Amazon Machine Images)可直接匯入 - 可為自己或自己的實驗室建立「私有雲」,擁有專用的 Galaxy - #### 自製工具 - 開發者自製的工具,要上傳到 Galaxy 也非常容易 - Galaxy 官方有提供完整的文件與教學 - 大概流程 - 將工具的參數與說明定義在 XML 檔裡 - [gatk4_applybqsr.xml?](https://github.com/ohsu-comp-bio/compbio-galaxy-wrappers/blob/master/gatk4/gatk4_applybqsr.xml) - 將自製工具放到指定的位置 - 重啟 Galaxy - #### Galaxy 官方目前提供兩個公開伺服器 - Main: https://usegalaxy.org/ - Test: https://test.galaxyproject.org/ - Main 與 Test 的功能比較 [![](https://i.imgur.com/PGE2FZS.png)](https://i.imgur.com/PGE2FZS.png) - #### Galaxy 的限制 - 當使用者一多,送出的計算請求後,有時還要排隊等待 <br> ## Galaxy 操作細節 / 資料匯入 - ### Get Data ![](https://i.imgur.com/8SCqkOn.png) <br> - 資料來源可從常見的大型生物資訊站獲得,如 NCBI, EBI, UCSC 等 <br> - ### Get Data / Upload Files ![](https://i.imgur.com/9miVc1e.png) <br> <br> - 可以從你的電腦上傳序列資料等等 - 上傳結果 ![](https://i.imgur.com/PZFNu6w.png) <br> - 透過 [IGV](https://software.broadinstitute.org/software/igv/download) local 工具檢視 目前沒有測試成功 但是 local 端的檔案是可以解讀的 [![](https://i.imgur.com/ehOGnag.png)](https://i.imgur.com/ehOGnag.png) <br> - 透過 vcf.iobio.io 工具檢視 [![](https://i.imgur.com/h2ODjug.png)](https://i.imgur.com/h2ODjug.png) <br> - 若檔案太大,建議使用 FTP - 說明文件 [Galaxy FTP Upload](https://galaxyproject.org/ftp-upload/) > - FTP 可以監控上傳狀態,以及支援續傳 > - 三天內未匯入的檔案,系統將從 FTP 上移除 > - 上傳到 FTP 上後,回到原本的 [Upload files] 功能 > 可從 FTP 選單中,選擇剛剛上傳的資料,並匯入到 Galaxy - 操作測試 - 帳密 - 使用註冊 Galaxy 帳號時的 email 和密碼 - via lftp ```bash $ sudo apt-get install lftp $ lftp -u tj_tsai@asus.com usegalaxy.org ``` 有連線成功,但無法存取木 沒有試成功,一直處在 ```Delaying before reconnect: 20``` - via FileZilla ```bash $ sudo apt-get install filezilla ``` [![](https://i.imgur.com/0CnZoHd.png)](https://i.imgur.com/0CnZoHd.png) - ### 官方共享的資料 - 對象 - 手邊沒有序列資料,但想操作與演練 Galaxy 的人 - 入口點: Menu > Shared Data > [Data Libraries](https://usegalaxy.org/library/list) [![](https://i.imgur.com/t4r5dNU.png)](https://i.imgur.com/t4r5dNU.png) <br> [![](https://i.imgur.com/CIZgRz4.png)](https://i.imgur.com/CIZgRz4.png) <br> 可以看到很多計畫名稱 [![](https://i.imgur.com/IbeNSLM.png)](https://i.imgur.com/IbeNSLM.png) <br> 如 GATK 本身提供的範本,有 fasta, bam, vcf 檔 [![](https://i.imgur.com/sOe37cN.png)](https://i.imgur.com/sOe37cN.png) <br> - 以 [Sample NGS Datasets](https://usegalaxy.org/library/list#folders/F5bee13e9f312df25) 當作 Galaxy 的 Hello World > Examples of Illumina, SOLiD, and 454 data > (三種高通量定序平台產生的資料) 選擇要匯入的檔案 [![](https://i.imgur.com/FUbaazt.png)](https://i.imgur.com/FUbaazt.png) <br> 選擇要匯入的專案(History) [![](https://i.imgur.com/TbOelgh.png)](https://i.imgur.com/TbOelgh.png) <br> 回到首頁查看 ![](https://i.imgur.com/fDxlD2X.png) <br> ## 安裝 Galaxy - ### GitHub https://github.com/galaxyproject/galaxy - 環境要求 - python 2.7 - ### 安裝 ```bash # 將近 600 MB $git clone https://github.com/galaxyproject/galaxy.git $cd galaxy # 雖然 Galaxy 會安裝 virtualenv # 但安裝 Galaxy 過程還是會出錯 # 部份套件會讀到 python3 去 $virtualenv -p python2 env-python2 $source env-python2/bin/activate # 開始安裝 $sh run.sh ``` - 檢查 server http://localhost:8080 是否啟動 - 關於虛擬環境 ``` (from log) ... Creating Python virtual environment for Galaxy: .venv using Python: python3 To avoid this, use the --no-create-venv flag or set $GALAXY_VIRTUAL_ENV to an existing environment before starting Galaxy. Running virtualenv with interpreter /home/galaxy/env-python3.6/bin/python3 ... ``` - ### 錯誤排除 ``` Collecting watchdog==0.9.0 Downloading https://wheels.galaxyproject.org/simple/watchdog/watchdog-0.9.0-py2-none-any.whl (72 kB) |████████████████████████████████| 72 kB 151 kB/s Requirement already satisfied: setuptools in ./.venv/lib/python2.7/site-packages (from cwltool==1.0.20191225192155->-r requirements.txt (line 47)) (45.0.0) ERROR: Package 'setuptools' requires a different Python: 2.7.12 not in '>=3.5' ``` - ### 成為 admin 管理員 - 在 config/galaxy.yml 添加 admin email ```yaml admin_users: 'tj_tsai@asus.com' ``` - 點選橫幅 [Login or Register] 註冊會員後,就會出現隱藏的 [Admin] 選項 - ### 安裝常用套件 - **入口點** Admin > [Tool Management] Install or Uninstall - 安裝 FastQC - 在搜尋列上輸入 fastqc [![](https://i.imgur.com/olOTrsp.png)](https://i.imgur.com/olOTrsp.png) <br> - 安裝最新版本 [![](https://i.imgur.com/OzKXuCf.png)](https://i.imgur.com/OzKXuCf.png) - target section 則是相當於「工具的分類」 <br> - 安裝結果,會在首頁的工具清單中出現 [![](https://i.imgur.com/V1b3TYA.png)](https://i.imgur.com/V1b3TYA.png) - ### 上傳常用 dataset - 先為 history 命名:TJ_dataset - 點選右側欄的工具:[Get Data] Upload File [![](https://i.imgur.com/9oPi53H.png)](https://i.imgur.com/9oPi53H.png) - 上傳後,就會出現在目前的 history [![](https://i.imgur.com/EChQtB5.png)](https://i.imgur.com/EChQtB5.png) - 再點選 上側欄的工具: Shared Data > [+Library] - 建立主目錄 - 再依需求,建立所需的子目錄 - 從目前的 history,匯入相關的 dataset <br> ## 安裝 Galaxy (New) ### Docker > - [docker](https://hub.docker.com/r/bgruening/galaxy-stable) > - [github](https://github.com/bgruening/docker-galaxy-stable) ``` docker run -d -p 8080:80 -p 8021:21 -p 8022:22 bgruening/galaxy-stable ``` <br> <hr> <br> ## 介紹 Galaxy 給他人 - Galaxy 是一個開放式生物資訊計算平台,亦是一套視覺化的工具 - 開發者已經將大多數的「生物資訊開發工具」都整合到 Galaxy - 做生物資訊的主要流程 [![](https://miro.medium.com/max/2520/1*dzyIw3S63cvz06UROVjdwA.png)](https://miro.medium.com/max/2520/1*dzyIw3S63cvz06UROVjdwA.png) - **一級分析** 將採樣的檢體,進行數位化(亦即序列)(SAM/BAM檔) - **二級分級** 針對序列,參考相關資料庫,找出變異點位置(VCF檔) - **三級分級** 針對變異點,參考臨床病徵,分析出致病基因的點 - 操作工具前,了解資料從何處來 - local 端 - 以公開分享的樣本資料 - 單一工具操作 - FastQ -> FastQC - encoding - 多個工具的串接(workflow) - FastQ -> Compute quality statistics -> Draw quality score boxplot - FastQ -> Map with Bowtie for Illumina -> SAM -> BAM -> ReorderSam -> Samtools markdup - [Bowtie2 Algorithm](https://ithelp.ithome.com.tw/articles/10221594) - GATK: https://hackmd.io/XtsPHvS1RC25IlS6K2AcNA?both - Mapping > Map with BWA-MEM - Picard > SortSam - Picard > MarkDuplicates - - 流程的分享:[Tuxedo](https://usegalaxy.org/u/setempler/w/degtuxedo2-2conditions-1replicate) - 自製工具的整合 - 自行架設 Galaxy - 成為 admin - 安裝常用工具 - 高通量定序研究 - 序列比對工具:Bowtie2 - download hg19 fa - 上傳 dataset - [Learn Galaxy](https://galaxyproject.org/learn/)