stacker.kmeans.plot_cluster_trj_data#
- plot_cluster_trj_data(cluster_file, outfile, x_labels_map=None)[source]#
Plots the output of run_kmeans() to a PNG file.
Creates a grouped bar plot of the number of frames from each trajectory in each cluster following KMeans clustering. Writes the plot output to a PNG file.
- Parameters:
- input_filestr
Path to clustering results written by run_kmeans()
- outfilestr
Filepath where the plot PNG file will be saved.
- x_labels_mapdict, optional
Dictionary to remap x labels. Keys are original labels and values are new labels.
- Returns:
- None
Examples
This will read the clustering results from ‘clustering_results.txt’, create a bar plot, and save it as ‘kmeans_plot.cluster_4.png’ in the specified output directory.
>>> import stacker as st >>> st.plot_cluster_trj_data('clustering_results.txt', "../testing/kmeans_plot.png", {'5JUP_N2_tGGG_aCCU_+1CGU_data': 'tGGG_aCCU_+1CGU', '5JUP_N2_tGGG_aCCU_+1GCU_data': 'tGGG_aCCU_+1GCU'})