Repository 'vapper'
hg clone https://toolshed.g2.bx.psu.edu/repos/johnheap/vapper

Changeset 19:fe79425b1fa4 (2019-06-03)
Previous changeset 18:e7da2274c9f6 (2019-06-03) Next changeset 20:26ec953069b3 (2019-06-03)
Commit message:
Uploaded
modified:
Tryp_V_T.py
b
diff -r e7da2274c9f6 -r fe79425b1fa4 Tryp_V_T.py
--- a/Tryp_V_T.py Mon Jun 03 16:00:24 2019 -0400
+++ b/Tryp_V_T.py Mon Jun 03 16:01:16 2019 -0400
[
b'@@ -1,2611 +1,425 @@\n-\n-\n-\n-\n-\n-\n-<!DOCTYPE html>\n-<html lang="en">\n-  <head>\n-    <meta charset="utf-8">\n-  <link rel="dns-prefetch" href="https://github.githubassets.com">\n-  <link rel="dns-prefetch" href="https://avatars0.githubusercontent.com">\n-  <link rel="dns-prefetch" href="https://avatars1.githubusercontent.com">\n-  <link rel="dns-prefetch" href="https://avatars2.githubusercontent.com">\n-  <link rel="dns-prefetch" href="https://avatars3.githubusercontent.com">\n-  <link rel="dns-prefetch" href="https://github-cloud.s3.amazonaws.com">\n-  <link rel="dns-prefetch" href="https://user-images.githubusercontent.com/">\n-\n-\n-\n-  <link crossorigin="anonymous" media="all" integrity="sha512-3+HOqCwtQal5hOJQ+mdxiq5zmGOTjF6RhjDsPLxbKDYgGlLFeCwzoIanb7j5IiCuXKUqyC2q8FdkC4nmx2P2rA==" rel="stylesheet" href="https://github.githubassets.com/assets/frameworks-a2fba223d5af91496cac70d4ec3624df.css" />\n-  <link crossorigin="anonymous" media="all" integrity="sha512-MRlTIqIyb8caK5+o8llXVntXovciHyAM4qE3kWU2S7SIjAPDxYp4mE0jQp4kP5UYegy+lG9y1I6VlsdzEjb5Qw==" rel="stylesheet" href="https://github.githubassets.com/assets/site-294181adec18ed639e160b96b45d17ac.css" />\n-    <link crossorigin="anonymous" media="all" integrity="sha512-XjvAy/mMWN5aOA+pyb/FgAgcVgJkPkwTCwvFK07Ez/H44lvl55ZLGwtpyL4MaMrwDE8QYO+1VYljKFjqr4/iJA==" rel="stylesheet" href="https://github.githubassets.com/assets/github-5b066aa36cc405c9cbcbadf1bde399ed.css" />\n-    \n-    \n-    \n-    \n-\n-  <meta name="viewport" content="width=device-width">\n-  \n-  <title>VAPPER-Galaxy/Tryp_V_T.py at master \xc2\xb7 johnheap/VAPPER-Galaxy \xc2\xb7 GitHub</title>\n-    <meta name="description" content="Contribute to johnheap/VAPPER-Galaxy development by creating an account on GitHub.">\n-    <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub">\n-  <link rel="fluid-icon" href="https://github.com/fluidicon.png" title="GitHub">\n-  <meta property="fb:app_id" content="1401488693436528">\n-\n-    <meta name="twitter:image:src" content="https://avatars0.githubusercontent.com/u/24318980?s=400&amp;v=4" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary" /><meta name="twitter:title" content="johnheap/VAPPER-Galaxy" /><meta name="twitter:description" content="Contribute to johnheap/VAPPER-Galaxy development by creating an account on GitHub." />\n-    <meta property="og:image" content="https://avatars0.githubusercontent.com/u/24318980?s=400&amp;v=4" /><meta property="og:site_name" content="GitHub" /><meta property="og:type" content="object" /><meta property="og:title" content="johnheap/VAPPER-Galaxy" /><meta property="og:url" content="https://github.com/johnheap/VAPPER-Galaxy" /><meta property="og:description" content="Contribute to johnheap/VAPPER-Galaxy development by creating an account on GitHub." />\n-\n-  <link rel="assets" href="https://github.githubassets.com/">\n-  \n-  <meta name="pjax-timeout" content="1000">\n-  \n-  <meta name="request-id" content="A691:31FC:5350A:9C70E:5CF5626C" data-pjax-transient>\n-\n-\n-  \n-\n-  <meta name="selected-link" value="repo_source" data-pjax-transient>\n-\n-      <meta name="google-site-verification" content="KT5gs8h0wvaagLKAVWq8bbeNwnZZK1r1XQysX3xurLU">\n-    <meta name="google-site-verification" content="ZzhVyEFwb7w3e0-uOTltm8Jsck2F5StVihD0exw2fsA">\n-    <meta name="google-site-verification" content="GXs5KoUUkNCoaAZn7wPN-t01Pywp9M3sEjnt_3_ZWPc">\n-\n-  <meta name="octolytics-host" content="collector.githubapp.com" /><meta name="octolytics-app-id" content="github" /><meta name="octolytics-event-url" content="https://collector.githubapp.com/github-external/browser_event" /><meta name="octolytics-dimension-request_id" content="A691:31FC:5350A:9C70E:5CF5626C" /><meta name="octolytics-dimension-region_edge" content="iad" /><meta name="octolytics-dimension-region_render" content="iad" />\n-<meta name="analytics-location" content="/&lt;user-name&gt;/&lt;repo-name&gt;/blob/show" data-pjax-transient="true" />\n-\n-\n-\n-    <m'..b'igsize=(10,ysize))\r\n+\r\n+\r\n+    for s in range(1, len(labelList)):\r\n+        ax.barh(ind, composite_df[labelList[s]], width, color=palette[s], label=labelList[s])\r\n+        ind = ind + width\r\n+\r\n+    ax.set(yticks=np.arange(width*(sampnum+2)/2, len(composite_df)*width*(sampnum+1), width*(sampnum+1)), yticklabels=composite_df[\'Phylotype\']) # , ylim=[(len(labelList)-1) * width - 1, len(composite_df)])\r\n+    ax.legend()\r\n+\r\n+\r\n+    ax.set_ylabel(\'Phylotype\')\r\n+    ax.invert_yaxis()  # labels read top-to-bottom\r\n+    ax.set_xlabel(\'Weighted Phylotype Frequency\')\r\n+\r\n+    # plt.text(-0.3, -0.15, title, va="top", wrap="True")\r\n+    #plt.tight_layout()\r\n+\r\n+    plt.subplots_adjust(bottom=0.1, top=0.92, left=0.15, right=0.9)\r\n+    ax.set_title(title, x=0, wrap=\'True\',ha=\'left\',)\r\n+\r\n+    plt.savefig(tdict[\'html_resource\'] + tdict[\'name\']+"_phylotypes.png")\r\n+    if tdict[\'pdf\'] == \'PDF_Yes\':\r\n+        plt.savefig(tdict[\'html_resource\'] + tdict[\'name\']+"phylotypes.pdf")\r\n+    plt.show()\r\n+    pass\r\n+\r\n+\r\n+\r\n+def doBarChart(tdict, sum2_df):\r\n+    cmap = plt.cm.get_cmap(\'tab20\')\r\n+    palette = [cmap(i) for i in range(cmap.N)]\r\n+    title = "Legend: Variant Antigen Profile of a $\\itTrypanosoma$ $\\itvivax$ transcriptome. " \\\r\n+            "Phylotype abundance is expressed as phylotype frequencies adjusted " \\\r\n+            "for combined transcript abundance. " \\\r\n+            "Data was produced with VAPPER-Variant Antigen Profiler (Silva Pereira et al., 2019)."\r\n+       # get a list of phylotype, create equivalent of saccver, get a list of\r\n+    maxFPKM = sum2_df[\'FPKM\'].max()\r\n+    total = sum2_df[\'FPKM\'].sum()\r\n+\r\n+    sum2_df[\'Normalised\'] = sum2_df.apply(lambda row: normalisef(row[\'FPKM\'], maxFPKM),axis=1)\r\n+    sum2_df[\'Weighted\'] = sum2_df.apply(lambda row: normalisef(row[\'FPKM\'], total),axis=1)\r\n+    pList = sum2_df[\'Phylotype\']\r\n+    phList = []\r\n+    for p in pList:\r\n+        phList.append(str(p))\r\n+\r\n+    fList = sum2_df[\'Weighted\']\r\n+    ysize = len(phList)*0.3\r\n+    fig, ax = plt.subplots(figsize=(10,ysize))\r\n+\r\n+    ax.barh(phList, fList, color=palette)\r\n+    ax.set_ylabel(\'Phylotype\')\r\n+    ax.invert_yaxis()  # labels read top-to-bottom\r\n+    ax.set_xlabel(\'Weighted Phylotype Frequency\')\r\n+\r\n+    # plt.text(-0.3, -0.15, title, va="top", wrap="True")\r\n+    #plt.tight_layout()\r\n+    plt.subplots_adjust(bottom=0.1, top=0.9, left=0.15, right=0.9)\r\n+    ax.set_title(title, x=0, wrap=\'True\',ha=\'left\',)\r\n+\r\n+    plt.savefig(tdict[\'html_resource\'] + tdict[\'name\']+"_phylotypes.png")\r\n+    if tdict[\'pdf\'] == \'PDF_Yes\':\r\n+        plt.savefig(tdict[\'html_resource\'] + tdict[\'name\']+"phylotypes.pdf")\r\n+    # plt.show()\r\n+    pass\r\n+\r\n+# argdict = {\'name\':2, \'pdfexport\': 3, \'refFastq\': 4, \'forward\': 5, \'reverse\': 6, \'html_file\': 7, \'html_resource\': 8}\r\n+\r\n+def transcriptomicProcess(args,argdict):\r\n+    tdict = {}\r\n+    tdict[\'name\'] = args[argdict[\'name\']]\r\n+    tdict[\'refFastq\'] = args[argdict[\'refFastq\']]\r\n+    tdict[\'forward\'] = args[argdict[\'forward\']]\r\n+    tdict[\'reverse\'] = args[argdict[\'reverse\']]\r\n+    tdict[\'vivax_trans_database\'] = \'data/vivax/Database/Phylotype_typeseqs.fas\'\r\n+    tdict[\'pdf\'] = args[argdict[\'pdfexport\']]\r\n+    tdict[\'html_file\'] = args[argdict[\'html_file\']]\r\n+    tdict[\'html_resource\'] = args[argdict[\'html_resource\']]\r\n+    \r\n+    uploadUserReferenceFastq(tdict[\'refFastq\'])\r\n+    transcriptMapping(tdict[\'name\'], tdict[\'refFastq\'], tdict[\'forward\'], tdict[\'reverse\'])        #uses bowtie\r\n+    processSamFiles(tdict[\'name\'])                              #uses samtools\r\n+    transcriptAbundance(tdict[\'name\'])                          #uses cufflinks -> ?.cuff/*.*\r\n+    transcriptsForBlast(tdict[\'name\'], tdict[\'refFastq\'])       #creates name+4blast.fa\r\n+    blastContigs(tdict[\'name\'], tdict[\'html_resource\'], \'data/vivax/Database/Phylotype_typeseqs.fas\')\r\n+    sum_df, sum2_df = combineFPMK(tdict)\r\n+    doBarChart(tdict, sum2_df)\r\n+    createHTML(tdict, sum_df)\r\n+\r\n+\r\n+if __name__ == "__main__":\r\n+    exit()\r\n+\r\n+\r\n'