Skip to content

Instantly share code, notes, and snippets.

@olgabot
Created January 10, 2014 00:08
Show Gist options
  • Save olgabot/8344550 to your computer and use it in GitHub Desktop.
Save olgabot/8344550 to your computer and use it in GitHub Desktop.
pkm = df_tidy[df_tidy.miso_id == gene_name_to_miso_mxe['PKM'][0]]
fig, ax = plt.subplots(1, figsize=(8,6))
sns.violinplot(pkm.value, pkm.celltype, "points", fig=fig, ax=ax,
color=[common.p_color, common.n_color, common.m_color,
common.o_color, 'white'],
bw=0.03, order=['iPSC', 'NPSC', 'MotorNeu', 'Outliers', 'pooled'],
alpha=0.75, linewidth=1)
sns.despine()
xmin, xmax, ymin, ymax = ax.axis()
ax.hlines((0.3, 0.7), xmin, xmax, color='k', alpha=0.8, linewidth=0.5)
ax.set_xlim(xmin, xmax)
ax.set_ylim(0, 1);
def celltype_to_long_name(celltype):
"""
Given a single-letter celltype string, one of 'P', 'M', or 'N',
(could also be lowercase) return a longer name that can be used for
figures, e.g. 'iPSC' instead of 'P'
"""
celltype = celltype.upper()
if celltype == 'M':
return common.m_long_name
elif celltype == 'N':
return common.n_long_name
elif celltype == 'P':
return common.p_long_name
elif celltype == 'O':
return common.o_long_name
elif celltype == 'POOLED':
return 'pooled'
elif celltype == 'FAILED':
return 'failed'
else:
raise ValueError('Invalid celltype: %s' % celltype)
celltype_to_ids = {'P': common.trusted_p, 'N': common.trusted_n,
'M':common.trusted_m,
'O':common.outliers,
'pooled':common.pooled_samples,
'failed':failed}
failed = singlecell._Common.read_single_column('/home/obot/projects/singlecell/singlecell/ignore_these_samples.txt')
sample_ids_to_celltype = dict((sample_id, celltype_to_long_name(celltype)) for celltype,
sample_ids in celltype_to_ids.iteritems() for sample_id in sample_ids)
gene_name = 'PKM'
series = mxe_summary.xs('miso_posterior_mean', axis=1, level=1).ix[gene_name_to_miso_mxe[gene_name][0]]
ax = sns.violinplot(series, sample_ids_to_celltype, color=[common.p_color, common.n_color, common.m_color,
common.o_color, 'white'], inner='points',
bw=0.05, order=['iPSC', 'NPSC', 'MotorNeu', 'Outliers', 'pooled'], alpha=0.75)
ax.set_ylim(0, 1)
ax.set_ylabel(gene_name)
sns.despine()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment