Biopython 表型微阵列


表型被定义为生物体针对特定化学物质或环境表现出的可观察到的特征或特征。表型微阵列同时测量生物体对大量化学物质和环境的反应,并分析数据以了解基因突变、基因特征等。

Biopython 提供了一个出色的模块 Bio.Phenotype 来分析表型数据。让我们在本章中学习如何解析、插值、提取和分析表型微阵列数据。

Parsing


表型微阵列数据可以有两种格式:CSV 和 JSON。 Biopython 支持这两种格式。 Biopython 解析器解析表型微阵列数据并作为 PlateRecord 对象的集合返回。每个 PlateRecord 对象都包含一组 WellRecord 对象。每个 WellRecord 对象以 8 行 12 列的格式保存数据。 8 行用 A 到 H 表示,12 列用 01 到 12 表示。例如,4 th 行和 6 th 列由 D06 表示。

让我们通过下面的例子来理解解析的格式和概念:

步骤 1 :下载Biopython团队提供的Plates.csv文件: https://raw.githubusercontent.com/biopython/biopython/master/Doc/examples/Plates.csv

步骤 2 : 加载 phenotpe 模块如下:

>>> 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[20Biopython 依赖 scipy 模块进行高级分析。它将在不使用 scipy 模块的情况下计算 min、max 和 average_height 细节。0.25] 
[67.0, 73.0, 75.0, 81.0]
>>>

分析和提取


Biopython 提供了一种适合使用 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 细节。