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

Fix NA issues after Pandas update #361

Merged
merged 4 commits into from
Jun 14, 2024
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
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.2
2.2.3
12 changes: 10 additions & 2 deletions autometa/binning/recursive_dbscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ def recursive_dbscan(
coverage_stddev_cutoff=coverage_stddev_cutoff,
gc_content_stddev_cutoff=gc_content_stddev_cutoff,
)
median_completeness = filtered_df.completeness.median()
if filtered_df.empty:
median_completeness = float("-inf")
else:
median_completeness = filtered_df.completeness.median()

if median_completeness >= best_median:
best_median = median_completeness
best_df = df
Expand Down Expand Up @@ -379,7 +383,11 @@ def recursive_hdbscan(
coverage_stddev_cutoff=coverage_stddev_cutoff,
gc_content_stddev_cutoff=gc_content_stddev_cutoff,
)
median_completeness = filtered_df.completeness.median()
if filtered_df.empty:
median_completeness = float("-inf")
else:
median_completeness = filtered_df.completeness.median()

if median_completeness >= best_median:
best_median = median_completeness
best_df = df
Expand Down
4 changes: 4 additions & 0 deletions autometa/binning/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

import pandas as pd

import numpy as np

from typing import Iterable, Tuple

from autometa.taxonomy.database import TaxonomyDatabase
Expand Down Expand Up @@ -183,7 +185,9 @@ def add_metrics(
# redundant_marker_count = cluster_marker_counts.gt(1).sum(axis=1)
# calculate completeness and purity and std. dev. metrics
completeness = present_marker_count / reference_markers_count * 100
completeness = completeness.where(~np.isnan(completeness),pd.NA)
purity = single_copy_marker_count / present_marker_count * 100
purity = purity.where(~np.isnan(purity), pd.NA)
coverage_stddev = main_grouped_by_cluster.coverage.std()
gc_content_stddev = main_grouped_by_cluster.gc_content.std()
# merge metrics with given dataframe
Expand Down
2 changes: 1 addition & 1 deletion nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ manifest {
doi = "https://doi.org/10.1093/nar/gkz148"
mainScript = "main.nf"
nextflowVersion = ">=21.04.0"
version = "2.2.2"
version = "2.2.3"
}


Expand Down
Loading