Skip to content

Commit

Permalink
removing the other plots
Browse files Browse the repository at this point in the history
  • Loading branch information
gordonkoehn committed Sep 13, 2024
1 parent f8be698 commit 4e7bf2c
Showing 1 changed file with 23 additions and 41 deletions.
64 changes: 23 additions & 41 deletions scripts/amplicon_covs_click.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,10 @@ def make_cov_heatmap(cov_df, output=None):

def make_median_cov_hist(cov_df, output=None):
"""Make histogram of median coverage."""
click.echo("Computing median coverage histogram")

try:
click.echo("Computing median coverage - what the heck is this?")
median = np.nanmedian(cov_df.iloc[:, 1:].values, axis=0)
except Exception as e:
click.echo(f"Error computing median coverage: {str(e)}")
return
# FIXME (gordonkoehn):
# median computation causes performance a crash for test data
median = np.nanmedian(cov_df.iloc[:, 1:].values, axis=0)

plt.figure(figsize=(12, 6))
sns.histplot(y=median, binwidth=0.002, stat="density")
plt.title("Median coverage histogram")
Expand All @@ -220,7 +216,6 @@ def make_median_cov_hist(cov_df, output=None):

if output is not None:
plt.savefig(output)
click.echo(f"Saved histogram to {output}")


def make_median_coverage_barplot(cov_df, output=None):
Expand Down Expand Up @@ -341,38 +336,25 @@ def main(

make_cov_heatmap(all_covs, os.path.join(outdir, "cov_heatmap.pdf"))

try:
make_median_cov_hist(all_covs, os.path.join(outdir, "median_cov_hist.pdf"))
except Exception as e:
click.echo(f"Error generating median_cov_hist plot: {str(e)}")

try:
make_median_coverage_barplot(
all_covs, os.path.join(outdir, "median_coverage_barplot.pdf")
)
except Exception as e:
click.echo(f"Error generating median_coverage_barplot plot: {str(e)}")

try:
make_cov_heatmap(
all_covs_frac, os.path.join(outdir, "cov_heatmap_norm.pdf")
)
except Exception as e:
click.echo(f"Error generating cov_heatmap_norm plot: {str(e)}")

try:
make_median_cov_hist(
all_covs_frac, os.path.join(outdir, "median_cov_hist_norm.pdf")
)
except Exception as e:
click.echo(f"Error generating median_cov_hist_norm plot: {str(e)}")

try:
make_median_coverage_barplot(
all_covs_frac, os.path.join(outdir, "median_coverage_barplot_norm.pdf")
)
except Exception as e:
click.echo(f"Error generating median_coverage_barplot_norm plot: {str(e)}")
# TODO (gordonkoehn):
# Clarify the purpose of these plots, and if they are still needed.
#
# make_median_cov_hist(
# all_covs, os.path.join(outdir, "median_cov_hist.pdf")
# )
# make_median_coverage_barplot(
# all_covs, os.path.join(outdir, "median_coverage_barplot.pdf")
# )
# make_cov_heatmap(
# all_covs_frac, os.path.join(outdir, "cov_heatmap_norm.pdf")
# )
# make_median_cov_hist(
# all_covs_frac, os.path.join(outdir, "median_cov_hist_norm.pdf")
# )

# make_median_coverage_barplot(
# all_covs_frac, os.path.join(outdir, "median_coverage_barplot_norm.pdf")
# )


if __name__ == "__main__":
Expand Down

0 comments on commit 4e7bf2c

Please sign in to comment.