{"action":"created","issue":{"url":"https://api.github.com/repos/tanghaibao/goatools/issues/96","repository_url":"https://api.github.com/repos/tanghaibao/goatools","labels_url":"https://api.github.com/repos/tanghaibao/goatools/issues/96/labels{/name}","comments_url":"https://api.github.com/repos/tanghaibao/goatools/issues/96/comments","events_url":"https://api.github.com/repos/tanghaibao/goatools/issues/96/events","html_url":"https://github.com/tanghaibao/goatools/issues/96","id":304712525,"number":96,"title":"All values in `table` must be nonnegative","user":{"login":"alexmascension","id":35657291,"avatar_url":"https://avatars2.githubusercontent.com/u/35657291?v=4","gravatar_id":"","url":"https://api.github.com/users/alexmascension","html_url":"https://github.com/alexmascension","followers_url":"https://api.github.com/users/alexmascension/followers","following_url":"https://api.github.com/users/alexmascension/following{/other_user}","gists_url":"https://api.github.com/users/alexmascension/gists{/gist_id}","starred_url":"https://api.github.com/users/alexmascension/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexmascension/subscriptions","organizations_url":"https://api.github.com/users/alexmascension/orgs","repos_url":"https://api.github.com/users/alexmascension/repos","events_url":"https://api.github.com/users/alexmascension/events{/privacy}","received_events_url":"https://api.github.com/users/alexmascension/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-03-13T10:45:39Z","updated_at":"2018-03-14T08:52:52Z","closed_at":null,"author_association":"NONE","body":"When running the program I occasionally came across this error:\r\n\r\n_Calculating uncorrected p-values using fisher_scipy_stats\r\n   913 out of  1,186 study items found in association_\r\n_Traceback (most recent call last):\r\n...\r\n  File \"/home/xxx/Programs/xxx/SET.py\", line 1883, in gene_ontology\r\n    goea_results_all = goeaobj.run_study(geneids_study) #This are all the GOEA results\r\n  File \"/home/ra/anaconda3/lib/python3.5/site-packages/goatools/go_enrichment.py\", line 266, in run_study\r\n    results = self.get_pval_uncorr(study, log)\r\n  File \"/home/ra/anaconda3/lib/python3.5/site-packages/goatools/go_enrichment.py\", line 331, in get_pval_uncorr\r\n    p_uncorrected=calc_pvalue(study_count, study_n, pop_count, pop_n),\r\n  File \"/home/ra/anaconda3/lib/python3.5/site-packages/goatools/pvalcalc.py\", line 67, in calc_pvalue\r\n    _, p_uncorrected = self.pval_fnc( [[a, b], [c, d]])\r\n  File \"/home/ra/anaconda3/lib/python3.5/site-packages/scipy/stats/stats.py\", line 3083, in fisher_exact\r\n    raise ValueError(\"All values in `table` must be nonnegative.\")\r\nValueError: All values in `table` must be nonnegative._\r\n\r\nI installed GOEA with anaconda (`conda install -c bioconda goatools`). I later added on to the site-packages dir the genes_NCBI .py files for 10090 and 9606. In some samples the error occurred and in others did not, so I don't know to what extent the error should be in the go_enrichment.py code or in my data.\r\n\r\nI used a workaround in the go_enrichment.py file by adding a try/except clause (lines 322 onwards) in the get_pval_uncorr method:\r\n\r\n```python\r\ndef get_pval_uncorr(self, study, log=sys.stdout):\r\n        \"\"\"Calculate the uncorrected pvalues for study items.\"\"\"\r\n        if log is not None:\r\n            log.write(\"Calculating uncorrected p-values using {PFNC}\\n\".format(\r\n                PFNC=self.pval_obj.name))\r\n        results = []\r\n        go2studyitems = get_terms(\"study\", study, self.assoc, self.obo_dag, log)\r\n        pop_n, study_n = self.pop_n, len(study)\r\n        allterms = set(go2studyitems.keys()).union(\r\n            set(self.go2popitems.keys()))\r\n        calc_pvalue = self.pval_obj.calc_pvalue\r\n        for term in allterms:\r\n            try:   # <-- INSERT\r\n                study_items = go2studyitems.get(term, set())\r\n                study_count = len(study_items)\r\n                pop_items = self.go2popitems.get(term, set())\r\n                pop_count = len(pop_items)\r\n\r\n                one_record = GOEnrichmentRecord(\r\n                    GO=term,\r\n                    p_uncorrected=calc_pvalue(study_count, study_n, pop_count, pop_n),\r\n                    study_items=study_items,\r\n                    pop_items=pop_items,\r\n                    ratio_in_study=(study_count, study_n),\r\n                    ratio_in_pop=(pop_count, pop_n))\r\n\r\n                results.append(one_record)\r\n            except ValueError: # <-- INSERT\r\n                print('{TERM} term had non-negative values.'.format(TERM=term)) # <-- INSERT\r\n\r\n        return results\r\n```\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/tanghaibao/goatools/issues/comments/372947218","html_url":"https://github.com/tanghaibao/goatools/issues/96#issuecomment-372947218","issue_url":"https://api.github.com/repos/tanghaibao/goatools/issues/96","id":372947218,"user":{"login":"alexmascension","id":35657291,"avatar_url":"https://avatars2.githubusercontent.com/u/35657291?v=4","gravatar_id":"","url":"https://api.github.com/users/alexmascension","html_url":"https://github.com/alexmascension","followers_url":"https://api.github.com/users/alexmascension/followers","following_url":"https://api.github.com/users/alexmascension/following{/other_user}","gists_url":"https://api.github.com/users/alexmascension/gists{/gist_id}","starred_url":"https://api.github.com/users/alexmascension/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexmascension/subscriptions","organizations_url":"https://api.github.com/users/alexmascension/orgs","repos_url":"https://api.github.com/users/alexmascension/repos","events_url":"https://api.github.com/users/alexmascension/events{/privacy}","received_events_url":"https://api.github.com/users/alexmascension/received_events","type":"User","site_admin":false},"created_at":"2018-03-14T08:52:52Z","updated_at":"2018-03-14T08:52:52Z","author_association":"NONE","body":"Here you are.\r\n\r\nhttps://drive.google.com/open?id=1d6ukUKfTswpKYsKV_-isGZeut47sV01J"}}
{"actor":{"display_login":"alexmascension"}}