Repository 'cpm_tpm_rpk'
hg clone https://toolshed.g2.bx.psu.edu/repos/artbio/cpm_tpm_rpk

Changeset 3:8b1020c25f0f (2019-04-12)
Previous changeset 2:563337e780ce (2019-02-06) Next changeset 4:be358a1ebf67 (2023-10-05)
Commit message:
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/cpm_tpm_rpk commit 9149001c65de633ddfd2f91cf208074e40482ce3
modified:
cpm_tpm_rpk.R
cpm_tpm_rpk.xml
test-data/pca.nolab.pdf
test-data/pca.pdf
test-data/tsne.nolab.pdf
test-data/tsne.pdf
added:
test-data/none.tab
test-data/none_pca.pdf
test-data/none_tsne.pdf
b
diff -r 563337e780ce -r 8b1020c25f0f cpm_tpm_rpk.R
--- a/cpm_tpm_rpk.R Wed Feb 06 19:31:57 2019 -0500
+++ b/cpm_tpm_rpk.R Fri Apr 12 12:01:35 2019 -0400
[
@@ -29,7 +29,7 @@
     c("-t", "--type"),
     default = 'cpm',
     type = 'character',
-    help = "Transformation type, either cpm, tpm or rpk [default : '%default' ]"
+    help = "Transformation type, either cpm, tpm, rpk or none[default : '%default' ]"
   ),
   make_option(
     c("-s", "--sep"),
@@ -127,7 +127,7 @@
 } else if ((opt$type == "tpm" | opt$type == "rpk") & opt$gene == "") {
   stop("At least two arguments must be supplied (count data and gene length file).\n",
        call. = FALSE)
-} else if (opt$type != "tpm" & opt$type != "rpk" & opt$type != "cpm") {
+} else if (opt$type != "tpm" & opt$type != "rpk" & opt$type != "cpm" & opt$type != "none") {
   stop("Wrong transformation requested (--type option) must be : cpm, tpm or rpk.\n",
        call. = FALSE)
 }
@@ -153,6 +153,7 @@
 
 data = read.table(
   opt$data,
+  check.names = FALSE,
   header = opt$colnames,
   row.names = 1,
   sep = opt$sep
@@ -177,6 +178,8 @@
   res = as.data.frame(apply(data, 2, tpm, length = gene_length), row.names = rownames(data))
 if (opt$type == "rpk")
   res = as.data.frame(apply(data, 2, rpk, length = gene_length), row.names = rownames(data))
+if (opt$type == "none")
+  res = data
 colnames(res) = colnames(data)
 
 
@@ -206,7 +209,7 @@
   embedding$Class <- as.factor(sub("Class_", "", rownames(tdf)))
   gg_legend = theme(legend.position="none")
   ggplot(embedding, aes(x=V1, y=V2)) +
-    geom_point(size=1.25, color='red') +
+    geom_point(size=1, color='red') +
     gg_legend +
     xlab("") +
     ylab("") +
@@ -215,16 +218,20 @@
       geom_text(aes(label=Class),hjust=-0.2, vjust=-0.5, size=2.5, color='darkblue')
     }
   ggsave(file=opt$tsne_out, device="pdf")
-  # make PCA and plot result with ggfortify
+  # make PCA and plot result with ggfortify (autoplot)
   tdf.pca <- prcomp(tdf, center = TRUE, scale. = T)
   if (opt$tsne_labels == TRUE) {
-      autoplot(tdf.pca, shape=F, label=T, label.size=2.5, colour="darkred") +
+      autoplot(tdf.pca, shape=F, label=T, label.size=2.5, label.vjust=1.2,
+               label.hjust=1.2,
+               colour="darkblue") +
+      geom_point(size=1, color='red') +
       xlab(paste("PC1",summary(tdf.pca)$importance[2,1]*100, "%")) +
       ylab(paste("PC2",summary(tdf.pca)$importance[2,2]*100, "%")) +
       ggtitle('PCA')
       ggsave(file=opt$pca_out, device="pdf")   
       } else {
-      autoplot(tdf.pca, shape=T, colour="red") +
+      autoplot(tdf.pca, shape=T, colour="darkblue") +
+      geom_point(size=1, color='red') +
       xlab(paste("PC1",summary(tdf.pca)$importance[2,1]*100, "%")) +
       ylab(paste("PC2",summary(tdf.pca)$importance[2,2]*100, "%")) +
       ggtitle('PCA') 
b
diff -r 563337e780ce -r 8b1020c25f0f cpm_tpm_rpk.xml
--- a/cpm_tpm_rpk.xml Wed Feb 06 19:31:57 2019 -0500
+++ b/cpm_tpm_rpk.xml Fri Apr 12 12:01:35 2019 -0400
b
@@ -1,4 +1,4 @@
-<tool id="cpm_tpm_rpk" name="Generate CPM, TPM, RPK" version="0.3.0">
+<tool id="cpm_tpm_rpk" name="Generate CPM, TPM, RPK" version="0.4.0">
     <description>from raw counts expression values</description>
     <requirements>
         <requirement type="package" version="1.3.2=r3.3.2_0">r-optparse</requirement>
@@ -64,6 +64,7 @@
                     <option value="cpm" selected="true">CPM</option>
                     <option value="tpm">TPM</option>
                     <option value="rpk">RPK</option>
+                    <option value="none">NONE</option>
                 </param>
                 <when value="tpm">
                     <param name="gene_file" type="data" format="txt" label="Gene length file"/> 
@@ -97,6 +98,8 @@
                 </when>
                 <when value="cpm">
                 </when>
+                <when value="none">
+                </when>
             </conditional>
         <param name="log" type="select" label="Data should be log transformed ?">
             <option value="FALSE" selected="true">No</option>
@@ -108,10 +111,10 @@
                 <option value="yes" >t-SNE and PCA</option>
             </param>
             <when value="yes">
-                    <param name="seed" value="49.0" type="float" label="Seed value for reproducibility" help="Set to 49 as default" />
-                    <param name="perp" value="10.0" type="float" label="perplexity" help="should be less than ((nbre observations)-1)/3" /> 
-                    <param name="theta" value="1.0" type="float" label="theta"/>
-                    <param name="tsne_labels" type="select" label="Add labels to points in the t-SNE plot" >
+                    <param name="seed" value="49.0" type="float" label="Seed value for reproducibility of t-SNE" help="Set to 49 as default" />
+                    <param name="perp" value="10.0" type="float" label="perplexity (t-SNE)" help="should be less than ((nbre observations)-1)/3" /> 
+                    <param name="theta" value="1.0" type="float" label="theta (t-SNE)"/>
+                    <param name="tsne_labels" type="select" label="Add labels to points plots" >
                         <option value="no" selected="true">No Labels</option>
                         <option value="yes" >Label points</option>
                     </param>
@@ -136,6 +139,19 @@
     <tests>
         <!-- test t-SNE -->
         <test>
+            <param name="input" value="none.tab" ftype="tabular"/>
+            <param name="type_transfo" value="none"/>
+            <param name="log" value="FALSE"/>
+            <param name="visualisation" value="yes"/>
+            <param name="seed" value="49"/>
+            <param name="perp" value="10"/>
+            <param name="theta" value="1" />
+            <param name="tsne_labels" value="yes" />
+            <output name="output" file="none.tab" ftype="tabular"/>
+            <output name="tsne_out" file="none_tsne.pdf" ftype="pdf"/>
+            <output name="pca_out" file="none_pca.pdf" ftype="pdf"/>
+        </test>
+        <test>
             <param name="input" value="counts.tab" ftype="tabular"/>
             <param name="type_transfo" value="cpm"/>
             <param name="log" value="TRUE"/>
b
diff -r 563337e780ce -r 8b1020c25f0f test-data/none.tab
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/none.tab Fri Apr 12 12:01:35 2019 -0400
b
b'@@ -0,0 +1,216 @@\n+Features\t20nM_1\t20sM_4\t32nM_7\t32sM_10\t40nM_13\t40sM_16\t20n1d_a\t20n1d_b\t30n5h_c1\t30n5h_c2\t30s5h_c3\t30s5h_c4\t40n5h_c5\t40n5h_c6\t40s5h_c7\t40s5h_c8\t20n1d_c\t20s1d_d\t20s1d_e\t20s1d_f\t30n1d_g\t30n1d_h\t30n1d_i\t30s1d_j\t30s1d_k\t30s1d_l\t40n1d_m\t40n1d_n\t40n1d_o\t40s1d_p\t40s1d_q\t40s1d_r\n+5S_DM\t0\t0\t0\t0\t2.52271103749722\t0\t0\t1.46876851779219\t1.10607886502204\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t1.51278181441303\t2.52260597944523\t0\t0\t0\t2.05794942496048\t0.646139123391797\n+ACCORD2_I-int\t13.4694287027486\t19.7873189245625\t17.5674602110498\t50.6988197972739\t17.6589772624805\t19.313391508794\t18.1589910793351\t13.2189166601297\t12.1668675152425\t18.2343843151734\t26.0100186444685\t27.0989940048899\t23.1050300244153\t31.4819885379018\t24.4065408703064\t27.0644930469596\t9.83737686997288\t16.0386739801143\t14.5565923551731\t13.0633061628418\t25.016895793462\t24.992288899494\t17.9393955029792\t28.3792668127381\t19.8019745551662\t35.5503726387062\t17.6582418561166\t22.6167312355617\t26.939353284346\t26.4137500118019\t25.7243678120059\t41.9990430204668\n+ACCORD2_LTR\t0\t0.860318214111411\t0\t2.25328087987884\t3.78406655624583\t2.75905592982771\t1.13493694245845\t0\t2.21215773004408\t0\t4.0640654131982\t3.69531736430316\t1.84840240195322\t4.49742693398597\t1.10938822137756\t2.00477726273775\t0\t1.33655616500952\t0.970439490344876\t2.61266123256835\t4.46730282026107\t3.22481147090245\t2.4462812049517\t2.74638065929724\t2.47524681939578\t1.51278181441303\t0\t10.3660018162991\t2.78682965010476\t0\t1.02897471248024\t5.16911298713437\n+ACCORD_I-int\t16.1633144432983\t28.3905010656766\t29.6450891061465\t33.7992131981826\t18.9203327812291\t43.2252095673008\t30.643297446378\t19.0939907312984\t11.0607886502204\t53.8743172948305\t18.6947009007117\t23.4036766405867\t36.0438468380879\t25.1855908303214\t25.5159290916839\t48.114654305706\t16.3956281166215\t17.3752301451238\t16.4974713358629\t24.8202817093994\t36.6318831261408\t29.8295061058477\t34.2479368693238\t26.5483463732066\t24.7524681939578\t21.9353363089889\t31.5325747430654\t21.6743674340799\t22.2946372008381\t40.0760345006649\t40.1300137867293\t58.7986602286535\n+ACCORD_LTR\t0.897961913516572\t2.58095464233423\t0\t0\t0\t0\t0\t0\t0\t3.3153426027588\t0.812813082639639\t2.46354490953544\t1.84840240195322\t0\t1.10938822137756\t6.01433178821325\t0\t0\t0\t1.30633061628418\t0\t1.61240573545123\t1.63085413663447\t0.915460219765745\t0.825082273131927\t0\t0\t1.88472760296347\t0\t0\t5.14487356240119\t1.93841737017539\n+ALA_DM\t1.79592382703314\t0\t0\t0\t0\t0\t1.13493694245845\t0\t0\t0\t0\t0\t0\t0\t1.10938822137756\t0\t0\t0\t0\t0\t0\t0\t0\t1.83092043953149\t0\t0\t0\t0\t0\t0\t0\t0.646139123391797\n+ARS406_DM\t4.48980956758286\t8.60318214111411\t10.9796626319061\t14.6463257192125\t16.3976217437319\t8.27716778948314\t13.6192433095013\t2.93753703558437\t12.1668675152425\t14.0902060617249\t16.2562616527928\t8.62240718337405\t16.635621617579\t7.19588309437755\t15.5314350992859\t17.0406067332709\t21.8608374888286\t12.0290054850857\t14.5565923551731\t15.6759673954101\t12.508447896731\t18.5426659576891\t14.6776872297102\t11.9009828569547\t8.25082273131927\t18.1533817729563\t18.9195448458392\t14.1354570222261\t13.0052050338222\t6.37573276146942\t7.20282298736166\t14.8611998380113\n+BARI1\t16.1633144432983\t8.60318214111411\t17.5674602110498\t9.01312351951536\t16.3976217437319\t17.4740208889088\t10.214432482126\t10.2813796245453\t4.42431546008817\t11.6036991096558\t7.31531774375675\t17.2448143667481\t6.46940840683628\t8.99485386797193\t4.43755288551025\t14.0334408391642\t14.2095443677386\t13.3655616500952\t17.4679108262078\t23.5139510931152\t5.36076338431329\t11.2868401481586\t8.96969775148958\t15.5628237360177\t11.551151823847\t10.5894727008912\t6.30651494861307\t1.88472760296347\t10.2183753837175\t9.10818965924203\t9.26077241232214\t10.3382259742687\n+BARI_DM\t27.8368193190137\t18.0666824963396\t14.2735614214779\t15.7729661591519\t22.7043993374749\t14.7149649590811\t19.2939280217936\t36.7192129448047\t23.2276561654629\t18.2343843151734\t17.0690747354324\t13.5494970024449\t17.5598228185556\t17.0902223491467\t12.2032704351532\t25.0597157842219\t15.30258624218\t13.3655616500952\t17.4679108262078\t9.14431431398924\t18.7626718450965\t17.7364630899635\t17.9393955029792\t18.'..b'2454821\t46.5943052978576\t54.1289860939192\t45.9077587265401\t68.1643644154857\t70.8420827951759\t16.9822980116943\t50.9272521509762\t67.7210408889515\t48.9256240990341\t52.1812325266475\t48.6798541147837\t37.0631544531192\t34.0551807225106\t55.5994642874225\t50.1629337018857\t50.0950431258312\t23.6664183870455\t59.4447993520453\n+TRANSPAC_LTR\t8.08165722164915\t15.4857278540054\t9.8816963687155\t32.6725727582432\t10.0908441499889\t6.437797169598\t17.0240541368767\t5.87507407116875\t9.95470978519838\t21.5497269179322\t14.6306354875135\t17.2448143667481\t23.1050300244153\t9.89433925476913\t16.6408233206634\t32.076436203804\t10.9304187444143\t22.7214548051619\t22.3201082779321\t1.30633061628418\t12.508447896731\t23.3798831640428\t24.462812049517\t9.15460219765745\t18.9768922820343\t15.8842090513368\t12.6130298972261\t17.904912228153\t25.0814668509429\t20.0380172503325\t10.2897471248024\t27.1378431824555\n+Transib-N1_DM\t14.3673906162651\t12.9047732116712\t7.68576384233428\t4.50656175975768\t10.0908441499889\t12.875594339196\t10.214432482126\t11.7501481423375\t17.6972618403527\t3.3153426027588\t12.1921962395946\t4.92708981907089\t11.0904144117193\t3.59794154718877\t4.43755288551025\t11.0262749450576\t3.27912562332429\t13.3655616500952\t7.76351592275901\t6.53165308142088\t10.7215267686266\t4.83721720635368\t8.15427068317234\t15.5628237360177\t4.95049363879156\t13.6150363297173\t20.1808478355618\t4.71181900740868\t10.2183753837175\t4.55409482962101\t9.26077241232214\t9.04594772748515\n+Transib5\t1.79592382703314\t6.88254571289129\t0\t5.6332021996971\t0\t4.59842654971285\t2.26987388491689\t5.87507407116875\t4.42431546008817\t4.1441782534485\t0\t1.23177245476772\t3.69680480390645\t0.899485386797193\t0\t7.01672041958212\t0\t8.01933699005714\t8.73395541310388\t1.30633061628418\t5.36076338431329\t4.03101433862806\t4.07713534158617\t3.66184087906298\t4.12541136565963\t0.756390907206514\t0\t3.76945520592695\t2.78682965010476\t4.55409482962101\t1.02897471248024\t1.93841737017539\n+XDMR\t9.87758104868229\t12.9047732116712\t6.58779757914366\t1.12664043993942\t6.30677759374304\t6.437797169598\t11.3493694245845\t11.7501481423375\t14.3790252452865\t4.1441782534485\t10.5665700743153\t0\t2.77260360292984\t8.99485386797193\t7.76571754964293\t3.00716589410662\t9.83737686997288\t10.6924493200762\t5.82263694206925\t15.6759673954101\t8.93460564052215\t4.03101433862806\t8.15427068317234\t17.3937441755492\t11.551151823847\t12.8586454225107\t5.04521195889046\t8.48127421333563\t5.57365930020952\t2.73245689777261\t2.05794942496048\t5.16911298713437\n+XDMR_DM\t7.18369530813257\t5.16190928466847\t8.78373010552489\t0\t13.8749107062347\t3.67874123977028\t9.07949553966757\t8.81261110675312\t1.10607886502204\t3.3153426027588\t4.87687849583784\t9.85417963814177\t2.77260360292984\t8.99485386797193\t22.1877644275512\t5.01194315684437\t12.0234606188557\t10.6924493200762\t4.85219745172438\t9.14431431398924\t6.2542239483655\t4.83721720635368\t7.33884361485511\t5.49276131859447\t4.95049363879156\t7.56390907206514\t0\t9.42363801481737\t4.64471608350794\t8.19737069331783\t6.17384827488143\t3.87683474035078\n+ZAM_I-int\t35.0205146271463\t32.6920921362336\t35.1349204220995\t40.5590558378191\t22.7043993374749\t33.1086711579326\t35.1830452162118\t11.7501481423375\t32.0762870856392\t34.8110973289674\t33.3253363882252\t51.7344431002443\t44.3616576468774\t26.0850762171186\t32.1722584199493\t39.0931566233861\t31.6982143588015\t41.4332411152952\t43.6697770655194\t54.8658858839354\t28.5907380496709\t29.0233032381221\t37.5096451425928\t25.6328861534409\t39.6039491103325\t33.2811999170866\t23.9647568047297\t34.8674606548243\t37.1577286680635\t48.2734051939827\t33.9561655118478\t35.5376517865488\n+ZAM_LTR\t1.79592382703314\t1.72063642822282\t2.19593252638122\t3.37992131981826\t3.78406655624583\t1.83937061988514\t2.26987388491689\t0\t7.74255205515429\t17.4055486644837\t4.0640654131982\t1.23177245476772\t12.9388168136726\t4.49742693398597\t7.76571754964293\t3.00716589410662\t5.46520937220715\t2.67311233001905\t2.91131847103463\t6.53165308142088\t5.36076338431329\t0\t0.815427068317234\t0\t3.30032909252771\t4.53834544323909\t10.0904239177809\t7.53891041185389\t7.4315457336127\t7.28655172739362\t3.08692413744071\t3.87683474035078\n'
b
diff -r 563337e780ce -r 8b1020c25f0f test-data/none_pca.pdf
b
Binary file test-data/none_pca.pdf has changed
b
diff -r 563337e780ce -r 8b1020c25f0f test-data/none_tsne.pdf
b
Binary file test-data/none_tsne.pdf has changed
b
diff -r 563337e780ce -r 8b1020c25f0f test-data/pca.nolab.pdf
b
Binary file test-data/pca.nolab.pdf has changed
b
diff -r 563337e780ce -r 8b1020c25f0f test-data/pca.pdf
b
Binary file test-data/pca.pdf has changed
b
diff -r 563337e780ce -r 8b1020c25f0f test-data/tsne.nolab.pdf
b
Binary file test-data/tsne.nolab.pdf has changed
b
diff -r 563337e780ce -r 8b1020c25f0f test-data/tsne.pdf
b
Binary file test-data/tsne.pdf has changed