Skip to content

Instantly share code, notes, and snippets.

View christiaanjs's full-sized avatar

Christiaan Swanepoel christiaanjs

  • Auckland, New Zealand
View GitHub Profile
@christiaanjs
christiaanjs / coalescent-softsort.ipynb
Created October 12, 2021 04:14
Relaxing the coalescent with SoftSort
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@christiaanjs
christiaanjs / tf-likelihood-test.ipynb
Last active May 14, 2020 09:33
Making Tensorflow likelihood gradients work in function mode
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@christiaanjs
christiaanjs / phylo-model.py
Created January 29, 2020 00:48
Phylo model
model = tfd.JointDistributionNamed(dict(
frequencies=tfd.Dirichlet(concentration=[4,4,4,4]),
kappa=tfd.LogNormal(loc=0, scale=1),
pop_size=tfd.LogNormal(loc=0, scale=1),
tree=lambda pop_size: treeflow.coalescent.ConstantCoalescent(pop_size=pop_size, sampling_times=sampling_times),
sequences=lambda tree, kappa, frequencies: treeflow.sequences.PhyloCTMC(tree=tree, q=HKY(frequencies=frequencies, kappa=kappa))
))
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@christiaanjs
christiaanjs / bijectors.ipynb
Created September 18, 2019 23:47
Truncated Lognormal distribution in Tensorflow Probability
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@christiaanjs
christiaanjs / skygrid-test.ipynb
Last active July 27, 2019 00:55
Skygrid + Beagle test
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from xml.etree import ElementTree
data_xml_filename = '311spp_5genes.xml'
xml_root = ElementTree.parse(data_xml_filename)
flat_dict = [{ 'alignment': alignment.attrib['id'], 'taxon': sequence.find('taxon').attrib['idref'], 'sequence': sequence.find('taxon').tail.strip() } for alignment in xml_root.findall('alignment') for sequence in alignment.findall('sequence') ]
taxa_dict = { taxon: { value['alignment']: value['sequence'] for value in values } for taxon, values in groupby(sorted(flat_dict, key=key_func), key=key_func) }
print(taxa_dict)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@christiaanjs
christiaanjs / distribution-test.ipynb
Created November 22, 2018 19:53
Bootstrap multivariate two-sample test for distribution
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.