dynast.preprocessing.aggregation

Module Contents

Functions

read_rates(rates_path: str) → pandas.DataFrame

Read mutation rates CSV as a pandas dataframe.

read_aggregates(aggregates_path: str) → pandas.DataFrame

Read aggregates CSV as a pandas dataframe.

merge_aggregates(*dfs: pandas.DataFrame) → pandas.DataFrame

Merge multiple aggregate dataframes into one.

calculate_mutation_rates(df_counts: pandas.DataFrame, rates_path: str, group_by: Optional[List[str]] = None) → str

Calculate mutation rate for each pair of bases.

aggregate_counts(df_counts: pandas.DataFrame, aggregates_path: str, conversions: FrozenSet[str] = frozenset({'TC'})) → str

Aggregate conversion counts for each pair of bases.

dynast.preprocessing.aggregation.read_rates(rates_path: str) pandas.DataFrame[source]

Read mutation rates CSV as a pandas dataframe.

Parameters
rates_path

Path to rates CSV

Returns

Rates dataframe

dynast.preprocessing.aggregation.read_aggregates(aggregates_path: str) pandas.DataFrame[source]

Read aggregates CSV as a pandas dataframe.

Parameters
aggregates_path

Path to aggregates CSV

Returns

Aggregates dataframe

dynast.preprocessing.aggregation.merge_aggregates(*dfs: pandas.DataFrame) pandas.DataFrame[source]

Merge multiple aggregate dataframes into one.

Parameters
dfs

Dataframes to merge

Returns

Merged dataframe

dynast.preprocessing.aggregation.calculate_mutation_rates(df_counts: pandas.DataFrame, rates_path: str, group_by: Optional[List[str]] = None) str[source]

Calculate mutation rate for each pair of bases.

Parameters
df_counts

Counts dataframe, with complemented reverse strand bases

rates_path

Path to write rates CSV

group_by

Column(s) to group calculations by, defaults to None, which combines all rows

Returns

Path to rates CSV

dynast.preprocessing.aggregation.aggregate_counts(df_counts: pandas.DataFrame, aggregates_path: str, conversions: FrozenSet[str] = frozenset({'TC'})) str[source]

Aggregate conversion counts for each pair of bases.

Parameters
df_counts

Counts dataframe, with complemented reverse strand bases

aggregates_path

Path to write aggregate CSV

conversions

Conversion(s) in question

Returns

Path to aggregate CSV that was written