Changes

From kogic.kr

Data.table

8,914 bytes added, 12:39, 24 January 2019
no edit summary
<h1><span style="font-family:courier new,courier,monospace">Convert a molten data table into an data table (array type)</span></h1>
<h3 style="color:#aaa; font-style:italic"><span style="font-family:courier new,courier,monospace">Input(head)</span></h3>
<div style="background:#eee;border:1px solid #ccc;padding:5px 10px;"><span style="font-family:courier new,courier,monospace"><span style="font-size:11px">&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Species &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ID &nbsp; &nbsp; &nbsp; Var1 Var2 &nbsp; &nbsp; &nbsp; &nbsp; Val &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Group &nbsp; &nbsp; &nbsp;Print_name<br />
&nbsp; &nbsp; 1: Dendronephthya_gigantea g30906.t1.cds@g30906@000029F CDS_length Full 2.01600e+03 Non-symbiotic_cnidarian Carnation_coral<br />
&nbsp; &nbsp; 2: Dendronephthya_gigantea g14782.t1.cds@g14782@000108F CDS_length Full 4.02000e+02 Non-symbiotic_cnidarian Carnation_coral<br />
&nbsp; &nbsp; 3: Dendronephthya_gigantea &nbsp; g9986.t1.cds@g9986@000064F CDS_length Full 8.40000e+02 Non-symbiotic_cnidarian Carnation_coral<br />
&nbsp; &nbsp; 4: Dendronephthya_gigantea &nbsp; g1279.t1.cds@g1279@000024F CDS_length Full 8.58000e+02 Non-symbiotic_cnidarian Carnation_coral<br />
&nbsp; &nbsp; 5: Dendronephthya_gigantea &nbsp; g9325.t1.cds@g9325@000042F CDS_length Full 8.61000e+02 Non-symbiotic_cnidarian Carnation_coral</span></span></div>
<h3 style="color:#aaa; font-style:italic"><span style="font-family:courier new,courier,monospace">Code</span></h3>
<h3 style="color:#aaa; font-style:italic"><span style="font-family:courier new,courier,monospace">Output</span></h3>
<div style="background:#eee;border:1px solid #ccc;padding:5px 10px;"><span style="font-family:courier new,courier,monospace"><span style="font-size:11px">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ID CDS_length &nbsp; &nbsp; &nbsp;FPKM<br />
&nbsp; &nbsp; 1: &nbsp; &nbsp; &nbsp; g10.t1.cds@g10@000002F &nbsp; &nbsp; &nbsp; 1185 30.363500<br />
&nbsp; &nbsp; 2: &nbsp; &nbsp; g100.t1.cds@g100@000002F &nbsp; &nbsp; &nbsp; &nbsp;696 &nbsp;0.959006<br />
&nbsp; &nbsp; 3: &nbsp; g1000.t1.cds@g1000@000011F &nbsp; &nbsp; &nbsp; &nbsp;660 &nbsp;0.000000<br />
&nbsp; &nbsp; 4: g10000.t1.cds@g10000@000064F &nbsp; &nbsp; &nbsp; 1074 &nbsp;0.278465<br />
&nbsp; &nbsp; 5: g10001.t1.cds@g10001@000064F &nbsp; &nbsp; &nbsp; &nbsp;522 &nbsp;0.962268&nbsp; &nbsp;&nbsp;</span></span></div> <h1><span style="font-family:courier new,courier,monospace">Fast melt for Data table</span></h1> <h3 style="color:#aaa; font-style:italic"><span style="font-family:courier new,courier,monospace">Input (head)</span></h3> <div style="background:#eee;border:1px solid #ccc;padding:5px 10px;"><span style="font-size:11px"><span style="font-family:courier new,courier,monospace">&nbsp; &nbsp; &nbsp; &nbsp; Position G4-SV40 G4-SV40-OHT<br />&nbsp; &nbsp; 1: 101488764 &nbsp; &nbsp; &nbsp;52 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;51<br />&nbsp; &nbsp; 2: 101488765 &nbsp; &nbsp; &nbsp;52 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;50<br />&nbsp; &nbsp; 3: 101488766 &nbsp; &nbsp; &nbsp;52 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;49<br />&nbsp; &nbsp; 4: 101488767 &nbsp; &nbsp; &nbsp;53 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;49<br />&nbsp; &nbsp; 5: 101488768 &nbsp; &nbsp; &nbsp;54 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;49</span></span></div> <h3 style="color:#aaa; font-style:italic"><span style="font-family:courier new,courier,monospace">Code</span></h3> <div style="background:#eee;border:1px solid #ccc;padding:5px 10px;"><big><span style="font-family:courier new,courier,monospace">melt(SeqDepth_dt, id.vars = &quot;Position&quot;)</span></big></div> <h3 style="color:#aaa; font-style:italic"><span style="font-family:courier new,courier,monospace">Output (head)</span></h3> <div style="background:#eee;border:1px solid #ccc;padding:5px 10px;"><span style="font-size:11px"><span style="font-family:courier new,courier,monospace">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Position &nbsp; &nbsp;variable value<br />&nbsp; &nbsp; &nbsp;1: 101488764 &nbsp; &nbsp; G4-SV40 &nbsp; &nbsp;52<br />&nbsp; &nbsp; &nbsp;2: 101488765 &nbsp; &nbsp; G4-SV40 &nbsp; &nbsp;52<br />&nbsp; &nbsp; &nbsp;3: 101488766 &nbsp; &nbsp; G4-SV40 &nbsp; &nbsp;52<br />&nbsp; &nbsp; &nbsp;4: 101488767 &nbsp; &nbsp; G4-SV40 &nbsp; &nbsp;53<br />&nbsp; &nbsp; &nbsp;5: 101488768 &nbsp; &nbsp; G4-SV40 &nbsp; &nbsp;54</span></span></div> <h1><span style="font-family:courier new,courier,monospace">Data table aggregation with &#39;by&#39;</span></h1> <h3 style="color:#aaa; font-style:italic"><span style="font-family:courier new,courier,monospace">Input (head)</span></h3> <div style="background:#eee;border:1px solid #ccc;padding:5px 10px;"><span style="font-family:courier new,courier,monospace"><span style="font-size:11px">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ID CDS_length &nbsp; &nbsp; &nbsp;FPKM &nbsp; ord bin<br />&nbsp; &nbsp; 1: &nbsp; &nbsp; &nbsp; g10.t1.cds@g10@000002F &nbsp;10.210671 4.9242662 10665 &nbsp; 8<br />&nbsp; &nbsp; 2: g10002.t1.cds@g10002@000064F &nbsp;12.039262 2.3361320 &nbsp;3975 &nbsp; 3<br />&nbsp; &nbsp; 3: g10008.t1.cds@g10008@000073F &nbsp; 9.162391 0.6201266 &nbsp; 856 &nbsp; 1<br />&nbsp; &nbsp; 4: g10011.t1.cds@g10011@000073F &nbsp; 9.942515 1.9781956 &nbsp;3149 &nbsp; 3<br />&nbsp; &nbsp; 5: g10012.t1.cds@g10012@000073F &nbsp;10.762382 0.5596289 &nbsp; 785 &nbsp; 1</span></span></div> <h3 style="color:#aaa; font-style:italic"><span style="font-family:courier new,courier,monospace">Code</span></h3> <div style="background:#eee;border:1px solid #ccc;padding:5px 10px;"><span style="font-family:courier new,courier,monospace"><big>dt[, .(Mean_CDS_length = mean(CDS_length), Mean_FPKM = mean(FPKM)), by=bin]</big></span></div> <h3 style="color:#aaa; font-style:italic"><span style="font-family:courier new,courier,monospace">Output</span></h3> <div style="background:#eee;border:1px solid #ccc;padding:5px 10px;"><span style="font-family:courier new,courier,monospace"><span style="font-size:11px">&nbsp; &nbsp; bin Mean_CDS_length Mean_FPKM<br />&nbsp;1: &nbsp; 8 &nbsp; &nbsp; &nbsp; 10.187520 4.7044951<br />&nbsp;2: &nbsp; 3 &nbsp; &nbsp; &nbsp; 10.590668 2.0831168<br />&nbsp;3: &nbsp; 1 &nbsp; &nbsp; &nbsp; 10.488467 0.4904325<br />&nbsp;4: &nbsp; 4 &nbsp; &nbsp; &nbsp; 10.550280 2.6412267<br />&nbsp;5: &nbsp; 2 &nbsp; &nbsp; &nbsp; 10.541246 1.3801430<br />&nbsp;6: &nbsp; 7 &nbsp; &nbsp; &nbsp; 10.344120 4.1326888<br />&nbsp;7: &nbsp; 6 &nbsp; &nbsp; &nbsp; 10.377043 3.6221557<br />&nbsp;8: &nbsp;10 &nbsp; &nbsp; &nbsp; &nbsp;9.563917 7.4570552<br />&nbsp;9: &nbsp; 5 &nbsp; &nbsp; &nbsp; 10.509382 3.1425986<br />10: &nbsp; 9 &nbsp; &nbsp; &nbsp; &nbsp;9.941699 5.4668993</span></span></div> <h1><span style="font-family:courier new,courier,monospace">Data table row-wise calculation</span></h1> <h3 style="color:#aaa; font-style:italic"><span style="font-family:courier new,courier,monospace">Input (head)</span></h3> <div style="background:#eee;border:1px solid #ccc;padding:5px 10px;"><span style="font-family:courier new,courier,monospace"><span style="font-size:11px">&nbsp; &nbsp;Description &nbsp; &nbsp; &nbsp; ID Anolis_carolinensis Balaena_mysticetus Balaenoptera_acutorostrata_scammoni<br />1: &nbsp; &nbsp;OG000001 OG000001 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 126 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;103 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 107<br />2: &nbsp; &nbsp;OG000002 OG000002 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;70 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 19 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;48<br />3: &nbsp; &nbsp;OG000003 OG000003 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;27 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 29 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;25<br />4: &nbsp; &nbsp;OG000004 OG000004 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;39 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 36 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;47<br />5: &nbsp; &nbsp;OG000005 OG000005 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 11 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 3</span></span></div> <h3 style="color:#aaa; font-style:italic"><span style="font-family:courier new,courier,monospace">Code</span></h3> <div style="background:#eee;border:1px solid #ccc;padding:5px 10px;"><span style="font-family:courier new,courier,monospace"><big>dt[,Sum := rowSums(.SD, na.rm=T), .SDcols = 3:5]</big></span></div> <div style="background:#eee;border:1px solid #ccc;padding:5px 10px;"><span style="font-family:courier new,courier,monospace"><big>dt[,Mean&nbsp;:= rowMeans(.SD, na.rm=T), .SDcols = 3:5]</big></span></div> <h3 style="color:#aaa; font-style:italic"><span style="font-family:courier new,courier,monospace">Output</span></h3> <div style="background:#eee;border:1px solid #ccc;padding:5px 10px;"><span style="font-family:courier new,courier,monospace"><span style="font-size:11px">&nbsp; &nbsp;Description &nbsp; &nbsp; &nbsp; ID Anolis_carolinensis Balaena_mysticetus Balaenoptera_acutorostrata_scammoni Sum &nbsp; &nbsp; &nbsp; Avg<br />1: &nbsp; &nbsp;OG000001 OG000001 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 126 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;103 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 107 336 112.00000<br />2: &nbsp; &nbsp;OG000002 OG000002 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;70 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 19 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;48 137 &nbsp;45.66667<br />3: &nbsp; &nbsp;OG000003 OG000003 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;27 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 29 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;25 &nbsp;81 &nbsp;27.00000<br />4: &nbsp; &nbsp;OG000004 OG000004 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;39 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 36 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;47 122 &nbsp;40.66667<br />5: &nbsp; &nbsp;OG000005 OG000005 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 11 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 3 &nbsp;15 &nbsp; 5.00000</span></span></div>
1,007
edits

Navigation menu