xavierdidelot / TransPhylo

Reconstruction of transmission trees using genomic data
http://xavierdidelot.github.io/TransPhylo/
GNU General Public License v2.0
60 stars 22 forks source link

Adding priors and/or postprocessing #27

Closed sapoudel closed 1 year ago

sapoudel commented 1 year ago

Hello, Do you have any suggestions on how to pass priors to TransPhylo? Something that can capture other information such as the geographic locations of the cases and penalize creating links between geographically separated cases, etc. Or is this something we can do in postprocessing e.g. take multiple possible transmission trees and choose ones that minimize our other constraints?

Thanks!

xavierdidelot commented 1 year ago

Hi Saugat,

You could try to postprocess the transmission trees using importance sampling, which has the advantage that you would run TransPhylo without any modification. For each tree you would compute the weight which is equal to the prior you want to give divided by the prior in TransPhylo, available in log value via res[[i]]$pTTree. This should work well as long as the two prior models don't disagree too much, otherwise you will end up with a low effective sample size, which you can compute as (sum of weights)^2/(sum of (weights^2)).

Otherwise you would need to edit the code of TransPhylo, specifically the file src/probTTree.cpp to include your prior.

Best wishes, Xavier