Skip to content

Commit

Permalink
fixed seq and tax abundances
Browse files Browse the repository at this point in the history
  • Loading branch information
farchaab committed Oct 9, 2024
1 parent 072d05e commit 5ae2d62
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mess/workflow/rules/processing/reads.smk
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ rule get_tax_profile:
paired=PAIRED,
run:
tax_df = pd.read_csv(input.tax, sep="\t")
tax_df = tax_df[tax_df.samplename == wildcards.sample]
cov_df = pd.read_csv(input.cov, sep="\t")
cov_df.rename(columns={"#rname": "contig"}, inplace=True)
merge_df = tax_df.merge(cov_df)
Expand All @@ -332,9 +333,10 @@ rule get_tax_profile:
for col in ["numreads", "meandepth"]:
if col == "numreads":
out = output.seq_abundance
df = merge_df.groupby("tax_id")[col].sum().reset_index()
elif col == "meandepth":
out = output.tax_abundance
df = merge_df.groupby("tax_id")[col].sum().reset_index()
df = merge_df.groupby("tax_id")[col].mean().reset_index()
df["abundance"] = df[col] / df[col].sum()
df[["tax_id", "abundance"]].to_csv(
out, sep="\t", header=False, index=False
Expand Down

0 comments on commit 5ae2d62

Please sign in to comment.