Skip to content

Instantly share code, notes, and snippets.

@adamewing
Created April 16, 2019 01:19
Show Gist options
  • Save adamewing/90f1f57985a2033f292debb2e2e5b25f to your computer and use it in GitHub Desktop.
Save adamewing/90f1f57985a2033f292debb2e2e5b25f to your computer and use it in GitHub Desktop.
Generate volcano plot for Stevenson et al.
#!/usr/bin/env python
import sys
import pandas as pd
import matplotlib as mpl
# Force matplotlib to not use any Xwindows backend.
mpl.use('Agg')
import matplotlib.pyplot as plt
import seaborn as sns
import logging
FORMAT = '%(asctime)s %(message)s'
logging.basicConfig(format=FORMAT)
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
if len(sys.argv) == 2:
de = pd.read_csv(sys.argv[1], header=0, index_col=False)
outfn = '.'.join(sys.argv[1].split('.')[:-1]) + '.volcano.eps'
de['sig'] = de['FDR'] < 0.05
de=de.sample(frac=1)
pal = [(0.7,0.7,0.7), (1.0,0.27,0.0)]
ax = sns.scatterplot(x='logFC', y='logCPM', data=de, hue='sig', palette=pal, size=2, legend=False)
fig = ax.figure
fig.savefig(outfn, bbox_inches='tight')
else:
sys.exit('usage: %s <DE table>' % sys.argv[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment