Skip to content

Commit

Permalink
two new arguments added to force "Frame" label in barplot axis and to…
Browse files Browse the repository at this point in the history
… adjust size limit for distance matrix.

Per default, the distance matrix size limit should be high enough for every trajectory. If this graph takes too much time to generate, decrease this limit
  • Loading branch information
tubiana committed Sep 22, 2020
1 parent fbba180 commit 2cc96d3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,13 @@ the interactive prompt.
number of group ('-ng')
-i INTERACTIVE, --interactive INTERACTIVE
Interactive mode for distance matrix (Y/n)
-axis AXIS, --axis AXIS
if something is wrong in the axis of timed barplot
graph (wrong time unit), and you just want 'frame'
instead of time Choose 'frame' here.
-limitmat LIMITMAT, --limitmat LIMITMAT
If the distance matrix is too long to generate choose
a limit here. Default is 100000000
```

## USAGE:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

MAJOR = 4
MINOR = 7
PATCH = 3
PATCH = 4
VERSION = "{}.{}.{}".format(MAJOR, MINOR, PATCH)

with open("ttclust/version.py", "w") as f:
Expand Down
23 changes: 17 additions & 6 deletions ttclust/ttclust.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,13 @@ def parseArg():
# Interactive mode for distance matrix:
arguments.add_argument('-i', '--interactive', help="Use saved distance matrix ? (Y/n)", default="Y")


# Optional for graphics
arguments.add_argument('-axis', '--axis', help="if something is wrong in the axis of timed barplot graph "
"(wrong time unit), and you just want 'frame' instead of time "
" Choose 'frame' here.", default="default")
arguments.add_argument('-limitmat', '--limitmat', help= "If the distance matrix is too long to generate "
"choose a limit here. Default is 100000000", default=100000000, type = int)
args = vars(arguments.parse_args())

# Activate autoclustering if autoclust is True and if no values was specified for ngroup or cutoff
Expand Down Expand Up @@ -752,14 +759,15 @@ def get_cmap(num_cluster):
return cmap


def plot_barplot(clusters_list, logname, size, traj):
def plot_barplot(clusters_list, logname, size, traj, args):
"""
DESCRIPTION
This function is used to plot the linear barplots.
Args:
clusters_list (list) : list of cluster label in order or appearance
logname (str) : output logname
size (int): number of frames
args (dict): dictionnary of arguments
Returns:
colors_list (list of list) : list of colors in RGBA format
"""
Expand All @@ -778,7 +786,7 @@ def plot_barplot(clusters_list, logname, size, traj):
fig, ax = plt.subplots(figsize=(10, 1.5))

# get time if present
if traj.time.sum() < 0.0000005:
if traj.time.sum() < 0.0000005 or args["axis"].lower() == "frame" :
timeMin, timeMax = 0, np.shape(data)[1]
plt.xlabel("Frame")

Expand Down Expand Up @@ -1063,7 +1071,7 @@ def plot_2D_distance_projection(rmsd_m, clusters_list, colors, logname):
plt.close()


def generate_graphs(clusters_list, output, size, linkage, cutoff, distances, traj):
def generate_graphs(clusters_list, output, size, linkage, cutoff, distances, traj, args):
"""
DESCRIPTION
Create a linear cluster mapping graph where every frame is printed as a
Expand All @@ -1076,13 +1084,16 @@ def generate_graphs(clusters_list, output, size, linkage, cutoff, distances, tra
cutoff (float): cutoff distance value for clustering (in the dendogram)
distances(numpy array): distance matrix
traj (Trajectory): trajectory for time usage in axis barplot
args (dict): dictionnary of arguments.
Return:
colors_list (list) to be used with 2D distance projection graph
"""
colors_list = plot_barplot(clusters_list, output, size, traj)
colors_list = plot_barplot(clusters_list, output, size, traj, args)
plot_dendro(linkage, output, cutoff, colors_list, clusters_list)
plot_hist(clusters_list, output, colors_list)
if (distances.shape[0] < 10002):


if (distances.shape[0] < args["limitmat"]):
plot_distmat(distances, output)
else:
printScreenLogfile("Too many frames (>=10002)! The RMSD distance matrix will not be generated")
Expand Down Expand Up @@ -1202,7 +1213,7 @@ def Cluster_analysis_call(args):
# reordering the list by the cluster number
clusters_list.sort(key=operator.attrgetter("id"))
print("====== Generating Graph ======")
colors_list = generate_graphs(clusters_list, logname, traj.n_frames, linkage, cutoff, distances, traj)
colors_list = generate_graphs(clusters_list, logname, traj.n_frames, linkage, cutoff, distances, traj, args)
print("====== Calc. repr. frame ======")
calculate_representative_frame_spread(clusters_list, distances)

Expand Down
3 changes: 2 additions & 1 deletion ttclust/version.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
__version__ = '4.7.3'
__version__ = '4.7.4'

0 comments on commit 2cc96d3

Please sign in to comment.