Created
June 26, 2020 15:00
-
-
Save sminot/735e29e99a401eeab8efd5c71a08cebf to your computer and use it in GitHub Desktop.
Plot specimen summary from geneshot results HDF5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Plot the number of genes detected and the proportion of reads aligned | |
| def plot_specimen_summary(hdf_fp, pdf=None, alpha = 0.85): | |
| specimen_summary = pd.read_hdf(hdf_fp, "/summary/all").set_index("specimen") | |
| specimen_summary = specimen_summary.assign( | |
| prop_reads = specimen_summary["aligned_reads"] / specimen_summary["n_reads"] | |
| ) | |
| for col_name, axis_title in [ | |
| ("n_genes_assembled", "Number of genes detected by assembly"), | |
| ("n_genes_aligned", "Number of genes detected by alignment"), | |
| ("prop_reads", "Proportion of reads aligned"), | |
| ]: | |
| g = sns.scatterplot( | |
| data=specimen_summary, | |
| x = "n_reads", | |
| y = col_name, | |
| linewidth = 0, | |
| alpha = alpha | |
| ) | |
| if col_name == "prop_reads": | |
| plt.ylim(0, 1) | |
| else: | |
| plt.ylim(0, ) | |
| plt.xlim(0, ) | |
| plt.ylabel(axis_title) | |
| plt.xlabel("Number of reads") | |
| if pdf is not None: | |
| pdf.savefig(bbox_inches="tight") | |
| plt.show() | |
| plot_specimen_summary(hdf_fp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment