{"action":"created","comment":{"url":"https://api.github.com/repos/biocore/gneiss/pulls/comments/71347585","id":71347585,"diff_hunk":"@@ -0,0 +1,117 @@\n+def match(x, y, intersect=False):\n+    \"\"\" Sorts samples in metadata and contingency table in the same order.\n+\n+    Parameters\n+    ----------\n+    x : pd.DataFrame\n+        Contingency table where samples correspond to rows and\n+        features correspond to columns.\n+    y: pd.DataFrame\n+        Metadata table where samples correspond to rows and\n+        explanatory metadata variables correspond to columns.\n+    intersect : bool, optional\n+        Specifies if only the intersection of samples in the\n+        contingency table and the metadata table will returned.\n+\n+    Returns\n+    -------\n+    _x : pd.DataFrame\n+        Filtered dataframe\n+    _y : pd.DataFrame\n+        Filtered dataframe\n+    \"\"\"\n+    _x = x.sort_index()\n+    _y = y.sort_index()\n+    if intersect:\n+        idx = set(_x.index) & set(_y.index)\n+        idx = sorted(idx)\n+        return _x.loc[idx], _y.loc[idx]\n+    else:\n+        if len(_x.index) != len(_y.index):\n+            raise ValueError(\"`x` and `y` have incompatible sizes, \"\n+                             \"`x` has %d rows, `y` has %d rows.  \"\n+                             \"Consider setting `intersect=True`.\" %\n+                             (len(_x.index), len(_y.index)))\n+        return _x, _y\n+\n+\n+def match_tips(table, tree, intersect=False):\n+    \"\"\" Returns the OTU table and tree with matched tips.\n+\n+    Sorts the columns of the OTU table to match the tips in\n+    the tree.  If the tree is multi-furcating, then the\n+    tree is reduced to a bifurcating tree by randomly inserting","path":"gneiss/util.py","position":43,"original_position":43,"commit_id":"2908c93714b75171ebbf9a9ee2f30f36bbd052d2","original_commit_id":"2908c93714b75171ebbf9a9ee2f30f36bbd052d2","user":{"login":"josenavas","id":2501478,"avatar_url":"https://avatars.githubusercontent.com/u/2501478?v=3","gravatar_id":"","url":"https://api.github.com/users/josenavas","html_url":"https://github.com/josenavas","followers_url":"https://api.github.com/users/josenavas/followers","following_url":"https://api.github.com/users/josenavas/following{/other_user}","gists_url":"https://api.github.com/users/josenavas/gists{/gist_id}","starred_url":"https://api.github.com/users/josenavas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josenavas/subscriptions","organizations_url":"https://api.github.com/users/josenavas/orgs","repos_url":"https://api.github.com/users/josenavas/repos","events_url":"https://api.github.com/users/josenavas/events{/privacy}","received_events_url":"https://api.github.com/users/josenavas/received_events","type":"User","site_admin":false},"body":"Probably better to point here to the [skbio `bifurcate`](http://scikit-bio.org/docs/latest/generated/skbio.tree.TreeNode.bifurcate.html#skbio.tree.TreeNode.bifurcate) documentation","created_at":"2016-07-19T14:20:18Z","updated_at":"2016-07-19T14:20:18Z","html_url":"https://github.com/biocore/gneiss/pull/12#discussion_r71347585","pull_request_url":"https://api.github.com/repos/biocore/gneiss/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/biocore/gneiss/pulls/comments/71347585"},"html":{"href":"https://github.com/biocore/gneiss/pull/12#discussion_r71347585"},"pull_request":{"href":"https://api.github.com/repos/biocore/gneiss/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/biocore/gneiss/pulls/12","id":77902470,"html_url":"https://github.com/biocore/gneiss/pull/12","diff_url":"https://github.com/biocore/gneiss/pull/12.diff","patch_url":"https://github.com/biocore/gneiss/pull/12.patch","issue_url":"https://api.github.com/repos/biocore/gneiss/issues/12","number":12,"state":"open","locked":false,"title":"Util","user":{"login":"mortonjt","id":4184797,"avatar_url":"https://avatars.githubusercontent.com/u/4184797?v=3","gravatar_id":"","url":"https://api.github.com/users/mortonjt","html_url":"https://github.com/mortonjt","followers_url":"https://api.github.com/users/mortonjt/followers","following_url":"https://api.github.com/users/mortonjt/following{/other_user}","gists_url":"https://api.github.com/users/mortonjt/gists{/gist_id}","starred_url":"https://api.github.com/users/mortonjt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mortonjt/subscriptions","organizations_url":"https://api.github.com/users/mortonjt/orgs","repos_url":"https://api.github.com/users/mortonjt/repos","events_url":"https://api.github.com/users/mortonjt/events{/privacy}","received_events_url":"https://api.github.com/users/mortonjt/received_events","type":"User","site_admin":false},"body":"This is adding in the utility helper functions discussed in code review.\r\n\r\n@antgonza @ElDeveloper @josenavas, mind if you could sanity check this PR?  Thanks!!","created_at":"2016-07-19T00:47:10Z","updated_at":"2016-07-19T14:20:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"939e5b1073f1d96c6e04fa6a51418fd758ae6ab6","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/biocore/gneiss/pulls/12/commits","review_comments_url":"https://api.github.com/repos/biocore/gneiss/pulls/12/comments","review_comment_url":"https://api.github.com/repos/biocore/gneiss/pulls/comments{/number}","comments_url":"https://api.github.com/repos/biocore/gneiss/issues/12/comments","statuses_url":"https://api.github.com/repos/biocore/gneiss/statuses/2908c93714b75171ebbf9a9ee2f30f36bbd052d2","head":{"label":"mortonjt:util","ref":"util","sha":"2908c93714b75171ebbf9a9ee2f30f36bbd052d2","user":{"login":"mortonjt","id":4184797,"avatar_url":"https://avatars.githubusercontent.com/u/4184797?v=3","gravatar_id":"","url":"https://api.github.com/users/mortonjt","html_url":"https://github.com/mortonjt","followers_url":"https://api.github.com/users/mortonjt/followers","following_url":"https://api.github.com/users/mortonjt/following{/other_user}","gists_url":"https://api.github.com/users/mortonjt/gists{/gist_id}","starred_url":"https://api.github.com/users/mortonjt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mortonjt/subscriptions","organizations_url":"https://api.github.com/users/mortonjt/orgs","repos_url":"https://api.github.com/users/mortonjt/repos","events_url":"https://api.github.com/users/mortonjt/events{/privacy}","received_events_url":"https://api.github.com/users/mortonjt/received_events","type":"User","site_admin":false},"repo":{"id":62267181,"name":"gneiss","full_name":"mortonjt/gneiss","owner":{"login":"mortonjt","id":4184797,"avatar_url":"https://avatars.githubusercontent.com/u/4184797?v=3","gravatar_id":"","url":"https://api.github.com/users/mortonjt","html_url":"https://github.com/mortonjt","followers_url":"https://api.github.com/users/mortonjt/followers","following_url":"https://api.github.com/users/mortonjt/following{/other_user}","gists_url":"https://api.github.com/users/mortonjt/gists{/gist_id}","starred_url":"https://api.github.com/users/mortonjt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mortonjt/subscriptions","organizations_url":"https://api.github.com/users/mortonjt/orgs","repos_url":"https://api.github.com/users/mortonjt/repos","events_url":"https://api.github.com/users/mortonjt/events{/privacy}","received_events_url":"https://api.github.com/users/mortonjt/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mortonjt/gneiss","description":null,"fork":true,"url":"https://api.github.com/repos/mortonjt/gneiss","forks_url":"https://api.github.com/repos/mortonjt/gneiss/forks","keys_url":"https://api.github.com/repos/mortonjt/gneiss/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mortonjt/gneiss/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mortonjt/gneiss/teams","hooks_url":"https://api.github.com/repos/mortonjt/gneiss/hooks","issue_events_url":"https://api.github.com/repos/mortonjt/gneiss/issues/events{/number}","events_url":"https://api.github.com/repos/mortonjt/gneiss/events","assignees_url":"https://api.github.com/repos/mortonjt/gneiss/assignees{/user}","branches_url":"https://api.github.com/repos/mortonjt/gneiss/branches{/branch}","tags_url":"https://api.github.com/repos/mortonjt/gneiss/tags","blobs_url":"https://api.github.com/repos/mortonjt/gneiss/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mortonjt/gneiss/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mortonjt/gneiss/git/refs{/sha}","trees_url":"https://api.github.com/repos/mortonjt/gneiss/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mortonjt/gneiss/statuses/{sha}","languages_url":"https://api.github.com/repos/mortonjt/gneiss/languages","stargazers_url":"https://api.github.com/repos/mortonjt/gneiss/stargazers","contributors_url":"https://api.github.com/repos/mortonjt/gneiss/contributors","subscribers_url":"https://api.github.com/repos/mortonjt/gneiss/subscribers","subscription_url":"https://api.github.com/repos/mortonjt/gneiss/subscription","commits_url":"https://api.github.com/repos/mortonjt/gneiss/commits{/sha}","git_commits_url":"https://api.github.com/repos/mortonjt/gneiss/git/commits{/sha}","comments_url":"https://api.github.com/repos/mortonjt/gneiss/comments{/number}","issue_comment_url":"https://api.github.com/repos/mortonjt/gneiss/issues/comments{/number}","contents_url":"https://api.github.com/repos/mortonjt/gneiss/contents/{+path}","compare_url":"https://api.github.com/repos/mortonjt/gneiss/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mortonjt/gneiss/merges","archive_url":"https://api.github.com/repos/mortonjt/gneiss/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mortonjt/gneiss/downloads","issues_url":"https://api.github.com/repos/mortonjt/gneiss/issues{/number}","pulls_url":"https://api.github.com/repos/mortonjt/gneiss/pulls{/number}","milestones_url":"https://api.github.com/repos/mortonjt/gneiss/milestones{/number}","notifications_url":"https://api.github.com/repos/mortonjt/gneiss/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mortonjt/gneiss/labels{/name}","releases_url":"https://api.github.com/repos/mortonjt/gneiss/releases{/id}","deployments_url":"https://api.github.com/repos/mortonjt/gneiss/deployments","created_at":"2016-06-30T00:40:24Z","updated_at":"2016-06-30T00:41:17Z","pushed_at":"2016-07-19T00:48:26Z","git_url":"git://github.com/mortonjt/gneiss.git","ssh_url":"git@github.com:mortonjt/gneiss.git","clone_url":"https://github.com/mortonjt/gneiss.git","svn_url":"https://github.com/mortonjt/gneiss","homepage":null,"size":100,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"biocore:master","ref":"master","sha":"1be0fe7f92eb66ef9e8a9ccfa87fb6bbd023b216","user":{"login":"biocore","id":6241857,"avatar_url":"https://avatars.githubusercontent.com/u/6241857?v=3","gravatar_id":"","url":"https://api.github.com/users/biocore","html_url":"https://github.com/biocore","followers_url":"https://api.github.com/users/biocore/followers","following_url":"https://api.github.com/users/biocore/following{/other_user}","gists_url":"https://api.github.com/users/biocore/gists{/gist_id}","starred_url":"https://api.github.com/users/biocore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/biocore/subscriptions","organizations_url":"https://api.github.com/users/biocore/orgs","repos_url":"https://api.github.com/users/biocore/repos","events_url":"https://api.github.com/users/biocore/events{/privacy}","received_events_url":"https://api.github.com/users/biocore/received_events","type":"Organization","site_admin":false},"repo":{"id":62265215,"name":"gneiss","full_name":"biocore/gneiss","owner":{"login":"biocore","id":6241857,"avatar_url":"https://avatars.githubusercontent.com/u/6241857?v=3","gravatar_id":"","url":"https://api.github.com/users/biocore","html_url":"https://github.com/biocore","followers_url":"https://api.github.com/users/biocore/followers","following_url":"https://api.github.com/users/biocore/following{/other_user}","gists_url":"https://api.github.com/users/biocore/gists{/gist_id}","starred_url":"https://api.github.com/users/biocore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/biocore/subscriptions","organizations_url":"https://api.github.com/users/biocore/orgs","repos_url":"https://api.github.com/users/biocore/repos","events_url":"https://api.github.com/users/biocore/events{/privacy}","received_events_url":"https://api.github.com/users/biocore/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/biocore/gneiss","description":null,"fork":false,"url":"https://api.github.com/repos/biocore/gneiss","forks_url":"https://api.github.com/repos/biocore/gneiss/forks","keys_url":"https://api.github.com/repos/biocore/gneiss/keys{/key_id}","collaborators_url":"https://api.github.com/repos/biocore/gneiss/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/biocore/gneiss/teams","hooks_url":"https://api.github.com/repos/biocore/gneiss/hooks","issue_events_url":"https://api.github.com/repos/biocore/gneiss/issues/events{/number}","events_url":"https://api.github.com/repos/biocore/gneiss/events","assignees_url":"https://api.github.com/repos/biocore/gneiss/assignees{/user}","branches_url":"https://api.github.com/repos/biocore/gneiss/branches{/branch}","tags_url":"https://api.github.com/repos/biocore/gneiss/tags","blobs_url":"https://api.github.com/repos/biocore/gneiss/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/biocore/gneiss/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/biocore/gneiss/git/refs{/sha}","trees_url":"https://api.github.com/repos/biocore/gneiss/git/trees{/sha}","statuses_url":"https://api.github.com/repos/biocore/gneiss/statuses/{sha}","languages_url":"https://api.github.com/repos/biocore/gneiss/languages","stargazers_url":"https://api.github.com/repos/biocore/gneiss/stargazers","contributors_url":"https://api.github.com/repos/biocore/gneiss/contributors","subscribers_url":"https://api.github.com/repos/biocore/gneiss/subscribers","subscription_url":"https://api.github.com/repos/biocore/gneiss/subscription","commits_url":"https://api.github.com/repos/biocore/gneiss/commits{/sha}","git_commits_url":"https://api.github.com/repos/biocore/gneiss/git/commits{/sha}","comments_url":"https://api.github.com/repos/biocore/gneiss/comments{/number}","issue_comment_url":"https://api.github.com/repos/biocore/gneiss/issues/comments{/number}","contents_url":"https://api.github.com/repos/biocore/gneiss/contents/{+path}","compare_url":"https://api.github.com/repos/biocore/gneiss/compare/{base}...{head}","merges_url":"https://api.github.com/repos/biocore/gneiss/merges","archive_url":"https://api.github.com/repos/biocore/gneiss/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/biocore/gneiss/downloads","issues_url":"https://api.github.com/repos/biocore/gneiss/issues{/number}","pulls_url":"https://api.github.com/repos/biocore/gneiss/pulls{/number}","milestones_url":"https://api.github.com/repos/biocore/gneiss/milestones{/number}","notifications_url":"https://api.github.com/repos/biocore/gneiss/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/biocore/gneiss/labels{/name}","releases_url":"https://api.github.com/repos/biocore/gneiss/releases{/id}","deployments_url":"https://api.github.com/repos/biocore/gneiss/deployments","created_at":"2016-06-29T23:48:50Z","updated_at":"2016-07-08T23:12:18Z","pushed_at":"2016-07-19T00:48:26Z","git_url":"git://github.com/biocore/gneiss.git","ssh_url":"git@github.com:biocore/gneiss.git","clone_url":"https://github.com/biocore/gneiss.git","svn_url":"https://github.com/biocore/gneiss","homepage":null,"size":96,"stargazers_count":0,"watchers_count":0,"language":"Jupyter Notebook","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":4,"forks":2,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/biocore/gneiss/pulls/12"},"html":{"href":"https://github.com/biocore/gneiss/pull/12"},"issue":{"href":"https://api.github.com/repos/biocore/gneiss/issues/12"},"comments":{"href":"https://api.github.com/repos/biocore/gneiss/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/biocore/gneiss/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/biocore/gneiss/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/biocore/gneiss/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/biocore/gneiss/statuses/2908c93714b75171ebbf9a9ee2f30f36bbd052d2"}}}}
{"actor":{"display_login":"josenavas"}}