Parsing output file

Modules for processing of configuration files, for processing of output files and results, which are generated by f90 programs.

Import libs:

from bpf90tools.parsers import (
    PParams,
    PPed,
    PVar,
    PSolution
)

file param.txt

object_pp = PParams()
object_pp.parse_file("./foldtest/test1/exm_create_param/param_exm_blup.txt")

The result is in the object_pp.params property:

{
    'DATAFILE': [''],
    'TRAITS': [''],
    'FIELDS_PASSED TO OUTPUT': ['1'],
    'RESIDUAL_VARIANCE': ['0.5492E-01'],
    'EFFECT': ['8 cross alpha', '10 cov', '1 cross alpha'],
    'RANDOM': ['animal'],
    'FILE': [''],
    'FILE_POS': ['1 2 3 0 0'],
    '(CO)VARIANCES': ['0'],
    'OPTION': ['sol se', 'alpha_size 40', 'fact_once memory', 'use_yams']
}

renaddxx.ped

Parsing a pedigree file - renaddxx.ped. The test file renadd04.ped is used for the example. Contents:

1 6 4 2000 0 2 1 0 0 ID015
12 0 0 1000 0 0 0 0 2 ID004
10 0 0 1000 0 0 0 0 1 ID005
15 0 0 1000 0 0 0 0 1 ID006
2 11 10 2000 0 2 1 2 0 ID007
3 13 12 2000 0 2 1 0 1 ID008
4 2 15 2000 0 2 1 0 2 ID010
5 11 14 2000 0 2 1 1 0 ID009
6 2 12 2000 0 2 1 3 0 ID011
7 6 3 2000 0 2 1 0 0 ID012
13 0 0 1000 0 0 0 1 0 ID001
8 6 4 2000 0 2 1 0 1 ID013
11 0 0 1000 0 0 0 2 0 ID002
9 5 8 2133 0 2 1 0 0 ID014
14 0 0 1000 0 0 0 0 1 ID003

Parsing:

object_pped = PPed()
object_pped.parse_file("./foldtest/test1/renadd04.ped")

The result is in the object_pp.params property:

   nomer     ID
0      1  ID015
1     12  ID004
2     10  ID005
3     15  ID006
4      2  ID007
5      3  ID008
6      4  ID010
7      5  ID009
8      6  ID011
9      7  ID012
10    13  ID001
11     8  ID013
12    11  ID002
13     9  ID014
14    14  ID003

aireml.log

Parsing a file with the variants aireml.log. File Contents airemlf90.log:

AIREMLF90 ver. 1.149
 In round         36 convergence =  0.712257048487E-03
 delta convergence =  0.994040299577E-06
-2logL =       0.24653657     : AIC =        4.2465366
Genetic variance(s) for effect  4
  0.71609E-04
Residual variance(s)
  0.41366
inverse of AI matrix (Sampling Variance)
  0.13285E-05 -0.48971E-06
 -0.48971E-06  0.11398
Correlations from inverse of AI matrix
   1.0000     -0.12585E-02
 -0.12585E-02   1.0000
SE for G
  0.11526E-02
SE for R
  0.33761

Parsing:

object_pvar = PVar()
object_pvar.parse_file("./foldtest/test1/airemlf90.log")

var = object_pvar.values
print(var.model_dump())

Result:

{
    'varG': 7.1609e-05,
    'varE': 0.41366,
    'aic': 4.2465366,
    'bic': 0.24653657,
    'heritability': 0.0
}

reml.log

Parsing a file with the variants reml.log. File Contents remlf90.log:

REMLF90 ver. 1.86
 Final Estimates
Genetic variance(s) for effect  4
  0.9417E-04
Residual variance(s)
  0.9420
 In round       4148 convergence =  0.996781495046E-10
-2logL =        1.4856567       AIC =        5.4856567

Parsing:

object_pvar = PVar()
object_pvar.parse_file("./foldtest/test1/remlf90.log")

var = object_pvar.values
print(var.model_dump())

Result:

{
    'varG': 9.417e-05,
    'varE': 0.942,
    'aic': 5.4856567,
    'bic': 1.4856567,
    'heritability': 0.0
}

solutions

Parsing a file with results obtained after blupf90 - solutions:

Contents solutions:

trait/effect level  solution
   1   1         1         -6.70995918
   1   1         2         -6.53072476
   1   2         1         -6.89090070
   1   2         2         -6.08694268
   1   2         3         -7.12763698
   1   2         4         -6.68739576
   1   3         1         22.97079761
   1   4         1          0.11711553
   1   4         2          0.14987163
   1   4         3         -0.06287934
   1   4         4          0.10684377
   1   4         5         -0.06593335
   1   4         6         -0.01102797
   1   4         7          0.13297009
   1   4         8          0.03384761
   1   4         9          0.01032430
   1   4        10          0.08872265
   1   4        11          0.03357531
   1   4        12         -0.06975455
   1   4        13         -0.01866804
   1   4        14         -0.05514734
   1   4        15          0.02127197

Parsing:

object_psol = PSolution()
object_psol.parse_file("./foldtest/test1/solutions")
print(object_psol.solutions)

Result:

         EBV level
0   0.117116     1
1   0.149872     2
2  -0.062879     3
3   0.106844     4
4  -0.065933     5
5  -0.011028     6
6   0.132970     7
7   0.033848     8
8   0.010324     9
9   0.088723    10
10  0.033575    11
11 -0.069755    12
12 -0.018668    13
13 -0.055147    14
14  0.021272    15

without varg

Contents file solutions:

trait/effect level  solution          s.e.
   1   1         1         -0.21337720          0.47468396
   1   1         2          0.00000000          0.00000000
   1   2         1        -12.45754690         22.12147091
   1   2         2        -11.60488568         21.96909516
   1   2         3        -12.63970827         22.99779542
   1   2         4        -12.25754758         22.12147643
   1   3         1         22.05395473         21.91343740
   1   4         1          0.00005158          0.00897511
   1   4         2          0.00005618          0.00846196
   1   4         3         -0.00002650          0.00846193
   1   4         4          0.00004680          0.00846186
   1   4         5         -0.00002956          0.00846189
   1   4         6          0.00000149          0.00846216
   1   4         7          0.00003811          0.00897534
   1   4         8          0.00001997          0.00897535
   1   4         9          0.00000303          0.00872283
   1   4        10          0.00003390          0.00846213
   1   4        11          0.00001065          0.00846213
   1   4        12         -0.00002415          0.00846214
   1   4        13         -0.00000962          0.00846214
   1   4        14         -0.00002326          0.00846211
   1   4        15          0.00001248          0.00846213

Parsing:

object_psol = PSolution(varg=None)
object_psol.parse_file("./foldtest/test1/solutions")
print(object_psol.solutions)

Result:

         EBV        SE level
0   0.000052  0.008975     1
1   0.000056  0.008462     2
2  -0.000027  0.008462     3
3   0.000047  0.008462     4
4  -0.000030  0.008462     5
5   0.000001  0.008462     6
6   0.000038  0.008975     7
7   0.000020  0.008975     8
8   0.000003  0.008723     9
9   0.000034  0.008462    10
10  0.000011  0.008462    11
11 -0.000024  0.008462    12
12 -0.000010  0.008462    13
13 -0.000023  0.008462    14
14  0.000012  0.008462    15

Note

If the genetic variant is not passed on, then ebv reliability (REL) is not calculated when processing the result. This leaves s.e. .

with varg

Parsing:

object_psol = PSolution(varg=float('0.71609E-04'))
object_psol.parse_file("./foldtest/test1/solutions")
print(object_psol.solutions)

Result:

         EBV  REL level
0   0.000052    0     1
1   0.000056    0     2
2  -0.000027    0     3
3   0.000047    0     4
4  -0.000030    0     5
5   0.000001    0     6
6   0.000038    0     7
7   0.000020    0     8
8   0.000003    0     9
9   0.000034    0    10
10  0.000011    0    11
11 -0.000024    0    12
12 -0.000010    0    13
13 -0.000023    0    14
14  0.000012    0    15