@@ -171,37 +171,42 @@ async def proteomics_gen(
171171 raise ValueError ("Quantile must be an integer from 0 to 100" )
172172 quantile /= 100
173173
174- logger .info (f"Config file is at '{ prot_config_filepath } '" )
174+ config_df = pd .read_excel (config_filepath , sheet_name = context_name )
175+ matrix : pd .DataFrame = process_proteomics_data (matrix_filepath )
175176
176- xl = pd .ExcelFile (prot_config_filepath )
177- sheet_names = xl .sheet_names
178-
179- for context_name in sheet_names :
180- datafilename = "" .join (["protein_abundance_" , context_name , ".csv" ])
181- config_sheet = pd .read_excel (prot_config_filepath , sheet_name = context_name )
182- groups = config_sheet ["group" ].unique ().tolist ()
183-
184- for group in groups :
185- group_idx = np .where ([g == group for g in config_sheet ["group" ].tolist ()])
186- cols = [* np .take (config_sheet ["sample_name" ].to_numpy (), group_idx ).ravel ().tolist (), "gene_symbol" ]
187-
188- proteomics_data = load_proteomics_data (datafilename , context_name )
189- proteomics_data = proteomics_data .loc [:, cols ]
190-
191- symbols_to_ids = await load_gene_symbol_map (gene_symbols = proteomics_data ["gene_symbol" ].tolist ())
192- proteomics_data .dropna (subset = ["gene_symbol" ], inplace = True )
193- if "uniprot" in proteomics_data .columns :
194- proteomics_data .drop (columns = ["uniprot" ], inplace = True )
195-
196- proteomics_data = proteomics_data .groupby (["gene_symbol" ]).agg ("max" )
197- proteomics_data ["entrez_gene_id" ] = symbols_to_ids ["gene_id" ]
198- proteomics_data .dropna (subset = ["entrez_gene_id" ], inplace = True )
199- proteomics_data .set_index ("entrez_gene_id" , inplace = True )
200-
201- # save proteomics data by test
202- abundance_to_bool_group (context_name , group , proteomics_data , rep_ratio , hi_rep_ratio , quantile )
203- to_bool_context (context_name , group_ratio , hi_group_ratio , groups )
177+ groups = config_df ["group" ].unique ().tolist ()
204178
179+ for group in groups :
180+ indices = np .where ([g == group for g in config_df ["group" ]])
181+ sample_columns = [* np .take (config_df ["sample_name" ].to_numpy (), indices ).ravel ().tolist (), "gene_symbol" ]
182+ matrix = matrix .loc [:, sample_columns ]
205183
184+ symbols_to_gene_ids = await load_gene_symbol_map (
185+ gene_symbols = matrix ["gene_symbol" ].tolist (),
186+ entrez_map = input_entrez_map ,
187+ )
188+ matrix .dropna (subset = ["gene_symbol" ], inplace = True )
189+ if "uniprot" in matrix .columns :
190+ matrix .drop (columns = ["uniprot" ], inplace = True )
191+
192+ matrix = matrix .groupby (["gene_symbol" ]).agg ("max" )
193+ matrix ["entrez_gene_id" ] = symbols_to_gene_ids ["gene_id" ]
194+ matrix .dropna (subset = ["entrez_gene_id" ], inplace = True )
195+ matrix .set_index ("entrez_gene_id" , inplace = True )
196+
197+ # bool_filepath = output_dir / f"bool_prot_Matrix_{context_name}_{group_name}.csv"
198+ abundance_to_bool_group (
199+ context_name = context_name ,
200+ group_name = group ,
201+ abundance_matrix = matrix ,
202+ replicate_ratio = replicate_ratio ,
203+ high_confidence_replicate_ratio = high_confidence_replicate_ratio ,
204+ quantile = quantile ,
205+ output_boolean_filepath = output_boolean_filepath ,
206206 )
207+ to_bool_context (
208+ context_name = context_name ,
209+ group_ratio = batch_ratio ,
210+ hi_group_ratio = high_confience_batch_ratio ,
211+ group_names = groups ,
207212 )
0 commit comments