Skip to content

Instantly share code, notes, and snippets.

@sminot
Created June 26, 2020 15:00
Show Gist options
  • Select an option

  • Save sminot/735e29e99a401eeab8efd5c71a08cebf to your computer and use it in GitHub Desktop.

Select an option

Save sminot/735e29e99a401eeab8efd5c71a08cebf to your computer and use it in GitHub Desktop.
Plot specimen summary from geneshot results HDF5
# 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