Skip to content

Commit

Permalink
Group before aggregate
Browse files Browse the repository at this point in the history
  • Loading branch information
marlinfiggins committed Nov 8, 2024
1 parent ed301ff commit 6f85c6f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions evofr/data/hier_frequencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ def __init__(
self.var_names = format_var_names(raw_var_names, pivot=pivot)
self.pivot = self.var_names[-1]

# Loop each group
grouped = raw_seq.groupby(group)
self.names = [name for name, _ in grouped]
self.groups = [
VariantFrequencies(group, self.date_to_index, self.var_names)
for _, group in grouped
]

# Aggregate counts into larger windows
self.aggregation_frequency = aggregation_frequency
if self.aggregation_frequency is not None:
Expand All @@ -68,14 +76,6 @@ def __init__(
self.groups, self.dates, self.aggregation_frequency
)

# Loop each group
grouped = raw_seq.groupby(group)
self.names = [name for name, _ in grouped]
self.groups = [
VariantFrequencies(group, self.date_to_index, self.var_names)
for _, group in grouped
]

self.seq_counts = np.stack([g.seq_counts for g in self.groups], axis=-1)

def make_data_dict(self, data: Optional[dict] = None) -> dict:
Expand Down

0 comments on commit 6f85c6f

Please sign in to comment.