- Biopython 教程
- Biopython - 首頁
- Biopython - 簡介
- Biopython - 安裝
- 建立簡單的應用程式
- Biopython - 序列
- 高階序列操作
- 序列 I/O 操作
- Biopython - 序列比對
- Biopython - BLAST 概述
- Biopython - Entrez 資料庫
- Biopython - PDB 模組
- Biopython - 基序物件
- Biopython - BioSQL 模組
- Biopython - 群體遺傳學
- Biopython - 基因組分析
- Biopython - 表型微陣列
- Biopython - 繪圖
- Biopython - 聚類分析
- Biopython - 機器學習
- Biopython - 測試技術
- Biopython 資源
- Biopython - 快速指南
- Biopython - 有用資源
- Biopython - 討論
Biopython - 表型微陣列
表型是指生物體針對特定化學物質或環境表現出的可觀察到的性狀或特徵。表型微陣列同時測量生物體對大量化學物質和環境的反應,並分析資料以瞭解基因突變、基因特徵等。
Biopython 提供了一個優秀的模組 Bio.Phenotype 來分析表型資料。本章我們將學習如何解析、插值、提取和分析表型微陣列資料。
解析
表型微陣列資料可以有兩種格式:CSV 和 JSON。Biopython 支援這兩種格式。Biopython 解析器解析表型微陣列資料,並將其返回為 PlateRecord 物件的集合。每個 PlateRecord 物件包含一組 WellRecord 物件。每個 WellRecord 物件的資料格式為 8 行 12 列。8 行用 A 到 H 表示,12 列用 01 到 12 表示。例如,第 4 行第 6 列用 D06 表示。
讓我們透過以下示例瞭解解析的格式和概念:
步驟 1 - 下載 Biopython 團隊提供的 Plates.csv 檔案 - https://raw.githubusercontent.com/biopython/biopython/master/Doc/examples/Plates.csv
步驟 2 - 如下載入 phenotype 模組:
>>> from Bio import phenotype
步驟 3 - 呼叫 phenotype.parse 方法,傳入資料檔案和格式選項(“pm-csv”)。它返回可迭代的 PlateRecord,如下所示:
>>> plates = list(phenotype.parse('Plates.csv', "pm-csv"))
>>> plates
[PlateRecord('WellRecord['A01'], WellRecord['A02'], WellRecord['A03'], ..., WellRecord['H12']'),
PlateRecord('WellRecord['A01'], WellRecord['A02'], WellRecord['A03'], ..., WellRecord['H12']'),
PlateRecord('WellRecord['A01'], WellRecord['A02'], WellRecord['A03'], ..., WellRecord['H12']'),
PlateRecord('WellRecord['A01'], WellRecord['A02'],WellRecord['A03'], ..., WellRecord['H12']')]
>>>
步驟 4 - 從列表中訪問第一個平板,如下所示:
>>> plate = plates[0]
>>> plate
PlateRecord('WellRecord['A01'], WellRecord['A02'], WellRecord['A03'], ...,
WellRecord['H12']')
>>>
步驟 5 - 如前所述,一個平板包含 8 行,每行有 12 個專案。WellRecord 可以透過兩種方式訪問,如下所示:
>>> well = plate["A04"]
>>> well = plate[0, 4]
>>> well WellRecord('(0.0, 0.0), (0.25, 0.0), (0.5, 0.0), (0.75, 0.0),
(1.0, 0.0), ..., (71.75, 388.0)')
>>>
步驟 6 - 每個孔在不同的時間點都會有一系列測量值,可以使用 for 迴圈訪問,如下所示:
>>> for v1, v2 in well: ... print(v1, v2) ... 0.0 0.0 0.25 0.0 0.5 0.0 0.75 0.0 1.0 0.0 ... 71.25 388.0 71.5 388.0 71.75 388.0 >>>
插值
插值可以更深入地瞭解資料。Biopython 提供了插值 WellRecord 資料的方法,以獲取中間時間點的資訊。語法類似於列表索引,因此易於學習。
要獲取 20.1 小時的資料,只需將索引值傳遞如下:
>>> well[20.10] 69.40000000000003 >>>
我們也可以傳遞開始時間點和結束時間點,如下所示:
>>> well[20:30] [67.0, 84.0, 102.0, 119.0, 135.0, 147.0, 158.0, 168.0, 179.0, 186.0] >>>
上述命令以 1 小時的時間間隔插值 20 小時到 30 小時的資料。預設情況下,間隔為 1 小時,我們可以將其更改為任何值。例如,讓我們將間隔設定為 15 分鐘(0.25 小時),如下所示:
>>> well[20:21:0.25] [67.0, 73.0, 75.0, 81.0] >>>
分析和提取
Biopython 提供了一個 fit 方法,可以使用 Gompertz、Logistic 和 Richards sigmoid 函式分析 WellRecord 資料。預設情況下,fit 方法使用 Gompertz 函式。我們需要呼叫 WellRecord 物件的 fit 方法來完成任務。程式碼如下:
>>> well.fit() Traceback (most recent call last): ... Bio.MissingPythonDependencyError: Install scipy to extract curve parameters. >>> well.model >>> getattr(well, 'min') 0.0 >>> getattr(well, 'max') 388.0 >>> getattr(well, 'average_height') 205.42708333333334 >>>
Biopython 依賴於 scipy 模組進行高階分析。它將在不使用 scipy 模組的情況下計算 min、max 和 average_height 的詳細資訊。