Skip to content

Commit

Permalink
🎨🐍 Fix deprecated pandas method invocation (#279)
Browse files Browse the repository at this point in the history
Update bedtools column summation to prevent FutureWarning message

```text
/home/evan/miniconda3/envs/autometa/lib/python3.9/site-packages/autometa/common/external/bedtools.py:107: FutureWarning: Indexing with multiple keys (implicitly converted to a tuple of keys) will be deprecated, use a list instead.
  dff = df.groupby(contig)[depth_product, bases].sum()
```

Now explicitly passes list, e.g. `dff = df.groupby(contig)[["depth_product", "bases"]].sum()`
  • Loading branch information
evanroyrees authored Jun 9, 2022
1 parent 86b9550 commit e500caa
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion autometa/common/external/bedtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def parse(bed: str, out: str = None, force: bool = False) -> pd.DataFrame:
df = pd.read_csv(bed, sep="\t", names=names, index_col="contig")
df = df[df.index != "genome"]
df = df.assign(depth_product=lambda x: x.depth * x.bases)
dff = df.groupby("contig")["depth_product", "bases"].sum()
dff = df.groupby("contig")[["depth_product", "bases"]].sum()
dff = dff.assign(coverage=lambda x: x.depth_product / x.bases)
if out and (not os.path.exists(out) or (os.path.exists(out) and force)):
dff.to_csv(out, sep="\t", index=True, header=True)
Expand Down

0 comments on commit e500caa

Please sign in to comment.