rbioinformaticslimma

Estimating differential regulation of metabolites in R


I have a metabolite data set with 25 resistant and 25 susceptible lines. Data looks like this, every column is a line and every row is a metabolite:

> dput(head(df,20))
structure(list(Metabolites = structure(1:20, .Label = c("M001", 
"M002", "M003", "M004", "M005", "M006", "M007", "M008", "M009", 
"M010", "M011", "M012", "M013", "M014", "M015", "M016", "M017", 
"M018", "M019", "M020", "M021", "M022", "M023", "M024", "M025", 
"M026", "M027", "M028", "M029", "M030", "M031", "M032", "M033", 
"M034", "M035", "M036", "M037", "M038", "M039", "M040", "M041", 
"M042", "M043", "M044", "M045", "M046", "M047", "M048", "M049", 
"M050", "M051", "M052", "M053", "M054", "M055", "M056", "M057", 
"M058", "M059", "M060", "M061", "M062", "M063", "M064", "M065", 
"M066", "M067", "M068", "M069", "M070", "M071", "M072", "M073", 
"M074", "M075", "M076", "M077", "M078", "M079", "M080", "M081", 
"M082", "M083", "M084", "M085", "M086", "M087", "M088", "M089", 
"M090", "M091", "M092", "M093", "M094", "M095", "M096", "M097", 
"M098", "M099", "M100", "M101", "M102", "M103", "M104", "M105", 
"M106", "M107", "M108", "M109", "M110", "M111", "M112", "M113", 
"M114", "M115", "M116", "M117", "M118", "M119", "M120", "M121", 
"M122", "M123", "M124", "M125", "M126", "M127", "M128", "M129", 
"M130", "M131", "M132", "M133", "M134", "M135", "M136", "M137", 
"M138", "M139", "M140", "M141", "M142", "M143", "M144", "M145", 
"M146", "M147", "M148", "M149", "M150", "M151", "M152", "M153", 
"M154", "M155", "M156", "M157", "M158", "M159", "M160", "M161", 
"M162", "M163", "M164", "M165", "M166", "M167", "M168", "M169", 
"M170", "M171", "M172", "M173", "M174", "M175", "M176", "M177", 
"M178", "M179", "M180", "M181", "M182", "M183", "M184", "M185", 
"M186", "M187", "M188", "M189", "M190", "M191", "M192", "M193", 
"M194", "M195", "M196", "M197", "M198", "M199", "M200", "M201", 
"M202", "M203", "M204", "M205", "M206", "M207", "M208", "M209", 
"M210", "M211", "M212", "M213", "M214", "M215", "M216", "M217", 
"M218", "M219", "M220", "M221", "M222", "M223", "M224", "M225", 
"M226", "M227", "M228", "M229", "M230", "M231", "M232", "M233", 
"M234", "M235", "M236", "M237", "M238", "M239", "M240", "M241", 
"M242", "M243", "M244", "M245", "M246", "M247", "M248", "M249", 
"M250", "M251", "M252", "M253", "M254", "M255", "M256", "M257", 
"M258", "M259", "M260", "M261", "M262", "M263", "M264", "M265", 
"M266", "M267", "M268", "M269", "M270", "M271", "M272", "M273", 
"M274", "M275", "M276", "M277", "M278", "M279", "M280", "M281", 
"M282", "M283", "M284", "M285", "M286", "M287", "M288", "M289", 
"M290", "M291", "M292", "M293", "M294", "M295", "M296", "M297", 
"M298", "M299", "M300", "M301", "M302", "M303", "M304", "M305", 
"M306", "M307", "M308", "M309", "M310", "M311", "M312", "M313", 
"M314", "M315", "M316", "M317", "M318", "M319", "M320", "M321", 
"M322", "M323", "M324", "M325", "M326", "M327", "M328", "M329", 
"M330", "M331", "M332", "M333", "M334", "M335", "M336", "M337", 
"M338", "M339", "M340", "M341", "M342", "M343", "M344", "M345", 
"M346", "M347", "M348", "M349", "M350", "M351", "M352", "M353", 
"M354", "M355", "M356", "M357", "M358", "M359", "M360", "M361", 
"M362", "M363", "M364", "M365", "M366", "M367", "M368", "M369", 
"M370", "M371", "M372", "M373", "M374", "M375", "M376", "M377", 
"M378", "M379", "M380", "M381", "M382", "M383", "M384", "M385", 
"M386", "M387", "M388", "M389", "M390", "M391", "M392", "M393", 
"M394", "M395", "M396", "M397", "M398", "M399", "M400", "M401", 
"M402", "M403", "M404", "M405", "M406", "M407", "M408", "M409", 
"M410", "M411", "M412", "M413", "M414", "M415", "M416", "M417", 
"M418", "M419", "M420", "M421", "M422", "M423", "M424", "M425", 
"M426", "M427", "M428", "M429", "M430", "M431", "M432", "M433", 
"M434", "M435", "M436", "M437", "M438", "M439", "M440", "M441", 
"M442", "M443", "M444", "M445", "M446", "M447", "M448", "M449", 
"M450", "M451", "M452", "M453", "M454", "M455", "M456", "M457", 
"M458", "M459", "M460", "M461", "M462", "M463", "M464", "M465", 
"M466", "M467", "M468", "M469", "M470", "M471", "M472", "M473", 
"M474", "M475", "M476", "M477", "M478", "M479", "M480", "M481", 
"M482", "M483", "M484", "M485", "M486", "M487", "M488", "M489", 
"M490", "M491", "M492", "M493", "M494", "M495", "M496", "M497", 
"M498", "M499", "M500", "M501", "M502", "M503", "M504", "M505", 
"M506", "M507", "M508", "M509", "M510", "M511", "M512", "M513", 
"M514", "M515", "M516", "M517", "M518", "M519", "M520", "M521", 
"M522", "M523", "M524", "M525", "M526", "M527", "M528", "M529", 
"M530", "M531", "M532", "M533", "M534"), class = "factor"), R = 
c(-0.368417113, 
-0.101138639, -0.161723188, 0.202453574, -0.255021436, 0.990889582, 
-0.14527723, 0.079853308, 0.029544276, 0.441221431, -0.11944612, 
-0.305230969, 0.03355256, 1.03727535, 0.320838857, 0.057860187, 
-0.220164171, -2.526670332, -0.367387096, 0.802085235), R.1 = c(0.335923239, 
3.061811172, -0.035662198, -0.607682577, 0.777607579, -0.058005603, 
1.137154667, 1.023908735, 0.028284344, -0.044308897, -0.411500613, 
1.399836977, 0.439845793, 2.247067657, -0.742871026, 1.568088682, 
0.11575394, 5.04122684, 2.374395515, 1.541474963), R.2 = c(-0.005240453, 
-0.298993563, -0.033124556, 0.000437247, -0.363018191, 0.326128083, 
0.21257698, -0.205006227, -0.091374353, -0.370715168, -0.267458783, 
0.248780422, 1.630503285, 1.874717025, 0.069540933, -0.436639754, 
0.133565845, -2.078394913, 0.540959939, -0.190331212), R.3 = c(0.02178722, 
0.571957417, 0.00324566, -0.061805284, 0.162608704, -0.325539348, 
-0.053329502, 0.227249242, -0.025090981, -0.080247253, 0.144508557, 
-0.088720932, 1.263644554, 0.996155965, 0.210446023, 1.990889582, 
0.076457177, 4.421971981, 0.198741153, -0.855116946), R.4 = c(0.006111685, 
0.021758841, -0.00737953, 0.380875266, -0.276248724, -0.011315313, 
-0.107602955, -0.104603974, 0.343158603, -0.457723898, -0.03562391, 
0.193219285, -0.063940821, 0.149473244, -0.019274012, -0.676331271, 
0.512558704, -0.994071688, 0.059564554, 1.429864917), R.5 = c(0.166168642, 
0.037674433, 0.086877451, -0.231273643, 0.221108542, -0.186011986, 
-0.089551585, -0.061788592, -0.018223759, 0.071986113, 0.101146723, 
-0.049779048, -0.518114903, 1.253322095, 0.216780998, 0.165038055, 
-0.439934372, 0.382512734, 0.421213338, 1.001105937), R.6 = c(-0.232768963, 
-0.261850899, -0.142152384, -0.342128282, -0.207394664, 0.031122517, 
-0.088355874, -0.324414618, 0.083484986, -0.381236261, -0.11649968, 
0.124415109, 0.358689609, 1.043033998, 0.038236206, -0.996719549, 
-0.01579871, -1.273254248, 0.551507204, 0.900665975), R.7 = c(-0.121204957, 
-0.269377573, 0.025763096, -0.370846136, 0.288406834, 0.110607324, 
-0.076961982, -0.629167859, -0.265012055, -0.505201609, -0.023481433, 
-0.17856392, 0.865332323, 0.524969082, -0.291204505, 0.719516623, 
-0.012732085, -1.941620399, 0.663526717, 1.199444088), R.8 = c(-0.141327295, 
0.152181413, 0.153037654, -0.097868883, -0.191620073, 0.259454516, 
0.583256179, -0.772155023, 0.272534699, 0.814200162, 0.248763352, 
0.315661336, 1.902073579, 3.385926093, 0.53062173, 0.309248961, 
0.006293118, -2.517164686, 0.301678975, 0.353796149), R.9 = c(-0.384312139, 
0.06505404, -0.073435447, -0.715351781, 0.217991274, -0.304059998, 
-0.102759574, 0.231438468, -0.403444624, 0.294886468, -0.085702486, 
-0.480999914, -0.433684562, 0.7205518, 0.005892568, 0.731183242, 
-0.290235435, 1.642113301, 1.033423002, 0.404841732), R.10 = c(0.043284098, 
-0.187714919, 0.103755766, 0.494175476, 0.183367264, 0.048461489, 
0.341167603, 0.942935915, 0.231005552, -0.032843257, 0.110780431, 
0.369394834, 1.09200937, 1.745564723, 0.411796215, 0.852997588, 
0.335184192, -0.440708907, 0.203262185, 1.007914836), R.11 = c(0.083099508, 
0.267121498, 0.015533879, -0.144656445, -0.101470878, 0.222392421, 
-0.266252913, 0.890823438, -0.210945895, -0.848512247, -0.067114196, 
-0.25944549, 0.221455302, 0.806681407, -0.042501067, 0.260151897, 
-0.040791883, -1.787941649, 0.382274808, 0.938294929), R.12 = 
 c(-0.705217235, 
 2.542562534, -0.135227381, -0.443646178, 0.519586492, 0.043795118, 
 0.686317021, 1.041588324, -0.304393436, -0.234275413, -0.43566302, 
 1.195857383, 1.752478594, 1.497997192, -0.80811711, 1.677544508, 
 0.208963846, 3.621611552, 2.73039294, 0.799138017), R.13 = c(0.42312992, 
 0.183353267, 0.147085025, -0.266112283, 0.324924347, 0.183090771, 
 0.20325984, -0.250088093, -0.24489442, 0.005137198, -0.116409492, 
 0.03395771, 1.37097252, 1.869706252, 0.235820911, 1.090602549, 
-0.225066556, 1.028663758, 0.590223864, -0.134533181), R.14 = c(0.048153022, 
 0.279512674, -0.015087144, 0.345647904, -0.066420426, -0.099863894, 
 0.002270174, 0.663318138, -0.13597767, 0.122096476, -0.020838519, 
 0.128906398, -0.620454804, 2.291401419, 0.112474729, 0.093509451, 
 0.211284031, 0.57905586, 0.319030146, -0.748749321), R.15 = c(-0.019510824, 
 0.115344305, 0.004854839, -0.57797607, 0.242971645, -0.085664592, 
 -0.186912355, 0.411476387, -0.173219579, -0.575194724, -0.184830499, 
 -0.066941159, -0.832648942, 2.396326768, -0.120558924, 1.286370872, 
 0.137328874, -0.415249645, -0.123145792, 0.396469739), R.16 = 
 c(0.123458788, 
 0.237039197, 0.092887298, -0.079751022, 0.056754778, -0.445799753, 
 0.013420516, 0.100152869, 0.119695066, -0.15320627, 0.009168315, 
 -0.17625064, -0.029486765, 1.666907682, 0.276289737, 1.188035155, 
 0.046047368, 0.280843392, 0.542246519, 0.847685006), R.17 = c(0.108754902, 
 0.020919096, -0.122974045, -0.280708392, -0.288840707, 0.084474568, 
 -0.295709099, -0.398888114, -0.644341048, -0.775756783, -0.548916159, 
 -0.180266946, -0.564083771, 1.007945835, -0.250767066, 0.229068486, 
 -0.272062897, 0.545069774, -0.590980007, 0.286389802), R.18 = 
 c(-0.819717423, 
 0.946193556, -0.096635783, -0.397640449, -0.404948682, -0.005217709, 
 0.361129545, 1.449898022, 0.076338824, -0.689502486, -0.437063806, 
 0.886017472, 0.837525303, 1.192266964, -1.132614108, -3.602036014, 
 0.368129605, -3.349106876, 1.454669286, 1.465455406), R.19 = c(0.620445088, 
 -0.415932471, 0.112894056, -0.15182218, 0.174272257, 0.111202562, 
 -0.840963315, -1.107727456, 0.105602182, -0.255257055, 0.280560458, 
 -1.043602781, -0.090670359, 1.593968549, 1.352097575, 0.586873898, 
 -0.219566377, -0.725140159, 0.324350757, 1.013175389), R.20 = 
 c(0.245063967, 
 0.113375519, 0.092986888, 0.288600861, -0.02038524, 0.004543925, 
 0.190331212, -0.199632058, 0.018920862, 0.222392421, 0.130545468, 
 0.138523024, 0.984010269, 1.984278002, 0.042850965, 0.983598393, 
 0.098937541, 0.548928809, 0.083001425, -0.042997405), R.21 = c(0.661566826, 
 0.119437254, 0.091438651, -0.715355635, 0.061747686, -0.744882623, 
 -0.024626971, 0.12485642, -0.591404712, -0.368052144, -0.195621484, 
 -0.112050968, 1.025425329, 0.453802053, -0.254558205, 0.155103041, 
 -0.045724139, -0.266813345, 0.513923164, 0.730513197), R.22 = c(0.34075977, 
 0.290896243, 0.099535674, 0.0828218, 0.081235304, 0.139222747, 
 -0.0077634, 0.336721484, -0.055014102, -0.174725988, 0.016240641, 
 -0.10410469, -1.439586959, 1.326737974, -0.078921802, -0.053470209, 
 0.154328146, 0.149227196, 0.418521645, -0.324534591), R.23 = 
 c(-0.007948753, 
 0.17967325, 0.015206413, -0.127001855, -0.094574813, 0.334241356, 
 0.124851487, 0.128964093, -0.031364171, -0.467678979, 0.001269419, 
 -0.010840947, -0.265703593, 1.368883853, -0.116494992, -0.392426988, 
 0.063286245, 0.067375329, 0.338763899, 1.268311492), R.24 = c(-0.206450877, 
 -0.277674691, -0.049784833, 0.227339641, 0.077055427, 0.454548402, 
 0.26706616, 0.102023049, 0.016301812, 0.518421645, 0.032254199, 
 0.117301336, 1.246234735, 1.851766791, 0.151897009, 0.120904889, 
 -0.091315167, -2.760725806, 0.960369191, 1.034626343), S = c(0.402177532, 
 0.420055574, 0.176453044, 0.198545679, 0.697700712, 0.257629601, 
 0.041820176, 1.020353532, -0.208399149, 0.137707165, 0.201996393, 
 0.048339534, -0.707179047, 2.282832351, 0.028758993, 1.288589164, 
 -0.078759733, -0.186109073, 0.344746177, -0.552074207), S.1 = 
 c(1.203313446, 
 0.466087228, 0.587909785, 0.849665727, 0.927068478, 0.900155762, 
 0.666443903, 0.587368998, 0.707134371, 0.583025997, -0.00695835, 
 0.577717726, 0.725546578, 1.901779685, -0.21032333, 0.319245674, 
 0.109198771, -1.136286206, -0.647850963, 0.374345671), S.2 = 
 c(-0.875181736, 
 0.65620627, -0.028983688, -0.135730534, 0.358207527, -0.15277028, 
 -0.067694407, -0.55682075, -0.056583528, 0.738471539, 0.104744105, 
 -0.62940378, 0.028515371, 1.857176942, 0.533757723, 0.450724355, 
 -0.312065883, -0.176636838, 0.457017571, 0.9536772), S.3 = c(0.588257773, 
 -0.004822383, 0.053954091, 0.084236537, 0.460311579, 0.125835216, 
 0.096404484, -0.355126928, 0.21176328, 0.234658286, -0.27556876, 
 0.415037499, 1.357233048, 1.305564649, -0.465708593, 1.262304112, 
 0.110473998, 1.171660703, 0.415336783, 0.837677625), S.4 = c(0.741814035, 
 4.425151813, 0.16639331, 0.078002512, 1.210404071, 0.470250842, 
 1.341152662, 1.190877372, 0.329602023, 1.182913983, 0.023918627, 
 1.744449024, 0.894972523, 3.493155756, -0.620596763, 2.040804149, 
 0.236774856, 2.586085658, 2.247754539, -0.254284144), S.5 = c(0, 
 0.007502765, -0.028720823, 0.004278881, -1.099986727, 0.15926652, 
 -0.047631122, -0.020210187, 0.229170954, 0.115369782, 0.131861561, 
 -0.307095488, 0.137154667, 2.853523128, 0.329790213, 1.451427879, 
 0.056204602, -1.178436104, 0.217307132, -0.13196534), S.6 = c(-0.097674532, 
 0.204931451, -0.051225323, -0.113849077, -0.304976169, -0.218640286, 
 0.068503564, -0.112268983, 0.115141225, -0.075998876, 0.101573667, 
 0.053061244, 2.147169087, 1.947962735, -0.03231389, 0.932885804, 
 0.342297684, -2.342396544, -0.179376477, 0.47767359), S.7 = c(0.478736427, 
 0.097003889, 0.096215315, 0.45495651, 0.050843677, 0.106915204, 
 0.087578298, 0.140944127, 0.052787414, -0.027338709, 0.124964208, 
 0.270931736, -0.178294391, 1.769631783, 0.078304995, 0.471482646, 
 0.272772601, -1.593511279, 0.386425363, 0.0138058), S.8 = c(-0.156557778, 
 0.044163331, -0.010018756, -0.144204723, -0.032552115, -0.639055204, 
 0.187733306, 0.272767852, -0.118499236, 0.153039566, -0.023246344, 
 -0.01053836, 0.438884241, 1.547487795, 0.290668675, -0.294716135, 
 -0.171756995, -4.196230266, 0.155476957, 1.36156786), S.9 = c(0.03088456, 
 0.026459045, 0.026537138, 0.280405137, -0.151398317, -0.285216317, 
 -0.085020584, -0.227058321, 0.037186602, -0.157265791, 0.163116612, 
 0.242552369, -0.185978979, 2.27217506, -0.03099791, 1.119271892, 
 0.010281641, -0.858385395, 0.680822516, 0.869603363), S.10 = 
 c(-0.933612603, 
 -0.561661401, -0.010971118, 0.084506296, 0.327996931, -0.127379306, 
 0.372832796, -0.496799668, 0.306224012, 0.774497651, -0.016301812, 
 0.118511278, 1.584962501, 1.104115103, 0.371968777, 0.84789681, 
 -0.422532036, -0.165301976, 0.360402243, 1.316057507), S.11 = 
  c(0.158086968, 
 -0.16276126, 0.058752587, 0.334639147, -0.236693103, 0.19592021, 
 0.189362494, -0.170716666, 0.412125904, -0.186556808, 0.019746348, 
 0.513638785, 0.979906429, 0.711042249, -0.196017653, 1.536277987, 
 0.278880442, 0.2421449, -0.140854662, -0.892002748), S.12 = c(-0.103349527, 
 0.008171537, 0.00740795, 0.230358731, 0.008814865, 0.059265949, 
 0.256748143, -0.029081064, 0.058693994, 0.245492585, -0.046478319, 
 -0.272943002, 0.266249071, 0.438993478, 0.214384273, 0.174833802, 
 -0.107021711, 0.025829916, 0.547141035, -0.018962311), S.13 = 
  c(0.098720989, 
  0.087518126, -0.036205038, -0.096469371, 0.154284035, 0.144596821, 
  0.03090228, 0.137503524, -0.100928909, -0.111945526, -0.099622711, 
  -0.060255248, -0.3379805, 1.422995021, 0.06065222, 0.439371453, 
  -0.038819249, -1.051399153, -0.190932002, -0.564482695), S.14 = 
 c(0.181128626, 
 0.048144347, 0.082784875, 0.164744762, -0.192795853, 0.679907305, 
 -0.013862653, 0.446737964, 0, -0.340500201, -0.063834709, -0.039999772, 
 -0.476580935, 1.429061666, 0.043243186, 0.96893928, 0.027823682, 
 -1.492793697, 0.316419333, 0.409292824), S.15 = c(0.038395379, 
 0.001808342, 0.119825623, 0.175174518, 0.030871971, 0.976623217, 
 0.131155431, 0.157773076, 0, 0.265868136, 0.180653687, 0.240570256, 
 1.327638515, 2.925137937, 0.09894185, 1.495915625, 0.236760712, 
 -1.783214151, 1.440123224, -1.006173287), S.16 = c(0.26489715, 
 0.618994392, 0.119147265, 0.428553572, -0.112110366, -0.053977621, 
 0.152664728, -0.740156602, 0.222392421, 0.121136438, 0.074861437, 
 -0.037941572, 0.025671408, 2.236333895, 0.212915143, 0.991816796, 
 0.226770862, -2.156734325, -0.168712606, 0.53196331), S.17 = c(0.195724471, 
 0.004644926, 0.055255112, 0.160263427, 0.020340448, 0.36325156, 
 0.180808289, 0.010481859, 0.086611107, 0.071709873, 0.119690699, 
 0.180955701, 0.64309333, 3.040632365, 0.243708653, 1.188487452, 
 0.141495436, 1.260289029, 0.635859213, 0.152117679), S.18 = c(-0.209778803, 
 -0.194816177, -0.06734922, -0.157660246, -0.322157988, -0.085877835, 
 -0.164075926, 0.322299716, -0.145776183, -0.044931851, 0.10228105, 
 0.049327712, 1.003411973, 1.339959808, 0.104617003, 0.650394253, 
 -0.03789984, -3.153164235, 0.831164535, 0.715554624), S.19 = c(0.121624202, 
 0.227489373, 0.129994473, 0.185885669, 0.013160365, 0.054966459, 
 0.067986838, 0.266339551, 0.123382416, 0.075101455, 0.180398333, 
 0.355694209, 0.178705887, 1.356842621, -0.14448904, -0.343652866, 
 0.32081973, -0.410169692, 1.146938038, 0.791776524), S.20 = c(-0.078601215, 
 0.831950488, 0.058102955, -0.486632366, 0.507899167, -0.036069255, 
 0.508578267, 0.725146477, -0.648288436, 0.047828525, -0.39820306, 
 0.663167328, 0.688127986, 2.014873276, -1.228761946, 1.194816177, 
 0.037371429, -0.00250093, 2.610433188, 0.941635837), S.21 = c(-0.658223681, 
 0.514305072, 0.071083098, -0.535674538, 0.508087425, -0.118021974, 
 0.031406847, -0.220352916, -0.327403225, 0.059973955, -0.142100162, 
 -0.283264771, -0.295316365, 1.163403665, 0.085747948, -0.622437206, 
 -0.283547003, -3.427114726, 0.503542524, -0.194592393), S.22 = 
 c(0.502575109, 
 0.214738849, 0.16387432, -1.058339765, 0.314335635, 0.400198512, 
 -0.134555177, 0.525833289, -0.471621028, -0.19065835, -0.096404484, 
 -0.250315154, -2.200389125, 1.296830599, -0.194787667, 0.704871964, 
 0.100567477, -1.596585726, -0.285145107, 0.873242858), S.23 = 
 c(-0.60259496, 
 -0.301673433, -0.116609187, 0.255225081, -0.263307928, -0.124370693, 
 0.174581628, -0.232733207, 0.190477241, 0.380540255, -0.074136422, 
 0.087765536, 1.566966071, 1.595043184, 0.05055783, 0.612866668, 
 -0.19426882, -0.358166123, 0.577028319, 0.528832273), S.24 = c(0.041270996, 
 -0.129181684, -0.059588796, -0.003285788, -0.175620198, 0.422784607, 
 -0.068934631, 0.059378547, 0.03562391, -0.034765418, -0.068083945, 
 0.065987814, -0.291090691, 1.771431998, 0.046542586, -0.876278566, 
 0.276660352, -4.220478101, -0.018334524, 0.793037619)), row.names = c(NA, 
 20L), class = "data.frame")

I want to find the metabolites that show significant difference between resistant and susceptible lines. Can anyone please guide me how to do that in R?

I don't know how to do this, so I first averaged each 25 lines in two sets into two data columns and then used #limma package in #R to check it out using this code:

 Group <- factor(c("R","S"))
 design <- model.matrix(~0 + Group)
 colnames(design) <- gsub("Group","", colnames(design))
 fit <- lmFit(dset[,2:3],design)
 contrast.matrix<-makeContrasts(RvsS=R-S,levels=design)
 fit2<-contrasts.fit(fit,contrast.matrix)
 fit2<-eBayes(fit2)
 sel.diif<-p.adjust(fit2$F.p.value,method="fdr")<0.05
 deg<-eset[,2:3][sel.diif,]

It gave following error:

 Error in .ebayes(fit = fit, proportion = proportion, stdev.coef.lim = stdev.coef.lim,  : No residual degrees of freedom in linear model fits

Solution

  • To find metabolites that have different regulation, you are right to use limma. You don't need to calculate the mean. limma estimates the variance and means of your different samples, and test for significant difference based on that. I show you an example below, and you should be able to adapt it to your data:

    #simulate data like yours
    set.seed(100)
    df = matrix(rnbinom(500*50,mu=100,size=2),500,50)
    colnames(df) = paste(rep(c("R","S"),each=25),rep(1:25,2),sep="")
    rownames(df) = paste("M",1:500,sep="")
    
    #let's make M451 - M500 higher in "S"
    df[451:500,26:50] <- df[451:500,26:50]+ rnorm(50*25,100,10)
    
    library(limma)
    # you need to set it up like this
    Group <- rep(c("R","S"),each=25)
    design <- model.matrix(~Group)
    # voom to transform your data for lmFit
    y <- voom(df, design)
    fit <- lmFit(y, design)
    fit <- eBayes(fit)
    results <- topTable(fit,coef=2,number=nrow(fit))
    head(results)
    
            logFC  AveExpr        t      P.Value    adj.P.Val         B
    M452 1.967264 10.79952 6.509923 1.575131e-09 7.875653e-07 11.460506
    M499 1.519837 11.02627 5.833641 4.228481e-08 6.726602e-06  8.320806
    M485 1.760947 10.90720 5.809568 4.737771e-08 6.726602e-06  8.224170
    M487 1.592874 11.09243 5.782545 5.381282e-08 6.726602e-06  8.089156
    M470 1.727917 10.96071 5.719957 7.218783e-08 7.218783e-06  7.821371
    M468 1.409254 11.13993 5.471017 2.282249e-07 1.695397e-05  6.702534
    

    In the results table above, for example the first row M452, the first column tells you logFC S / R , a positive means it is higher in S compared to S. The other columns P.Value and adj.P.Val as p.values from the moderated t-test and the adjusted p.value to get the significant hits, do:

    sum(results$adj.P.Val<0.05)
    [1] 51
    rownames(results)[results$adj.P.Val<0.05]
     [1] "M452" "M499" "M485" "M487" "M470" "M468" "M484" "M474" "M497" "M496"
    [11] "M475" "M469" "M488" "M457" "M454" "M467" "M489" "M453" "M493" "M482"
    [21] "M479" "M472" "M461" "M494" "M473" "M498" "M465" "M476" "M455" "M500"
    [31] "M451" "M481" "M5"   "M456" "M495" "M490" "M486" "M471" "M462" "M492"
    [41] "M459" "M464" "M478" "M460" "M466" "M152" "M458" "M483" "M480" "M491"
    [51] "M255"
    

    Using the example you have:

    Group <- rep(c("R","S"),each=25)
    design <- model.matrix(~Group)
    # you don't need to use voom, but better to provide a matrix
    mat = as.matrix(df[,-1])
    rownames(mat) = df$Metabolites
    fit <- lmFit(mat, design)
    fit <- eBayes(fit)
    results <- topTable(fit,coef=2,number=nrow(fit))
    #gives you significant results
    results[results$adj.P.Val<0.05,]