Mercurial > repos > bimib > cobraxy
comparison COBRAxy/ras_generator.py @ 530:352c51a39e23 draft
Uploaded
author | francesco_lapi |
---|---|
date | Wed, 22 Oct 2025 12:18:07 +0000 |
parents | 6acd64232dad |
children | 1fc5c1edb0ef |
comparison
equal
deleted
inserted
replaced
529:6acd64232dad | 530:352c51a39e23 |
---|---|
348 # Store genes not mapped for later use | 348 # Store genes not mapped for later use |
349 self.genes_not_mapped = sorted(genes_not_mapped) | 349 self.genes_not_mapped = sorted(genes_not_mapped) |
350 | 350 |
351 # create the dataframe of ras (rules x samples) | 351 # create the dataframe of ras (rules x samples) |
352 ras_df = pd.DataFrame(data=ras_df, index=range(len(self.dict_rule_reactions)), columns=self.cell_ids) | 352 ras_df = pd.DataFrame(data=ras_df, index=range(len(self.dict_rule_reactions)), columns=self.cell_ids) |
353 ras_df['REACTIONS'] = [reaction_ids for rule, reaction_ids in self.dict_rule_reactions.items()] | 353 ras_df['Reactions'] = [reaction_ids for rule, reaction_ids in self.dict_rule_reactions.items()] |
354 | 354 |
355 reactions_common = pd.DataFrame() | 355 reactions_common = pd.DataFrame() |
356 reactions_common["REACTIONS"] = ras_df['REACTIONS'] | 356 reactions_common["Reactions"] = ras_df['Reactions'] |
357 reactions_common["proof2"] = ras_df['REACTIONS'] | 357 reactions_common["proof2"] = ras_df['Reactions'] |
358 reactions_common = reactions_common.explode('REACTIONS') | 358 reactions_common = reactions_common.explode('Reactions') |
359 reactions_common = reactions_common.set_index("REACTIONS") | 359 reactions_common = reactions_common.set_index("Reactions") |
360 | 360 |
361 ras_df = ras_df.explode("REACTIONS") | 361 ras_df = ras_df.explode("Reactions") |
362 ras_df = ras_df.set_index("REACTIONS") | 362 ras_df = ras_df.set_index("Reactions") |
363 | 363 |
364 if drop_na_rows: | 364 if drop_na_rows: |
365 ras_df = ras_df.dropna(how="all") | 365 ras_df = ras_df.dropna(how="all") |
366 | 366 |
367 if drop_duplicates: | 367 if drop_duplicates: |