{ "cells": [ { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "library(\"vegan\")\n", "\n", "setwd(dir = \"~/miseq/ReverseTrans/\")\n", "df1 = read.csv(\"normalized_tab.csv\")\n", "\n", "mapping = read.csv(\"mapping.csv\", sep = \"\\t\")\n", "\n", "rownames(df1) = df1[,1]\n", "\n", "df1 = df1[,-1]\n", "df1 = t(df1)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "species_diversity = specpool(df1, rownames(df1))\n", "\n", "df1Shannon = diversity(df1, index = \"shannon\",base = exp(1))\n", "df1Pielou = df1Shannon/log(rowSums(df1),base = exp(1))" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\n", "
NameEnzymeSpeciesShannonPielou
1Osnat037 TGIRT 1753 6.376924 0.6923657
4Osnat040 TGIRT 1732 6.079408 0.6600633
5Osnat041 TGIRT 1595 5.950627 0.6460811
6Osnat042 TGIRT 1542 6.049250 0.6567890
7Osnat043 TGIRT 1558 6.148981 0.6676172
8Osnat044 SuperScriptIV1723 6.381981 0.6929147
10Osnat046 SuperScriptIV1604 5.934493 0.6443294
11Osnat047 SuperScriptIV1794 6.116224 0.6640606
13Osnat049 SuperScriptIV1470 6.017251 0.6533147
14Osnat050 SuperScriptIV1412 6.099111 0.6622025
15Osnat051 Promega42 1199 6.139135 0.6665481
16Osnat052 Promega42 1499 5.727399 0.6218445
17Osnat053 Promega42 1582 5.988915 0.6502381
18Osnat054 Promega42 1049 5.427566 0.5892905
21Osnat057 Promega42 1548 6.190277 0.6721008
22Osnat058 Promega55 1689 6.177508 0.6707144
25Osnat061 Promega55 1535 5.969043 0.6480806
26Osnat062 Promega55 1532 6.140683 0.6667162
27Osnat063 Promega55 1416 5.951154 0.6461384
28Osnat064 Promega55 1268 5.825569 0.6325031
\n" ], "text/latex": [ "\\begin{tabular}{r|lllll}\n", " & Name & Enzyme & Species & Shannon & Pielou\\\\\n", "\\hline\n", "\t1 & Osnat037 & TGIRT & 1753 & 6.376924 & 0.6923657 \\\\\n", "\t4 & Osnat040 & TGIRT & 1732 & 6.079408 & 0.6600633 \\\\\n", "\t5 & Osnat041 & TGIRT & 1595 & 5.950627 & 0.6460811 \\\\\n", "\t6 & Osnat042 & TGIRT & 1542 & 6.049250 & 0.6567890 \\\\\n", "\t7 & Osnat043 & TGIRT & 1558 & 6.148981 & 0.6676172 \\\\\n", "\t8 & Osnat044 & SuperScriptIV & 1723 & 6.381981 & 0.6929147 \\\\\n", "\t10 & Osnat046 & SuperScriptIV & 1604 & 5.934493 & 0.6443294 \\\\\n", "\t11 & Osnat047 & SuperScriptIV & 1794 & 6.116224 & 0.6640606 \\\\\n", "\t13 & Osnat049 & SuperScriptIV & 1470 & 6.017251 & 0.6533147 \\\\\n", "\t14 & Osnat050 & SuperScriptIV & 1412 & 6.099111 & 0.6622025 \\\\\n", "\t15 & Osnat051 & Promega42 & 1199 & 6.139135 & 0.6665481 \\\\\n", "\t16 & Osnat052 & Promega42 & 1499 & 5.727399 & 0.6218445 \\\\\n", "\t17 & Osnat053 & Promega42 & 1582 & 5.988915 & 0.6502381 \\\\\n", "\t18 & Osnat054 & Promega42 & 1049 & 5.427566 & 0.5892905 \\\\\n", "\t21 & Osnat057 & Promega42 & 1548 & 6.190277 & 0.6721008 \\\\\n", "\t22 & Osnat058 & Promega55 & 1689 & 6.177508 & 0.6707144 \\\\\n", "\t25 & Osnat061 & Promega55 & 1535 & 5.969043 & 0.6480806 \\\\\n", "\t26 & Osnat062 & Promega55 & 1532 & 6.140683 & 0.6667162 \\\\\n", "\t27 & Osnat063 & Promega55 & 1416 & 5.951154 & 0.6461384 \\\\\n", "\t28 & Osnat064 & Promega55 & 1268 & 5.825569 & 0.6325031 \\\\\n", "\\end{tabular}\n" ], "text/markdown": [ "\n", "| | Name | Enzyme | Species | Shannon | Pielou | \n", "|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|\n", "| 1 | Osnat037 | TGIRT | 1753 | 6.376924 | 0.6923657 | \n", "| 4 | Osnat040 | TGIRT | 1732 | 6.079408 | 0.6600633 | \n", "| 5 | Osnat041 | TGIRT | 1595 | 5.950627 | 0.6460811 | \n", "| 6 | Osnat042 | TGIRT | 1542 | 6.049250 | 0.6567890 | \n", "| 7 | Osnat043 | TGIRT | 1558 | 6.148981 | 0.6676172 | \n", "| 8 | Osnat044 | SuperScriptIV | 1723 | 6.381981 | 0.6929147 | \n", "| 10 | Osnat046 | SuperScriptIV | 1604 | 5.934493 | 0.6443294 | \n", "| 11 | Osnat047 | SuperScriptIV | 1794 | 6.116224 | 0.6640606 | \n", "| 13 | Osnat049 | SuperScriptIV | 1470 | 6.017251 | 0.6533147 | \n", "| 14 | Osnat050 | SuperScriptIV | 1412 | 6.099111 | 0.6622025 | \n", "| 15 | Osnat051 | Promega42 | 1199 | 6.139135 | 0.6665481 | \n", "| 16 | Osnat052 | Promega42 | 1499 | 5.727399 | 0.6218445 | \n", "| 17 | Osnat053 | Promega42 | 1582 | 5.988915 | 0.6502381 | \n", "| 18 | Osnat054 | Promega42 | 1049 | 5.427566 | 0.5892905 | \n", "| 21 | Osnat057 | Promega42 | 1548 | 6.190277 | 0.6721008 | \n", "| 22 | Osnat058 | Promega55 | 1689 | 6.177508 | 0.6707144 | \n", "| 25 | Osnat061 | Promega55 | 1535 | 5.969043 | 0.6480806 | \n", "| 26 | Osnat062 | Promega55 | 1532 | 6.140683 | 0.6667162 | \n", "| 27 | Osnat063 | Promega55 | 1416 | 5.951154 | 0.6461384 | \n", "| 28 | Osnat064 | Promega55 | 1268 | 5.825569 | 0.6325031 | \n", "\n", "\n" ], "text/plain": [ " Name Enzyme Species Shannon Pielou \n", "1 Osnat037 TGIRT 1753 6.376924 0.6923657\n", "4 Osnat040 TGIRT 1732 6.079408 0.6600633\n", "5 Osnat041 TGIRT 1595 5.950627 0.6460811\n", "6 Osnat042 TGIRT 1542 6.049250 0.6567890\n", "7 Osnat043 TGIRT 1558 6.148981 0.6676172\n", "8 Osnat044 SuperScriptIV 1723 6.381981 0.6929147\n", "10 Osnat046 SuperScriptIV 1604 5.934493 0.6443294\n", "11 Osnat047 SuperScriptIV 1794 6.116224 0.6640606\n", "13 Osnat049 SuperScriptIV 1470 6.017251 0.6533147\n", "14 Osnat050 SuperScriptIV 1412 6.099111 0.6622025\n", "15 Osnat051 Promega42 1199 6.139135 0.6665481\n", "16 Osnat052 Promega42 1499 5.727399 0.6218445\n", "17 Osnat053 Promega42 1582 5.988915 0.6502381\n", "18 Osnat054 Promega42 1049 5.427566 0.5892905\n", "21 Osnat057 Promega42 1548 6.190277 0.6721008\n", "22 Osnat058 Promega55 1689 6.177508 0.6707144\n", "25 Osnat061 Promega55 1535 5.969043 0.6480806\n", "26 Osnat062 Promega55 1532 6.140683 0.6667162\n", "27 Osnat063 Promega55 1416 5.951154 0.6461384\n", "28 Osnat064 Promega55 1268 5.825569 0.6325031" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "df2 = mapping[mapping$Name %in% rownames(df1),]\n", "\n", "df2$Species = species_diversity$Species\n", "df2$Shannon = df1Shannon\n", "df2$Pielou = df1Pielou\n", "\n", "df2" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\n", "\tPairwise comparisons using t tests with pooled SD \n", "\n", "data: df2$Species and df2$Enzyme \n", "\n", " Promega42 Promega55 SuperScriptIV\n", "Promega55 0.38 - - \n", "SuperScriptIV 0.16 0.38 - \n", "TGIRT 0.16 0.38 0.75 \n", "\n", "P value adjustment method: BH " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "pairwise.t.test(x = df2$Species, g = df2$Enzyme, p.adjust.method = \"BH\")" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\n", "\tPairwise comparisons using t tests with pooled SD \n", "\n", "data: df2$Pielou and df2$Enzyme \n", "\n", " Promega42 Promega55 SuperScriptIV\n", "Promega55 0.57 - - \n", "SuperScriptIV 0.37 0.57 - \n", "TGIRT 0.37 0.57 0.93 \n", "\n", "P value adjustment method: BH " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "pairwise.t.test(x = df2$Pielou, g = df2$Enzyme, p.adjust.method = \"BH\")" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\n", "\tPairwise comparisons using t tests with pooled SD \n", "\n", "data: df2$Shannon and df2$Enzyme \n", "\n", " Promega42 Promega55 SuperScriptIV\n", "Promega55 0.57 - - \n", "SuperScriptIV 0.37 0.57 - \n", "TGIRT 0.37 0.57 0.93 \n", "\n", "P value adjustment method: BH " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "pairwise.t.test(x = df2$Shannon, g = df2$Enzyme, p.adjust.method = \"BH\")" ] } ], "metadata": { "kernelspec": { "display_name": "R", "language": "R", "name": "ir" }, "language_info": { "codemirror_mode": "r", "file_extension": ".r", "mimetype": "text/x-r-source", "name": "R", "pygments_lexer": "r", "version": "3.5.1" } }, "nbformat": 4, "nbformat_minor": 2 }