Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameterize size of clades to estimate by diffusion frequency likelihood #383

Merged
merged 1 commit into from
Oct 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions augur/frequencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ def register_arguments(parser):
help="tree to estimate clade frequencies for")
parser.add_argument("--include-internal-nodes", action="store_true",
help="calculate frequencies for internal nodes as well as tips")
parser.add_argument('--minimal-clade-size', type=int, default=0,
help="minimal size of a clade to have frequencies estimated")

# Alignment-specific arguments
parser.add_argument('--alignments', type=str, nargs='+',
Expand All @@ -54,6 +52,12 @@ def register_arguments(parser):
parser.add_argument("--censored", action="store_true", help="calculate censored frequencies at each pivot")

# Diffusion frequency specific arguments
parser.add_argument('--minimal-clade-size', type=int, default=0,
help="minimal number of tips a clade must have for its diffusion frequencies to be reported")
parser.add_argument('--minimal-clade-size-to-estimate', type=int, default=10,
help="""minimal number of tips a clade must have for its diffusion frequencies to be estimated
by the diffusion likelihood; all smaller clades will inherit frequencies from their
parents""")
parser.add_argument("--stiffness", type=float, default=10.0, help="parameter penalizing curvature of the frequency trajectory")
parser.add_argument("--inertia", type=float, default=0.0, help="determines how frequencies continue "
"in absense of data (inertia=0 -> go flat, inertia=1.0 -> continue current trend)")
Expand Down Expand Up @@ -116,7 +120,8 @@ def run(args):
tree_freqs = tree_frequencies(tree, pivots, method='SLSQP',
node_filter = node_filter_func,
ws = max(2, tree.count_terminals()//10),
stiffness = stiffness, inertia=inertia)
stiffness = stiffness, inertia=inertia,
min_clades=args.minimal_clade_size_to_estimate)

tree_freqs.estimate_clade_frequencies()

Expand Down
4 changes: 2 additions & 2 deletions augur/frequency_estimators.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ class that estimates frequencies for nodes in the tree. each internal node is as
will be numbered in preorder. Each node is assumed to have an attribute `attr` with a
key "num_date".
'''
def __init__(self, tree, pivots, node_filter=None, min_clades = 20, verbose=0, pc=1e-4, **kwargs):
def __init__(self, tree, pivots, node_filter=None, min_clades=10, verbose=0, pc=1e-4, **kwargs):
'''
set up the internal tree, the pivots and cutoffs

Expand All @@ -458,7 +458,7 @@ def __init__(self, tree, pivots, node_filter=None, min_clades = 20, verbose=0, p
Description
'''
self.tree = tree
self.min_clades = 10 #min_clades
self.min_clades = min_clades
self.pivots = pivots
self.kwargs = kwargs
self.verbose = verbose
Expand Down