@@ -356,35 +356,42 @@ def _get_coessentiality_df(self, pvalue_threshold = 10**-3):
356356 self .pvalue_threshold = pvalue_threshold
357357
358358 def coessentiality_autoformat (self ):
359+
360+ coessentiality_matrix_path = f'{ self .manager_path } /data/coessentiality/coessentiality_matrix.csv'
361+ coessentiality_df_path = f'{ self .manager_path } /data/coessentiality/coessentiality_df.csv'
359362
360- if self .verbose : print ("Building Coessentiality Matrix ..." , end = ' ' )
361- self ._load_coessentiality_matrix ()
362- self .matrix .to_pandas ().to_csv (
363- f'{ self .manager_path } /data/coessentiality/coessentiality_matrix.csv'
364- )
365- if self .verbose : print ("Done!" )
363+ # Check if the data has already been formatted or run the formatting
364+ if os .path .exists (coessentiality_matrix_path ):
365+ if self .verbose : print ("coessentiality_matrix.csv already exists" )
366+ self .matrix = pl .read_csv (coessentiality_matrix_path )
366367
367- if self .verbose : print ("Building Coessentiality DataFrame ..." , end = ' ' )
368- self ._get_coessentiality_df ()
369- self .df .to_pandas ().to_csv (
370- f'{ self .manager_path } /data/coessentiality/coessentiality_df.csv'
371- )
372- if self .verbose : print ("Done!" )
368+ else :
369+ if self .verbose : print ("Building Coessentiality Matrix ..." , end = ' ' )
370+ self ._load_coessentiality_matrix ()
371+ self .matrix .to_pandas ().to_csv (coessentiality_matrix_path )
372+ if self .verbose : print ("Done!" )
373+
374+ if os .path .exists (coessentiality_df_path ):
375+ if self .verbose : print ("coessentiality_df.csv already exists" )
376+ self .df = pl .read_csv (coessentiality_df_path )
377+
378+ else :
379+ if self .verbose : print ("Building Coessentiality DataFrame ..." , end = ' ' )
380+ self ._get_coessentiality_df ()
381+ self .df .to_pandas ().to_csv (coessentiality_df_path )
382+ if self .verbose : print ("Done!" )
373383
384+ # Update the config file
374385 self .parser ['data_paths' ].update ({
375386 'coessentiality' : 'data/coessentiality/'
376387 })
377388
378389 self .parser ['formatted' ].update ({
379- 'coessentiality_matrix.csv' : f' { self . manager_path } /data/coessentiality/coessentiality_matrix.csv' ,
380- 'coessentiality_df.csv' : f' { self . manager_path } /data/coessentiality/coessentiality_df.csv'
390+ 'coessentiality_matrix.csv' : coessentiality_matrix_path ,
391+ 'coessentiality_df.csv' : coessentiality_df_path
381392 })
382393
383394 self .parser ['depmap_files' ].update ({
384- 'coessentiality' : f'{ self .manager_path } /data/coessentiality/coessentiality_df.csv' ,
385- 'coessentiality_matrix' : f'{ self .manager_path } /data/coessentiality/coessentiality_matrix.csv' ,
386- # 'coessentiality_signs': f'{self.manager_path}/data/coessentiality/GLS_sign.npy',
387- # 'coessentiality_pvalues': f'{self.manager_path}/data/coessentiality/GLS_p.npy',
388- # 'gene_names': f'{self.manager_path}/data/coessentiality/genes.txt',
389- # 'pvalue_threshold': self.pvalue_threshold,
395+ 'coessentiality' : coessentiality_df_path ,
396+ 'coessentiality_matrix' : coessentiality_matrix_path ,
390397 })
0 commit comments