{"action":"created","comment":{"url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/pulls/comments/73282048","id":73282048,"diff_hunk":"@@ -0,0 +1,67 @@\n+import numpy as np\n+import pandas as pd\n+from scipy import linalg\n+\n+class TFA:\n+\n+    \"\"\"\n+    TFA calculates transcription factor activity using matrix pseudoinverse\n+\n+        Parameters\n+    --------\n+    prior: pd.dataframe\n+        binary or numeric g by t matrix stating existence of gene-TF interactions. \n+        g--gene, t--TF.\n+\n+    exp.mat: pd.dataframe\n+        normalized expression g by c matrix. g--gene, c--conditions\n+\n+    exp.mat.halftau: pd.dataframe\n+        normalized expression matrix for time series.\n+\n+    noself=True: boolean\n+        If noself (no self interaction) is True, self-regulatory interactions \n+        in prior matrix are set to 0.\n+\n+    dup_self=True: boolean\n+        If dup_slef (duplicate self) is True, TFs that other TFs with the exact same \n+        set of interactions in the prior are kept and will have the same activities\n+    \"\"\"\n+\n+    def __init__(self, prior, exp_mat, exp_mat_halftau):\n+        self.prior = prior\n+        self.exp_mat = exp_mat\n+        self.exp_mat = exp_mat_halftau\n+\n+    def tfa(self, noself = True, dup_self = True):\n+        tfwt = self.prior.abs().sum(axis = 0) > 0\n+        tfwt = tfwt[tfwt].index.tolist()\n+\n+        if dup_self:\n+            # subset of prior matrix whose columns are not all zeros (snz: sum non-zero)\n+            prior_snz = self.prior[tfwt]            \n+            duplicates = prior_snz.transpose().duplicated(keep=False) # mark duplicates as true\n+            dTFs = duplicates[duplicates].index.tolist()\n+\n+        # find non-duplicated TFs that are also present in target gene list \n+        ndTFs = list(set(self.prior.columns.values.tolist()).difference(dTFs))\n+\n+        if noself:","path":"inferelator_ng/tfa.py","position":49,"original_position":49,"commit_id":"5ee2709997228e7e53f600a59a8928c92174b141","original_commit_id":"5ee2709997228e7e53f600a59a8928c92174b141","user":{"login":"e5c","id":6350854,"avatar_url":"https://avatars.githubusercontent.com/u/6350854?v=3","gravatar_id":"","url":"https://api.github.com/users/e5c","html_url":"https://github.com/e5c","followers_url":"https://api.github.com/users/e5c/followers","following_url":"https://api.github.com/users/e5c/following{/other_user}","gists_url":"https://api.github.com/users/e5c/gists{/gist_id}","starred_url":"https://api.github.com/users/e5c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/e5c/subscriptions","organizations_url":"https://api.github.com/users/e5c/orgs","repos_url":"https://api.github.com/users/e5c/repos","events_url":"https://api.github.com/users/e5c/events{/privacy}","received_events_url":"https://api.github.com/users/e5c/received_events","type":"User","site_admin":false},"body":"Hi Ren!\r\nSome minor style nits: variable names should avoid capital letters, e.g. `dTFs`, and use underscores where appropriate (`noself` -> `no_self`). \r\n\r\nEchoing @AaronWatters above, one convention that Hammer Lab uses is to avoid abbreviations wherever possible. While this makes the coding a little more verbose, the result is far more readable. E.g. `dTFs` -> `duplicate_tfs`, `ndTFs` -> `non_duplicated_tfs`, `no_self` -> `no_self_interaction`.\r\n","created_at":"2016-08-03T05:19:25Z","updated_at":"2016-08-03T05:19:25Z","html_url":"https://github.com/simonsfoundation/inferelator_ng/pull/17#discussion_r73282048","pull_request_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/pulls/17","_links":{"self":{"href":"https://api.github.com/repos/simonsfoundation/inferelator_ng/pulls/comments/73282048"},"html":{"href":"https://github.com/simonsfoundation/inferelator_ng/pull/17#discussion_r73282048"},"pull_request":{"href":"https://api.github.com/repos/simonsfoundation/inferelator_ng/pulls/17"}}},"pull_request":{"url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/pulls/17","id":78726224,"html_url":"https://github.com/simonsfoundation/inferelator_ng/pull/17","diff_url":"https://github.com/simonsfoundation/inferelator_ng/pull/17.diff","patch_url":"https://github.com/simonsfoundation/inferelator_ng/pull/17.patch","issue_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/issues/17","number":17,"state":"open","locked":false,"title":"Refactor tfa","user":{"login":"ryi06","id":10792267,"avatar_url":"https://avatars.githubusercontent.com/u/10792267?v=3","gravatar_id":"","url":"https://api.github.com/users/ryi06","html_url":"https://github.com/ryi06","followers_url":"https://api.github.com/users/ryi06/followers","following_url":"https://api.github.com/users/ryi06/following{/other_user}","gists_url":"https://api.github.com/users/ryi06/gists{/gist_id}","starred_url":"https://api.github.com/users/ryi06/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryi06/subscriptions","organizations_url":"https://api.github.com/users/ryi06/orgs","repos_url":"https://api.github.com/users/ryi06/repos","events_url":"https://api.github.com/users/ryi06/events{/privacy}","received_events_url":"https://api.github.com/users/ryi06/received_events","type":"User","site_admin":false},"body":"Results from tfa.py was compared with results from tfa.R manually...\r\nI will work on the unit test next","created_at":"2016-07-25T18:11:10Z","updated_at":"2016-08-03T05:19:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"44d8ac45cb8c93037d9f324189e78efddc0c95f6","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/pulls/17/commits","review_comments_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/pulls/17/comments","review_comment_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/pulls/comments{/number}","comments_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/issues/17/comments","statuses_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/statuses/5ee2709997228e7e53f600a59a8928c92174b141","head":{"label":"ryi06:master","ref":"master","sha":"5ee2709997228e7e53f600a59a8928c92174b141","user":{"login":"ryi06","id":10792267,"avatar_url":"https://avatars.githubusercontent.com/u/10792267?v=3","gravatar_id":"","url":"https://api.github.com/users/ryi06","html_url":"https://github.com/ryi06","followers_url":"https://api.github.com/users/ryi06/followers","following_url":"https://api.github.com/users/ryi06/following{/other_user}","gists_url":"https://api.github.com/users/ryi06/gists{/gist_id}","starred_url":"https://api.github.com/users/ryi06/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryi06/subscriptions","organizations_url":"https://api.github.com/users/ryi06/orgs","repos_url":"https://api.github.com/users/ryi06/repos","events_url":"https://api.github.com/users/ryi06/events{/privacy}","received_events_url":"https://api.github.com/users/ryi06/received_events","type":"User","site_admin":false},"repo":{"id":61826702,"name":"inferelator_ng","full_name":"ryi06/inferelator_ng","owner":{"login":"ryi06","id":10792267,"avatar_url":"https://avatars.githubusercontent.com/u/10792267?v=3","gravatar_id":"","url":"https://api.github.com/users/ryi06","html_url":"https://github.com/ryi06","followers_url":"https://api.github.com/users/ryi06/followers","following_url":"https://api.github.com/users/ryi06/following{/other_user}","gists_url":"https://api.github.com/users/ryi06/gists{/gist_id}","starred_url":"https://api.github.com/users/ryi06/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryi06/subscriptions","organizations_url":"https://api.github.com/users/ryi06/orgs","repos_url":"https://api.github.com/users/ryi06/repos","events_url":"https://api.github.com/users/ryi06/events{/privacy}","received_events_url":"https://api.github.com/users/ryi06/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ryi06/inferelator_ng","description":"Inferelator refactor and generalization.","fork":true,"url":"https://api.github.com/repos/ryi06/inferelator_ng","forks_url":"https://api.github.com/repos/ryi06/inferelator_ng/forks","keys_url":"https://api.github.com/repos/ryi06/inferelator_ng/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ryi06/inferelator_ng/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ryi06/inferelator_ng/teams","hooks_url":"https://api.github.com/repos/ryi06/inferelator_ng/hooks","issue_events_url":"https://api.github.com/repos/ryi06/inferelator_ng/issues/events{/number}","events_url":"https://api.github.com/repos/ryi06/inferelator_ng/events","assignees_url":"https://api.github.com/repos/ryi06/inferelator_ng/assignees{/user}","branches_url":"https://api.github.com/repos/ryi06/inferelator_ng/branches{/branch}","tags_url":"https://api.github.com/repos/ryi06/inferelator_ng/tags","blobs_url":"https://api.github.com/repos/ryi06/inferelator_ng/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ryi06/inferelator_ng/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ryi06/inferelator_ng/git/refs{/sha}","trees_url":"https://api.github.com/repos/ryi06/inferelator_ng/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ryi06/inferelator_ng/statuses/{sha}","languages_url":"https://api.github.com/repos/ryi06/inferelator_ng/languages","stargazers_url":"https://api.github.com/repos/ryi06/inferelator_ng/stargazers","contributors_url":"https://api.github.com/repos/ryi06/inferelator_ng/contributors","subscribers_url":"https://api.github.com/repos/ryi06/inferelator_ng/subscribers","subscription_url":"https://api.github.com/repos/ryi06/inferelator_ng/subscription","commits_url":"https://api.github.com/repos/ryi06/inferelator_ng/commits{/sha}","git_commits_url":"https://api.github.com/repos/ryi06/inferelator_ng/git/commits{/sha}","comments_url":"https://api.github.com/repos/ryi06/inferelator_ng/comments{/number}","issue_comment_url":"https://api.github.com/repos/ryi06/inferelator_ng/issues/comments{/number}","contents_url":"https://api.github.com/repos/ryi06/inferelator_ng/contents/{+path}","compare_url":"https://api.github.com/repos/ryi06/inferelator_ng/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ryi06/inferelator_ng/merges","archive_url":"https://api.github.com/repos/ryi06/inferelator_ng/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ryi06/inferelator_ng/downloads","issues_url":"https://api.github.com/repos/ryi06/inferelator_ng/issues{/number}","pulls_url":"https://api.github.com/repos/ryi06/inferelator_ng/pulls{/number}","milestones_url":"https://api.github.com/repos/ryi06/inferelator_ng/milestones{/number}","notifications_url":"https://api.github.com/repos/ryi06/inferelator_ng/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ryi06/inferelator_ng/labels{/name}","releases_url":"https://api.github.com/repos/ryi06/inferelator_ng/releases{/id}","deployments_url":"https://api.github.com/repos/ryi06/inferelator_ng/deployments","created_at":"2016-06-23T18:13:47Z","updated_at":"2016-06-29T04:50:57Z","pushed_at":"2016-07-26T17:59:10Z","git_url":"git://github.com/ryi06/inferelator_ng.git","ssh_url":"git@github.com:ryi06/inferelator_ng.git","clone_url":"https://github.com/ryi06/inferelator_ng.git","svn_url":"https://github.com/ryi06/inferelator_ng","homepage":"","size":255,"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":"simonsfoundation:master","ref":"master","sha":"8b0f7dba1be1c47107add90be1c6ca0be4791b1d","user":{"login":"simonsfoundation","id":7658073,"avatar_url":"https://avatars.githubusercontent.com/u/7658073?v=3","gravatar_id":"","url":"https://api.github.com/users/simonsfoundation","html_url":"https://github.com/simonsfoundation","followers_url":"https://api.github.com/users/simonsfoundation/followers","following_url":"https://api.github.com/users/simonsfoundation/following{/other_user}","gists_url":"https://api.github.com/users/simonsfoundation/gists{/gist_id}","starred_url":"https://api.github.com/users/simonsfoundation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simonsfoundation/subscriptions","organizations_url":"https://api.github.com/users/simonsfoundation/orgs","repos_url":"https://api.github.com/users/simonsfoundation/repos","events_url":"https://api.github.com/users/simonsfoundation/events{/privacy}","received_events_url":"https://api.github.com/users/simonsfoundation/received_events","type":"Organization","site_admin":false},"repo":{"id":61822570,"name":"inferelator_ng","full_name":"simonsfoundation/inferelator_ng","owner":{"login":"simonsfoundation","id":7658073,"avatar_url":"https://avatars.githubusercontent.com/u/7658073?v=3","gravatar_id":"","url":"https://api.github.com/users/simonsfoundation","html_url":"https://github.com/simonsfoundation","followers_url":"https://api.github.com/users/simonsfoundation/followers","following_url":"https://api.github.com/users/simonsfoundation/following{/other_user}","gists_url":"https://api.github.com/users/simonsfoundation/gists{/gist_id}","starred_url":"https://api.github.com/users/simonsfoundation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simonsfoundation/subscriptions","organizations_url":"https://api.github.com/users/simonsfoundation/orgs","repos_url":"https://api.github.com/users/simonsfoundation/repos","events_url":"https://api.github.com/users/simonsfoundation/events{/privacy}","received_events_url":"https://api.github.com/users/simonsfoundation/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/simonsfoundation/inferelator_ng","description":"Inferelator refactor and generalization.","fork":false,"url":"https://api.github.com/repos/simonsfoundation/inferelator_ng","forks_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/forks","keys_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/keys{/key_id}","collaborators_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/teams","hooks_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/hooks","issue_events_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/issues/events{/number}","events_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/events","assignees_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/assignees{/user}","branches_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/branches{/branch}","tags_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/tags","blobs_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/git/refs{/sha}","trees_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/git/trees{/sha}","statuses_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/statuses/{sha}","languages_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/languages","stargazers_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/stargazers","contributors_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/contributors","subscribers_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/subscribers","subscription_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/subscription","commits_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/commits{/sha}","git_commits_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/git/commits{/sha}","comments_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/comments{/number}","issue_comment_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/issues/comments{/number}","contents_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/contents/{+path}","compare_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/compare/{base}...{head}","merges_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/merges","archive_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/downloads","issues_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/issues{/number}","pulls_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/pulls{/number}","milestones_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/milestones{/number}","notifications_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/labels{/name}","releases_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/releases{/id}","deployments_url":"https://api.github.com/repos/simonsfoundation/inferelator_ng/deployments","created_at":"2016-06-23T17:05:23Z","updated_at":"2016-06-29T03:07:43Z","pushed_at":"2016-08-01T19:08:29Z","git_url":"git://github.com/simonsfoundation/inferelator_ng.git","ssh_url":"git@github.com:simonsfoundation/inferelator_ng.git","clone_url":"https://github.com/simonsfoundation/inferelator_ng.git","svn_url":"https://github.com/simonsfoundation/inferelator_ng","homepage":"","size":247,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":4,"forks":8,"open_issues":4,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/simonsfoundation/inferelator_ng/pulls/17"},"html":{"href":"https://github.com/simonsfoundation/inferelator_ng/pull/17"},"issue":{"href":"https://api.github.com/repos/simonsfoundation/inferelator_ng/issues/17"},"comments":{"href":"https://api.github.com/repos/simonsfoundation/inferelator_ng/issues/17/comments"},"review_comments":{"href":"https://api.github.com/repos/simonsfoundation/inferelator_ng/pulls/17/comments"},"review_comment":{"href":"https://api.github.com/repos/simonsfoundation/inferelator_ng/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/simonsfoundation/inferelator_ng/pulls/17/commits"},"statuses":{"href":"https://api.github.com/repos/simonsfoundation/inferelator_ng/statuses/5ee2709997228e7e53f600a59a8928c92174b141"}}}}
{"actor":{"display_login":"e5c"}}