Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mhc_rank
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Patrick Skillman-Lawrence
mhc_rank
Commits
9d197d67
Commit
9d197d67
authored
5 years ago
by
Tim O'Donnell
Browse files
Options
Downloads
Patches
Plain Diff
tests
parent
30cc4451
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mhcflurry/custom_loss.py
+3
-2
3 additions, 2 deletions
mhcflurry/custom_loss.py
test/test_class1_presentation_predictor.py
+10
-8
10 additions, 8 deletions
test/test_class1_presentation_predictor.py
with
13 additions
and
10 deletions
mhcflurry/custom_loss.py
+
3
−
2
View file @
9d197d67
...
@@ -291,8 +291,9 @@ class MultiallelicMassSpecLoss(Loss):
...
@@ -291,8 +291,9 @@ class MultiallelicMassSpecLoss(Loss):
pos_max
=
tf
.
reduce_max
(
pos
,
axis
=
1
)
pos_max
=
tf
.
reduce_max
(
pos
,
axis
=
1
)
neg
=
tf
.
boolean_mask
(
y_pred
,
tf
.
math
.
equal
(
y_true
,
0.0
))
neg
=
tf
.
boolean_mask
(
y_pred
,
tf
.
math
.
equal
(
y_true
,
0.0
))
term
=
tf
.
reshape
(
neg
,
(
-
1
,
1
))
-
pos_max
+
self
.
delta
term
=
tf
.
reshape
(
neg
,
(
-
1
,
1
))
-
pos_max
+
self
.
delta
result
=
tf
.
reduce_sum
(
tf
.
maximum
(
0.0
,
term
)
**
2
)
/
tf
.
cast
(
result
=
tf
.
math
.
divide_no_nan
(
tf
.
size
(
term
),
tf
.
float32
)
*
self
.
multiplier
tf
.
reduce_sum
(
tf
.
maximum
(
0.0
,
term
)
**
2
),
tf
.
cast
(
tf
.
size
(
term
),
tf
.
float32
))
*
self
.
multiplier
return
result
return
result
...
...
This diff is collapsed.
Click to expand it.
test/test_class1_presentation_predictor.py
+
10
−
8
View file @
9d197d67
...
@@ -91,7 +91,7 @@ def teardown():
...
@@ -91,7 +91,7 @@ def teardown():
cleanup
()
cleanup
()
def
test_basic
():
def
X
test_basic
():
affinity_predictor
=
PAN_ALLELE_PREDICTOR_NO_MASS_SPEC
affinity_predictor
=
PAN_ALLELE_PREDICTOR_NO_MASS_SPEC
models
=
[]
models
=
[]
for
affinity_network
in
affinity_predictor
.
class1_pan_allele_models
:
for
affinity_network
in
affinity_predictor
.
class1_pan_allele_models
:
...
@@ -485,9 +485,11 @@ def Xtest_real_data_multiallelic_refinement(max_epochs=10):
...
@@ -485,9 +485,11 @@ def Xtest_real_data_multiallelic_refinement(max_epochs=10):
import
ipdb
;
ipdb
.
set_trace
()
import
ipdb
;
ipdb
.
set_trace
()
def
test_synthetic_allele_refinement_with_affinity_data
():
test_synthetic_allele_refinement
(
include_affinities
=
True
)
def
Xtest_synthetic_allele_refinement_with_affinity_data
(
max_epochs
=
10
,
include_affinities
=
False
):
def
test_synthetic_allele_refinement
(
max_epochs
=
10
,
include_affinities
=
False
):
refine_allele
=
"
HLA-C*01:02
"
refine_allele
=
"
HLA-C*01:02
"
alleles
=
[
alleles
=
[
"
HLA-A*02:01
"
,
"
HLA-B*27:01
"
,
"
HLA-C*07:01
"
,
"
HLA-A*02:01
"
,
"
HLA-B*27:01
"
,
"
HLA-C*07:01
"
,
...
@@ -508,11 +510,10 @@ def Xtest_synthetic_allele_refinement_with_affinity_data(
...
@@ -508,11 +510,10 @@ def Xtest_synthetic_allele_refinement_with_affinity_data(
"
curated_training_data.no_mass_spec.csv.bz2
"
))
"
curated_training_data.no_mass_spec.csv.bz2
"
))
def
filter_df
(
df
):
def
filter_df
(
df
):
df
=
df
.
loc
[
return
df
.
loc
[
(
df
.
allele
.
isin
(
alleles
))
&
(
df
.
allele
.
isin
(
alleles
))
&
(
df
.
peptide
.
str
.
len
()
==
length
)
(
df
.
peptide
.
str
.
len
()
==
length
)
]
]
return
df
train_with_ms
=
filter_df
(
train_with_ms
)
train_with_ms
=
filter_df
(
train_with_ms
)
train_no_ms
=
filter_df
(
train_no_ms
)
train_no_ms
=
filter_df
(
train_no_ms
)
...
@@ -560,12 +561,13 @@ def Xtest_synthetic_allele_refinement_with_affinity_data(
...
@@ -560,12 +561,13 @@ def Xtest_synthetic_allele_refinement_with_affinity_data(
(
affinity_model
,)
=
PAN_ALLELE_PREDICTOR_NO_MASS_SPEC
.
class1_pan_allele_models
(
affinity_model
,)
=
PAN_ALLELE_PREDICTOR_NO_MASS_SPEC
.
class1_pan_allele_models
presentation_model
=
Class1PresentationNeuralNetwork
(
presentation_model
=
Class1PresentationNeuralNetwork
(
auxiliary_input_features
=
[
"
gene
"
],
auxiliary_input_features
=
[
"
gene
"
],
batch_generator_batch_size
=
1024
,
max_epochs
=
max_epochs
,
max_epochs
=
max_epochs
,
learning_rate
=
0.00
0
1
,
learning_rate
=
0.001
,
patience
=
5
,
patience
=
5
,
min_delta
=
0.0
,
min_delta
=
0.0
,
random_negative_rate
=
0
.0
,
random_negative_rate
=
1
.0
,
random_negative_constant
=
0
)
# WHY DOES THIS BREAK WITH RANDOM NEG?
random_negative_constant
=
25
)
presentation_model
.
load_from_class1_neural_network
(
affinity_model
)
presentation_model
.
load_from_class1_neural_network
(
affinity_model
)
presentation_model
=
pickle
.
loads
(
pickle
.
dumps
(
presentation_model
))
presentation_model
=
pickle
.
loads
(
pickle
.
dumps
(
presentation_model
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment