Skip to content

Commit

Permalink
#27 enabled shap plots
Browse files Browse the repository at this point in the history
  • Loading branch information
EC2 Default User committed Sep 6, 2021
1 parent 38f70f2 commit 9f4f0d2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 47 deletions.
16 changes: 8 additions & 8 deletions clin_msi/msi_model_scripts/apply_msi_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ def apply_model(infile,moddir,outfile,shap_plot_dir=None):
df=df.rename(columns={sampcol:'samp'})
dfnew,shapdict,curfeats=apply_mod_to_dataframe(df,moddir)
dfnew[['samp','yprob']].to_csv(outfile,index=False)
# ## GRAB SHAP DATA
# testdat,bmdict=grab_shap_data(dfnew,shapdict,curfeats)
# ## EXPORT SHAP PLOTS
# for i in range(len(testdat)):
# shap_outfile=shap_plot_dir+"/shap_plot_"+str(i+1)+'.png'
# shaprec=testdat.iloc[i]
# shapdict_loc=bmdict[i]
# build_n_save_shap_plot(shaprec,shapdict_loc,shap_outfile)
## GRAB SHAP DATA
testdat,bmdict=grab_shap_data(dfnew,shapdict,curfeats)
## EXPORT SHAP PLOTS
for i in range(len(testdat)):
shap_outfile=shap_plot_dir+"/shap_plot_"+str(i+1)+'.png'
shaprec=testdat.iloc[i]
shapdict_loc=bmdict[i]
build_n_save_shap_plot(shaprec,shapdict_loc,shap_outfile)
35 changes: 0 additions & 35 deletions clin_msi/msi_training.py

This file was deleted.

8 changes: 4 additions & 4 deletions clin_msi/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import pysam
import pandas as pd

from .count_normalization.normalize_counts import parse_raw_data
from .msi_model_scripts.apply_msi_model import apply_model
from count_normalization.normalize_counts import parse_raw_data
from msi_model_scripts.apply_msi_model import apply_model


def repeat_finder(s):
Expand Down Expand Up @@ -96,7 +96,7 @@ def predict(

#apply model to normalized msi counts
final_results_file = os.path.join(output_dir, sample_name + '_MSIscore.txt')
apply_model(os.path.join(output_dir, sample_name + '_normalized.csv'), model_dir, final_results_file)
apply_model(os.path.join(output_dir, sample_name + '_normalized.csv'), model_dir, final_results_file,shap_plot_dir=output_dir)

if __name__ == '__main__':
predict()
predict()

0 comments on commit 9f4f0d2

Please sign in to comment.