Skip to content

Commit

Permalink
Fix on input-parameters test
Browse files Browse the repository at this point in the history
Now differential JSON writes the values
  • Loading branch information
iquasere committed Dec 20, 2023
1 parent 85ce0b5 commit fffcc88
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
docker load --input /tmp/keggcharter.tar
docker image ls -a
- name: Run KEGGCharter with "input-quantification" and "input-taxonomy" parameters
run: docker run keggcharter /bin/bash -c "keggcharter -f KEGGCharter/cicd/keggcharter_input.tsv -rd resources_directory -keggc 'KEGG' -koc 'KO' -ecc 'EC number' -cogc 'COG ID' -iq -it "My community" -mm 00680"
run: docker run keggcharter /bin/bash -c "keggcharter -f KEGGCharter/cicd/keggcharter_input.tsv -rd resources_directory -keggc 'KEGG' -koc 'KO' -ecc 'EC number' -cogc 'COG ID' -iq -it 'My community' -mm 00680"

include-missing-genomes:
runs-on: ubuntu-latest
Expand Down
19 changes: 7 additions & 12 deletions keggpathway_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,9 @@ def pathway_boxes_differential(self, dataframe, colormap="coolwarm"):
dataframe = dataframe.apply(conv_rgb_hex)
dataframe = dataframe[dataframe.columns.tolist()]
nrboxes = len(dataframe.columns.tolist()) # number of samples
box2colors = {}
for box in dataframe.index.tolist():
boxidx = self.ortho_ids_to_pos[box] # get box index
box_colors = dataframe.loc[box].tolist()
box2colors[box] = box_colors
paired = nrboxes % 2 == 0
for i in range(nrboxes):
newrecord = create_box_heatmap(
Expand All @@ -314,7 +312,6 @@ def pathway_boxes_differential(self, dataframe, colormap="coolwarm"):
self.orthologs[boxidx].graphics.append(newrecord)
if self.orthologs[boxidx].graphics[0].width is not None: # TODO - should check more deeply why sometimes width is None
create_tile_box(self.orthologs[boxidx])
return box2colors


def grey_boxes(self, box_list):
Expand Down Expand Up @@ -457,21 +454,19 @@ def differential_expression_sample(
if len(df) == 0:
return 1
df = df.groupby('Boxes')[samples].sum()

box2colors = self.pathway_boxes_differential(df)

df1 = df.copy()
self.pathway_boxes_differential(df)
name = self.name.split(':')[-1]
# Write JSON data to a file
with open(f'{output}/json/differential_{name}.json', 'w') as file:
json.dump(box2colors, file, indent=2)
self.to_pdf(f'{output}/maps/differential_{name}.pdf')

self.differential_colorbar(df, f'{output}/maps/differential_{name}_legend.png')

self.add_legend(
f'{output}/maps/differential_{name}.pdf', f'{output}/maps/differential_{name}_legend.png',
f'{output}/maps/differential_{self.title.replace("/", "|")}.png')

# Write JSON data to a file
df = df1.reset_index()
box2quant = {df.iloc[i]['Boxes']: df.iloc[i][samples].tolist() for i in range(len(df))}
with open(f'{output}/json/differential_{name}.json', 'w') as file:
json.dump(box2quant, file, indent=2)
return 0

def add_legend(self, kegg_map_file, legend_file, output):
Expand Down

0 comments on commit fffcc88

Please sign in to comment.