Skip to content

Commit

Permalink
fix to plot_grid
Browse files Browse the repository at this point in the history
  • Loading branch information
dmnfarrell committed May 8, 2018
1 parent 551f11f commit e03b711
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 15 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ added neo module for neo-epitope prediction pipeline
snap package now builds with some predictors built in
fixed netmhciipan predictor
default config file in home dir for paths
changes default cutoff method for binders to use pre-defined quantiles for cutoffs
simplified web interface

------
0.2.0
Expand Down
3 changes: 2 additions & 1 deletion epitopepredict/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ def get_summary(self, P, pb, seqs):
x = pb.groupby('name').agg({'peptide':[base.first,np.size],
P.scorekey:base.first}).reset_index()
x.columns = [col[1]+'_'+col[0] if col[1]!='' else col[0] for col in x.columns.values]
x = x.rename(columns={'size_peptide':'binders','first_score':'max_score','first_peptide':'top_peptide'})
x = x.rename(columns={'size_peptide':'binders','first_%s' %P.scorekey:'max_score',
'first_peptide':'top_peptide'})
cl = analysis.find_clusters(pb)
if len(cl)>0:
cl = cl.groupby('name').size().rename('clusters').to_frame().reset_index()
Expand Down
3 changes: 1 addition & 2 deletions epitopepredict/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,14 @@
'mhc2_length': 11,
'n': 2, #number of alleles
'cutoff_method': 'default',
'cutoffs': 4, #percentile cutoff
'cutoffs': .95, #percentile cutoff
'sequence_file':'', #genbank/fasta file
'peptide_file':'', #plain text list of peptides
'path': 'results',
'overwrite': 'no',
'verbose':'no',
'names': '', #subset of protein names
'overwrite': 'no',
#'genome_analysis': 'no',
'cpus': 1,
'compression': '',
'fasta_header_sep': ' '}
Expand Down
16 changes: 12 additions & 4 deletions epitopepredict/neo.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,17 @@ def setup(self):
elif self.mhc2_alleles[0] in base.mhc2_presets:
self.mhc2_alleles = base.get_preset_alleles(self.mhc2_alleles[0])

if type(self.cutoffs) is int:
self.cutoffs = [self.cutoffs for p in self.predictors]
if type(self.cutoffs) is int or type(self.cutoffs) is float:
self.cutoffs = [self.cutoffs]
else:
self.cutoffs = [float(i) for i in self.cutoffs.split(',')]
self.names = self.names.split(',')
if self.names == ['']: self.names=None

if os.path.exists(self.names):
self.names = read_names(self.names)
elif self.names == '':
self.names=None
else:
self.names = self.names.split(',')
if not os.path.exists(self.path) and self.path != '':
os.mkdir(self.path)
return True
Expand All @@ -77,8 +82,11 @@ def run(self):
path = self.path
overwrite = self.overwrite
files = self.vcf_files
preds = self.predictors
labels = self.get_file_labels(files)
cutoffs = self.cutoffs
if len(cutoffs) < len(preds) :
cutoffs = [cutoffs[0] for p in preds]

for f in labels:
print (f)
Expand Down
12 changes: 8 additions & 4 deletions epitopepredict/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,12 @@ def bokeh_plot_grid(pred, name, width=None, palette='Blues', **kwargs):
return

cols = ['allele','pos','peptide',P.scorekey]
d = df[cols].copy()
#d = df[cols].copy()
b = P.get_binders(**kwargs)
d = P.data.copy()
#mark binders
mask = d.index.isin(b.index)
d['binder'] = mask

l = base.get_length(df)
grps = df.groupby('allele')
Expand All @@ -299,8 +304,7 @@ def bokeh_plot_grid(pred, name, width=None, palette='Blues', **kwargs):
if P.name not in ['tepitope']:
d['score1'] = d[val].apply( lambda x: 1-math.log(x, 50000))
val='score1'
cut = .42
d[val] = d[val].clip(cut)
d[val][d.binder==False] = min(d[val])

source = ColumnDataSource(d)
colors = all_palettes[palette][7]
Expand All @@ -312,7 +316,7 @@ def bokeh_plot_grid(pred, name, width=None, palette='Blues', **kwargs):
p.rect(x="pos", y="allele", width=1, height=1,
source=source,
fill_color={'field': val,'transform':mapper},
line_color='gray', line_width=.2)
line_color='gray', line_width=.5)
p.select_one(HoverTool).tooltips = [
('allele', '@allele'),
(P.scorekey, '@%s{1.11}' %P.scorekey),
Expand Down
4 changes: 1 addition & 3 deletions epitopepredict/templates/global.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@
<div class="floatleft">
{{ tables }}
</div>
{% end %}

<div class="floatright">
{{ script }}
{{ div }}

</div>

{% end %}
</div>

{% end %}
2 changes: 1 addition & 1 deletion epitopepredict/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<table class="largetable">
<tr><th>
<a href="/global" class="largebtn">
<span>all results</span>
<span>summary</span>
</a> </th>
<td>
<p>Global view showing results for all protein sequences in a set of predictions.</p></td>
Expand Down

0 comments on commit e03b711

Please sign in to comment.