Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions app/Heatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ class Heatmap(object):
This is a program that genreates a heatmap of multiple RGI analyses.
"""

def __init__(self, input, classification, frequency, output, cluster, display, debug):
def __init__(self, input, classification, frequency, include_loose,output, cluster, display, debug):
self.input = input
self.classification = classification
self.frequency = frequency
self.include_loose = include_loose
self.output = output
self.cluster = cluster
self.display = display
Expand Down Expand Up @@ -332,7 +333,7 @@ def run(self):
hsp = max(value.keys(), key=(lambda key: value[key]['bit_score']))

# Flag to exclude loose hits
if value[hsp]["type_match"] != "Loose":
if value[hsp]["type_match"] != "Loose" or self.include_loose:
topmodel = value[hsp]["model_name"]
tophits[topmodel] = value[hsp]["type_match"]

Expand Down Expand Up @@ -409,7 +410,7 @@ def run(self):
genelist = sorted(genelist)

# Create a dictionary that will convert type of hit to num. value
conversion = {"Perfect": 2, "Strict": 1}
conversion = {"Perfect": 3, "Strict": 2, "Loose": 1}

# Apply conversion so hit criteria is number based
for sample in genes:
Expand All @@ -428,7 +429,7 @@ def run(self):

# Fixed colourmap values (purple, teal, yellow)
cmap_values = [0, 1, 2, 3]
custom_cmap = matplotlib.colors.ListedColormap(['#4c0057', '#00948f', '#feed00'])
custom_cmap = matplotlib.colors.ListedColormap(['#000000', '#4c0057', '#00948f', '#feed00'])
norm = matplotlib.colors.BoundaryNorm(cmap_values, custom_cmap.N)

# If the classification option chosen:
Expand Down Expand Up @@ -848,15 +849,16 @@ def run(self):
print('Output file %s: AMR genes are listed in alphabetical order '
'and samples have been clustered hierarchically (see SciPy documentation). '
'Yellow represents a perfect hit, teal represents a strict hit, purple '
'represents no hit.' %(file_name))
'represents a loose hit, black represents no hit.' %(file_name))
elif self.cluster == 'genes':
print('Output file %s: AMR genes have been clustered hierarchically. '
'Yellow represents a perfect hit, teal represents a strict hit, purple '
'represents no hit.' %(file_name))
'represents a loose hit, black represents no hit.' %(file_name))
elif self.cluster == 'both':
print('Output file %s: AMR genes and samples have been clustered hierarchically '
'(see SciPy documentation). Yellow represents a perfect hit, teal represents a strict hit, purple '
'represents no hit.' %(file_name))
'represents a loose hit, black represents no hit.' %(file_name))
else:
print('Output file %s: Yellow represents a perfect hit, '
'teal represents a strict hit, purple represents no hit.' %(file_name))
'teal represents a strict hit, purple represents a loose hit,'
' black represents no hit.' %(file_name))
4 changes: 3 additions & 1 deletion app/MainBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,8 @@ def heatmap_args(self):
help="The option to organize resistance genes based on a category.")
parser.add_argument('-f', '--frequency', dest="frequency", action="store_true",
help="Represent samples based on resistance profile.")
parser.add_argument('-l', '--include_loose', dest="include_loose", action="store_true",
help="Include loose predictions.")
parser.add_argument('-o', '--output', dest="output", default="RGI_heatmap",
help="Name for the output EPS and PNG files.\nThe number of files run will automatically \nbe appended to the end of the file name.(default={})".format('RGI_heatmap'))
parser.add_argument('-clus', '--cluster', dest="cluster", choices=("samples", "genes", "both"),
Expand All @@ -400,7 +402,7 @@ def heatmap_args(self):
return parser

def heatmap_run(self, args):
obj = Heatmap(args.input, args.classification, args.frequency,
obj = Heatmap(args.input, args.classification, args.frequency, args.include_loose,
args.output, args.cluster, args.display, args.debug)
obj.run()

Expand Down