{"action":"created","comment":{"url":"https://api.github.com/repos/rice-bioe/fc/pulls/comments/46922982","id":46922982,"diff_hunk":"@@ -736,230 +506,223 @@ def get_transform_fxn(data_beads, peaks_mef, mef_channels,\n     if plot_filename is None:\n         plot_filename = str(data_beads)\n \n-    # 1. Cluster\n-    # ===========\n-    if cluster_method == 'dbscan':\n-        labels = clustering_dbscan(data_beads[:,cluster_channels], \n-            **cluster_params)\n-    elif cluster_method == 'distance':\n-        labels = clustering_distance(data_beads[:,cluster_channels], \n-            **cluster_params)\n-    elif cluster_method == 'gmm':\n-        labels = clustering_gmm(data_beads[:,cluster_channels], \n-            **cluster_params)\n+    # mef_channels and mef_values should be iterables.\n+    if hasattr(mef_channels, '__iter__'):\n+        mef_channel_all = list(mef_channels)\n+        mef_values_all = np.array(mef_values).copy()\n     else:\n-        raise ValueError(\"Clustering method {} not recognized.\"\n-            .format(cluster_method))\n+        mef_channel_all = [mef_channels]\n+        mef_values_all = np.array([mef_values])\n+\n+    ###\n+    # 1. Clustering\n+    ###\n \n+    # If clustering channels not specified, use channels in mef_channels\n+    if clustering_channels is None:\n+        clustering_channels = mef_channels\n+\n+    # Get number of clusters from number of specified MEF values\n+    n_clusters = mef_values_all.shape[1]\n+\n+    # Run clustering function\n+    labels = clustering_func(data_beads[:, clustering_channels],\n+                             n_clusters,\n+                             **clustering_params)\n+\n+    # Separate events corresponding to each cluster\n     labels_all = np.array(list(set(labels)))\n-    n_clusters = len(labels_all)\n-    data_clustered = [data_beads[labels == i] for i in labels_all]\n+    populations = [data_beads[labels == i] for i in labels_all]\n+\n+    # Sort populations based on distance to the origin\n+    cluster_dist = [np.sum((np.mean(di[:,clustering_channels], axis=0))**2)\n+                    for di in populations]\n+    cluster_sorted_ind = np.argsort(cluster_dist)\n+    populations = [populations[i] for i in cluster_sorted_ind]\n \n     # Print information\n     if verbose:\n-        print(\"- STEP 1. CLUSTERING.\")\n-        print(\"Number of clusters found: {}\".format(n_clusters))\n-        # Calculate percentage of each cluster\n-        data_count = np.array([di.shape[0] for di in data_clustered])\n-        data_perc = data_count*100.0/data_count.sum()\n-        print(\"Percentage of samples in each cluster:\")\n-        print(data_perc)\n+        # Calculate and display percentage of events on each population\n+        data_count = np.array([di.shape[0] for di in populations])","path":"fc/mef.py","position":null,"original_position":976,"commit_id":"a0d781fb00f6fcfc238901cb8283e750b8773549","original_commit_id":"bf2581e42c2227533df5e00f2f2f7ebfa9c8f04e","user":{"login":"castillohair","id":1529481,"avatar_url":"https://avatars.githubusercontent.com/u/1529481?v=3","gravatar_id":"","url":"https://api.github.com/users/castillohair","html_url":"https://github.com/castillohair","followers_url":"https://api.github.com/users/castillohair/followers","following_url":"https://api.github.com/users/castillohair/following{/other_user}","gists_url":"https://api.github.com/users/castillohair/gists{/gist_id}","starred_url":"https://api.github.com/users/castillohair/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/castillohair/subscriptions","organizations_url":"https://api.github.com/users/castillohair/orgs","repos_url":"https://api.github.com/users/castillohair/repos","events_url":"https://api.github.com/users/castillohair/events{/privacy}","received_events_url":"https://api.github.com/users/castillohair/received_events","type":"User","site_admin":false},"body":"Addressed in a0d781fb00f6fcfc238901cb8283e750b8773549","created_at":"2015-12-08T07:45:35Z","updated_at":"2015-12-08T07:45:35Z","html_url":"https://github.com/rice-bioe/fc/pull/165#discussion_r46922982","pull_request_url":"https://api.github.com/repos/rice-bioe/fc/pulls/165","_links":{"self":{"href":"https://api.github.com/repos/rice-bioe/fc/pulls/comments/46922982"},"html":{"href":"https://github.com/rice-bioe/fc/pull/165#discussion_r46922982"},"pull_request":{"href":"https://api.github.com/repos/rice-bioe/fc/pulls/165"}}},"pull_request":{"url":"https://api.github.com/repos/rice-bioe/fc/pulls/165","id":52799217,"html_url":"https://github.com/rice-bioe/fc/pull/165","diff_url":"https://github.com/rice-bioe/fc/pull/165.diff","patch_url":"https://github.com/rice-bioe/fc/pull/165.patch","issue_url":"https://api.github.com/repos/rice-bioe/fc/issues/165","number":165,"state":"open","locked":false,"title":"MEF module cleanup","user":{"login":"castillohair","id":1529481,"avatar_url":"https://avatars.githubusercontent.com/u/1529481?v=3","gravatar_id":"","url":"https://api.github.com/users/castillohair","html_url":"https://github.com/castillohair","followers_url":"https://api.github.com/users/castillohair/followers","following_url":"https://api.github.com/users/castillohair/following{/other_user}","gists_url":"https://api.github.com/users/castillohair/gists{/gist_id}","starred_url":"https://api.github.com/users/castillohair/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/castillohair/subscriptions","organizations_url":"https://api.github.com/users/castillohair/orgs","repos_url":"https://api.github.com/users/castillohair/repos","events_url":"https://api.github.com/users/castillohair/events{/privacy}","received_events_url":"https://api.github.com/users/castillohair/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-12-07T02:13:42Z","updated_at":"2015-12-08T07:45:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c7767df2fb72bbc6f8617a1e89e4b7944c9ec15e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rice-bioe/fc/pulls/165/commits","review_comments_url":"https://api.github.com/repos/rice-bioe/fc/pulls/165/comments","review_comment_url":"https://api.github.com/repos/rice-bioe/fc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rice-bioe/fc/issues/165/comments","statuses_url":"https://api.github.com/repos/rice-bioe/fc/statuses/a0d781fb00f6fcfc238901cb8283e750b8773549","head":{"label":"rice-bioe:mef-improvements","ref":"mef-improvements","sha":"a0d781fb00f6fcfc238901cb8283e750b8773549","user":{"login":"rice-bioe","id":2345009,"avatar_url":"https://avatars.githubusercontent.com/u/2345009?v=3","gravatar_id":"","url":"https://api.github.com/users/rice-bioe","html_url":"https://github.com/rice-bioe","followers_url":"https://api.github.com/users/rice-bioe/followers","following_url":"https://api.github.com/users/rice-bioe/following{/other_user}","gists_url":"https://api.github.com/users/rice-bioe/gists{/gist_id}","starred_url":"https://api.github.com/users/rice-bioe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rice-bioe/subscriptions","organizations_url":"https://api.github.com/users/rice-bioe/orgs","repos_url":"https://api.github.com/users/rice-bioe/repos","events_url":"https://api.github.com/users/rice-bioe/events{/privacy}","received_events_url":"https://api.github.com/users/rice-bioe/received_events","type":"Organization","site_admin":false},"repo":{"id":38354829,"name":"fc","full_name":"rice-bioe/fc","owner":{"login":"rice-bioe","id":2345009,"avatar_url":"https://avatars.githubusercontent.com/u/2345009?v=3","gravatar_id":"","url":"https://api.github.com/users/rice-bioe","html_url":"https://github.com/rice-bioe","followers_url":"https://api.github.com/users/rice-bioe/followers","following_url":"https://api.github.com/users/rice-bioe/following{/other_user}","gists_url":"https://api.github.com/users/rice-bioe/gists{/gist_id}","starred_url":"https://api.github.com/users/rice-bioe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rice-bioe/subscriptions","organizations_url":"https://api.github.com/users/rice-bioe/orgs","repos_url":"https://api.github.com/users/rice-bioe/repos","events_url":"https://api.github.com/users/rice-bioe/events{/privacy}","received_events_url":"https://api.github.com/users/rice-bioe/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rice-bioe/fc","description":"Python Flow Cytometry Library","fork":false,"url":"https://api.github.com/repos/rice-bioe/fc","forks_url":"https://api.github.com/repos/rice-bioe/fc/forks","keys_url":"https://api.github.com/repos/rice-bioe/fc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rice-bioe/fc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rice-bioe/fc/teams","hooks_url":"https://api.github.com/repos/rice-bioe/fc/hooks","issue_events_url":"https://api.github.com/repos/rice-bioe/fc/issues/events{/number}","events_url":"https://api.github.com/repos/rice-bioe/fc/events","assignees_url":"https://api.github.com/repos/rice-bioe/fc/assignees{/user}","branches_url":"https://api.github.com/repos/rice-bioe/fc/branches{/branch}","tags_url":"https://api.github.com/repos/rice-bioe/fc/tags","blobs_url":"https://api.github.com/repos/rice-bioe/fc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rice-bioe/fc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rice-bioe/fc/git/refs{/sha}","trees_url":"https://api.github.com/repos/rice-bioe/fc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rice-bioe/fc/statuses/{sha}","languages_url":"https://api.github.com/repos/rice-bioe/fc/languages","stargazers_url":"https://api.github.com/repos/rice-bioe/fc/stargazers","contributors_url":"https://api.github.com/repos/rice-bioe/fc/contributors","subscribers_url":"https://api.github.com/repos/rice-bioe/fc/subscribers","subscription_url":"https://api.github.com/repos/rice-bioe/fc/subscription","commits_url":"https://api.github.com/repos/rice-bioe/fc/commits{/sha}","git_commits_url":"https://api.github.com/repos/rice-bioe/fc/git/commits{/sha}","comments_url":"https://api.github.com/repos/rice-bioe/fc/comments{/number}","issue_comment_url":"https://api.github.com/repos/rice-bioe/fc/issues/comments{/number}","contents_url":"https://api.github.com/repos/rice-bioe/fc/contents/{+path}","compare_url":"https://api.github.com/repos/rice-bioe/fc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rice-bioe/fc/merges","archive_url":"https://api.github.com/repos/rice-bioe/fc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rice-bioe/fc/downloads","issues_url":"https://api.github.com/repos/rice-bioe/fc/issues{/number}","pulls_url":"https://api.github.com/repos/rice-bioe/fc/pulls{/number}","milestones_url":"https://api.github.com/repos/rice-bioe/fc/milestones{/number}","notifications_url":"https://api.github.com/repos/rice-bioe/fc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rice-bioe/fc/labels{/name}","releases_url":"https://api.github.com/repos/rice-bioe/fc/releases{/id}","created_at":"2015-07-01T06:50:32Z","updated_at":"2015-12-02T20:24:37Z","pushed_at":"2015-12-08T07:44:52Z","git_url":"git://github.com/rice-bioe/fc.git","ssh_url":"git@github.com:rice-bioe/fc.git","clone_url":"https://github.com/rice-bioe/fc.git","svn_url":"https://github.com/rice-bioe/fc","homepage":null,"size":6410,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":29,"forks":0,"open_issues":29,"watchers":0,"default_branch":"master"}},"base":{"label":"rice-bioe:develop","ref":"develop","sha":"911a7bd554ab7ee5fbc3640daa81fe5402928eb8","user":{"login":"rice-bioe","id":2345009,"avatar_url":"https://avatars.githubusercontent.com/u/2345009?v=3","gravatar_id":"","url":"https://api.github.com/users/rice-bioe","html_url":"https://github.com/rice-bioe","followers_url":"https://api.github.com/users/rice-bioe/followers","following_url":"https://api.github.com/users/rice-bioe/following{/other_user}","gists_url":"https://api.github.com/users/rice-bioe/gists{/gist_id}","starred_url":"https://api.github.com/users/rice-bioe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rice-bioe/subscriptions","organizations_url":"https://api.github.com/users/rice-bioe/orgs","repos_url":"https://api.github.com/users/rice-bioe/repos","events_url":"https://api.github.com/users/rice-bioe/events{/privacy}","received_events_url":"https://api.github.com/users/rice-bioe/received_events","type":"Organization","site_admin":false},"repo":{"id":38354829,"name":"fc","full_name":"rice-bioe/fc","owner":{"login":"rice-bioe","id":2345009,"avatar_url":"https://avatars.githubusercontent.com/u/2345009?v=3","gravatar_id":"","url":"https://api.github.com/users/rice-bioe","html_url":"https://github.com/rice-bioe","followers_url":"https://api.github.com/users/rice-bioe/followers","following_url":"https://api.github.com/users/rice-bioe/following{/other_user}","gists_url":"https://api.github.com/users/rice-bioe/gists{/gist_id}","starred_url":"https://api.github.com/users/rice-bioe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rice-bioe/subscriptions","organizations_url":"https://api.github.com/users/rice-bioe/orgs","repos_url":"https://api.github.com/users/rice-bioe/repos","events_url":"https://api.github.com/users/rice-bioe/events{/privacy}","received_events_url":"https://api.github.com/users/rice-bioe/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rice-bioe/fc","description":"Python Flow Cytometry Library","fork":false,"url":"https://api.github.com/repos/rice-bioe/fc","forks_url":"https://api.github.com/repos/rice-bioe/fc/forks","keys_url":"https://api.github.com/repos/rice-bioe/fc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rice-bioe/fc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rice-bioe/fc/teams","hooks_url":"https://api.github.com/repos/rice-bioe/fc/hooks","issue_events_url":"https://api.github.com/repos/rice-bioe/fc/issues/events{/number}","events_url":"https://api.github.com/repos/rice-bioe/fc/events","assignees_url":"https://api.github.com/repos/rice-bioe/fc/assignees{/user}","branches_url":"https://api.github.com/repos/rice-bioe/fc/branches{/branch}","tags_url":"https://api.github.com/repos/rice-bioe/fc/tags","blobs_url":"https://api.github.com/repos/rice-bioe/fc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rice-bioe/fc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rice-bioe/fc/git/refs{/sha}","trees_url":"https://api.github.com/repos/rice-bioe/fc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rice-bioe/fc/statuses/{sha}","languages_url":"https://api.github.com/repos/rice-bioe/fc/languages","stargazers_url":"https://api.github.com/repos/rice-bioe/fc/stargazers","contributors_url":"https://api.github.com/repos/rice-bioe/fc/contributors","subscribers_url":"https://api.github.com/repos/rice-bioe/fc/subscribers","subscription_url":"https://api.github.com/repos/rice-bioe/fc/subscription","commits_url":"https://api.github.com/repos/rice-bioe/fc/commits{/sha}","git_commits_url":"https://api.github.com/repos/rice-bioe/fc/git/commits{/sha}","comments_url":"https://api.github.com/repos/rice-bioe/fc/comments{/number}","issue_comment_url":"https://api.github.com/repos/rice-bioe/fc/issues/comments{/number}","contents_url":"https://api.github.com/repos/rice-bioe/fc/contents/{+path}","compare_url":"https://api.github.com/repos/rice-bioe/fc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rice-bioe/fc/merges","archive_url":"https://api.github.com/repos/rice-bioe/fc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rice-bioe/fc/downloads","issues_url":"https://api.github.com/repos/rice-bioe/fc/issues{/number}","pulls_url":"https://api.github.com/repos/rice-bioe/fc/pulls{/number}","milestones_url":"https://api.github.com/repos/rice-bioe/fc/milestones{/number}","notifications_url":"https://api.github.com/repos/rice-bioe/fc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rice-bioe/fc/labels{/name}","releases_url":"https://api.github.com/repos/rice-bioe/fc/releases{/id}","created_at":"2015-07-01T06:50:32Z","updated_at":"2015-12-02T20:24:37Z","pushed_at":"2015-12-08T07:44:52Z","git_url":"git://github.com/rice-bioe/fc.git","ssh_url":"git@github.com:rice-bioe/fc.git","clone_url":"https://github.com/rice-bioe/fc.git","svn_url":"https://github.com/rice-bioe/fc","homepage":null,"size":6410,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":29,"forks":0,"open_issues":29,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rice-bioe/fc/pulls/165"},"html":{"href":"https://github.com/rice-bioe/fc/pull/165"},"issue":{"href":"https://api.github.com/repos/rice-bioe/fc/issues/165"},"comments":{"href":"https://api.github.com/repos/rice-bioe/fc/issues/165/comments"},"review_comments":{"href":"https://api.github.com/repos/rice-bioe/fc/pulls/165/comments"},"review_comment":{"href":"https://api.github.com/repos/rice-bioe/fc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rice-bioe/fc/pulls/165/commits"},"statuses":{"href":"https://api.github.com/repos/rice-bioe/fc/statuses/a0d781fb00f6fcfc238901cb8283e750b8773549"}}}}