Skip to content

Commit

Permalink
Report R2 when estimating mixing weights
Browse files Browse the repository at this point in the history
  • Loading branch information
omerwe committed May 10, 2024
1 parent 6e3c5d9 commit 7f1493d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions polypred.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from pandas.api.types import is_numeric_dtype
from polyfun_utils import Logger, check_package_versions, set_snpid_index, configure_logger
from sklearn.linear_model import LinearRegression
import sklearn.metrics as metrics

def splash_screen():
print('*********************************************************************')
Expand Down Expand Up @@ -308,6 +309,8 @@ def estimate_mixing_weights(args):
linreg = LinearRegression(positive = not args.allow_neg_mixweights)
linreg.fit(df_prs_sum_all, df_pheno['PHENO'])
mix_weights, intercept = linreg.coef_, linreg.intercept_
r2_score = metrics.r2_score(df_pheno['PHENO'], linreg.predict(df_prs_sum_all))
logging.info('In-sample R2: %0.3f'%(r2_score))

#create and print df_coef, and save it to disk
df_coef = pd.Series(mix_weights, index=beta_files)
Expand Down

0 comments on commit 7f1493d

Please sign in to comment.