PoonLab / twt

Generic framework for the coalescent simulation of pathogen trees within host trees in R
GNU Affero General Public License v3.0
3 stars 2 forks source link

Error when calling load.outer.tree() #118

Closed davidchampredon closed 4 years ago

davidchampredon commented 4 years ago

Here's the MRE with the YAML file at the bottom. I think my YAML file has a problem, but can't see where (if the error msg could give a hint that would be great), please help... thanks!

library(twt)
settings <- yaml.load_file('../data/sampled-hosts-1.yaml')
m   <- Model$new(settings)
run <- load.outer.tree(m)

Returns:

Error: object of type 'closure' is not subsettable
Called from: eventlog$add.event(type = "transmission", time = branching.time, 
    line1 = NA, line2 = NA, comp1 = comp$get.name(), comp2 = source$get.name(), 
    type1 = comp$get.type()$get.name(), type2 = source$get.type()$get.name())

YAML file used:

InitialConditions:
  originTime: 3493
  size:
    host: 560
  indexType: 'host'

CompartmentTypes:
  'host':
    migration.rates: ()
    transition.rates: ()
    branching.rates: (host=1e-06)
    effective.size: 100
    generation.time: 1
    bottleneck.size: 1
    wait.time.distr:
      distr: 'exp'
      hyperparameters:
        - rate: 0.001
    popn.growth.dynamics:
      piece1:
        - startTime: 0
        - startPopn: 1
        - endTime: 5
        - endPopn: 20
      piece2:
        - startTime: 5
        - startPopn: 10

Compartments:
  'ID18':
    type: host
    source: 'ID73'
    branching.time: 2987
    unsampled: TRUE
  'ID277':
    type: host
    source: 'ID18'
    branching.time: 2982
    unsampled: TRUE
  'ID165':
    type: host
    source: 'ID18'
    branching.time: 2561
    unsampled: TRUE
  'ID221':
    type: host
    source: 'ID277'
    branching.time: 2556
    replicates: 1
  'ID190':
    type: host
    source: 'ID221'
    branching.time: 2129
    replicates: 1
  'ID105':
    type: host
    source: 'ID18'
    branching.time: 1564
    replicates: 1
  'ID188':
    type: host
    source: 'ID105'
    branching.time: 1553
    replicates: 1
  'ID406':
    type: host
    source: 'ID105'
    branching.time: 1549
    replicates: 1
  'ID192':
    type: host
    source: 'ID188'
    branching.time: 1542
    unsampled: TRUE
  'ID97':
    type: host
    source: 'ID188'
    branching.time: 1540
    unsampled: TRUE
  'ID207':
    type: host
    source: 'ID192'
    branching.time: 1534
    replicates: 1
  'ID399':
    type: host
    source: 'ID221'
    branching.time: 1532
    unsampled: TRUE
  'ID56':
    type: host
    source: 'ID192'
    branching.time: 1524
    replicates: 1
  'ID57':
    type: host
    source: 'ID56'
    branching.time: 1519
    unsampled: TRUE
  'ID218':
    type: host
    source: 'ID57'
    branching.time: 1511
    unsampled: TRUE
  'ID228':
    type: host
    source: 'ID218'
    branching.time: 1508
    replicates: 1
  'ID335':
    type: host
    source: 'ID218'
    branching.time: 1508
    unsampled: TRUE
  'ID149':
    type: host
    source: 'ID57'
    branching.time: 1505
    replicates: 1
  'ID235':
    type: host
    source: 'ID218'
    branching.time: 1504
    unsampled: TRUE
  'ID281':
    type: host
    source: 'ID235'
    branching.time: 1488
    unsampled: TRUE
  'ID288':
    type: host
    source: 'ID281'
    branching.time: 1478
    unsampled: TRUE
  'ID233':
    type: host
    source: 'ID288'
    branching.time: 1474
    unsampled: TRUE
  'ID152':
    type: host
    source: 'ID288'
    branching.time: 1459
    unsampled: TRUE
  'ID260':
    type: host
    source: 'ID288'
    branching.time: 1448
    unsampled: TRUE
  'ID418':
    type: host
    source: 'ID260'
    branching.time: 1436
    unsampled: TRUE
  'ID84':
    type: host
    source: 'ID105'
    branching.time: 1414
    unsampled: TRUE
  'ID237':
    type: host
    source: 'ID406'
    branching.time: 1319
    unsampled: TRUE
  'ID1':
    type: host
    source: 'ID233'
    branching.time: 1271
    replicates: 1
  'ID212':
    type: host
    source: 'ID277'
    branching.time: 1249
    unsampled: TRUE
  'ID463':
    type: host
    source: 'ID84'
    branching.time: 1229
    replicates: 1
  'ID389':
    type: host
    source: 'ID56'
    branching.time: 1227
    replicates: 1
  'ID93':
    type: host
    source: 'ID212'
    branching.time: 969
    unsampled: TRUE
  'ID372':
    type: host
    source: 'ID463'
    branching.time: 963
    unsampled: TRUE
  'ID214':
    type: host
    source: 'ID372'
    branching.time: 958
    unsampled: TRUE
  'ID474':
    type: host
    source: 'ID372'
    branching.time: 952
    unsampled: TRUE
  'ID295':
    type: host
    source: 'ID212'
    branching.time: 766
    unsampled: TRUE
  'ID100':
    type: host
    source: 'ID295'
    branching.time: 759
    unsampled: TRUE
  'ID21':
    type: host
    source: 'ID295'
    branching.time: 748
    replicates: 1
  'ID225':
    type: host
    source: 'ID295'
    branching.time: 742
    unsampled: TRUE
  'ID529':
    type: host
    source: 'ID474'
    branching.time: 593
    unsampled: TRUE
  'ID210':
    type: host
    source: 'ID73'
    branching.time: 592
    replicates: 1
  'ID426':
    type: host
    source: 'ID335'
    branching.time: 569
    replicates: 1
  'ID183':
    type: host
    source: 'ID277'
    branching.time: 528
    unsampled: TRUE
  'ID316':
    type: host
    source: 'ID183'
    branching.time: 519
    replicates: 1
  'ID61':
    type: host
    source: 'ID192'
    branching.time: 509
    unsampled: TRUE
  'ID553':
    type: host
    source: 'ID426'
    branching.time: 505
    replicates: 1
  'ID102':
    type: host
    source: 'ID57'
    branching.time: 415
    unsampled: TRUE
  'ID229':
    type: host
    source: 'ID102'
    branching.time: 410
    unsampled: TRUE
  'ID274':
    type: host
    source: 'ID229'
    branching.time: 401
    replicates: 1
  'ID191':
    type: host
    source: 'ID229'
    branching.time: 397
    unsampled: TRUE
  'ID104':
    type: host
    source: 'ID210'
    branching.time: 367
    unsampled: TRUE
  'ID430':
    type: host
    source: 'ID235'
    branching.time: 344
    replicates: 1
  'ID113':
    type: host
    source: 'ID57'
    branching.time: 337
    unsampled: TRUE
  'ID117':
    type: host
    source: 'ID430'
    branching.time: 325
    unsampled: TRUE
  'ID337':
    type: host
    source: 'ID152'
    branching.time: 279
    replicates: 1
  'ID33':
    type: host
    source: 'ID152'
    branching.time: 125
    unsampled: TRUE
  'ID560':
    type: host
    source: 'ID529'
    branching.time: 77
    unsampled: TRUE

Lineages:
  '1':
    type: virus
    sampling.time: 1263
    location: ID221
    replicates: 1
  '2':
    type: virus
    sampling.time: 483
    location: ID190
    replicates: 1
  '3':
    type: virus
    sampling.time: 1280
    location: ID105
    replicates: 1
  '4':
    type: virus
    sampling.time: 183
    location: ID188
    replicates: 1
  '5':
    type: virus
    sampling.time: 156
    location: ID406
    replicates: 1
  '6':
    type: virus
    sampling.time: 1467
    location: ID207
    replicates: 1
  '7':
    type: virus
    sampling.time: 1021
    location: ID56
    replicates: 1
  '8':
    type: virus
    sampling.time: 1486
    location: ID228
    replicates: 1
  '9':
    type: virus
    sampling.time: 1130
    location: ID149
    replicates: 1
  '10':
    type: virus
    sampling.time: 329
    location: ID1
    replicates: 1
  '11':
    type: virus
    sampling.time: 831
    location: ID463
    replicates: 1
  '12':
    type: virus
    sampling.time: 571
    location: ID389
    replicates: 1
  '13':
    type: virus
    sampling.time: 706
    location: ID21
    replicates: 1
  '14':
    type: virus
    sampling.time: 223
    location: ID210
    replicates: 1
  '15':
    type: virus
    sampling.time: 492
    location: ID426
    replicates: 1
  '16':
    type: virus
    sampling.time: 0
    location: ID316
    replicates: 1
  '17':
    type: virus
    sampling.time: 497
    location: ID553
    replicates: 1
  '18':
    type: virus
    sampling.time: 38
    location: ID274
    replicates: 1
  '19':
    type: virus
    sampling.time: 307
    location: ID430
    replicates: 1
  '20':
    type: virus
    sampling.time: 102
    location: ID337
    replicates: 1
ArtPoon commented 4 years ago

Thanks for the error report @davidchampredon The problem is that you have specified ID73 as the source of ID18_1 without declaring ID73 as a Compartment. load.outer.tree now reports this as an error in commit fcc349c