我使用Limma包来分析一些数据。用read.maimagenes
读取原始数据后,我得到一个RGList
对象。 R.cut和G.cut是类数字的值,我想要它们之上的值。我试过这样的事情:
RG$R <- RG$R[RG$R>R.cut]
RG$G <- RG$G[RG$G>G.cut]
但是这将RG $ R的类从矩阵转换为数字我怎么能保持矩阵类(我不知道引入一些NA值是否会影响分析的其余部分)。我试过像这样的子集:
RG.probe$R <- subset(x=RG, subset=RG$R>R.cut)
但它不断返回错误Error: Two subscripts required
如何做到这一点?
除此之外:如果我想获得R.cut和G.cut上方的行?
可能的解决方案:
我发现使用ifelse
我可以做到这一点,虽然我必须为切割下的那些引入一个值,但我还没有找到检查R和G通道是否高于每个通道的方法切。
RG$R<-ifelse(RG$R>R.cut, RG$R, '')
RG$G<-ifelse(RG$G>G.cut, RG$G, '')
虽然它被转换为字符,因此我无法做进一步的分析。
使数据可重现的数据:
library(limma)
RG<-read.maimages(path, source='agilent')
class(RG)
[1] "RGList"
attr(,"package")
[1] "limma"
dput(head(RG$R))
structure(c(2893, 81.5, 80.5, 140208, 4512, 6272, 4934, 195,
184.5, 164092, 11819, 10569, 1689.5, 83, 82, 68996, 2260.5, 3603,
2470, 84, 77, 96750, 3203, 5223, 3246, 85.5, 104.5, 54773, 519.5,
8244.5, 1807, 86.5, 88, 204574, 15693, 8939.5, 2040, 87, 95,
131880, 7346, 9922.5, 1445, 76, 85.5, 125598, 3863, 5758.5, 2626,
87.5, 85, 180266, 18173, 20171.5, 1811.5, 84, 87.5, 122498, 3993,
5857, 1799, 87.5, 82, 123220, 3780, 5964, 1706, 77.5, 80, 124463,
3390, 5070, 3787, 81.5, 88, 65874, 269, 781.5, 1476, 90, 89,
122445, 4232, 6479, 2788, 82, 87.5, 80669, 791, 7440.5, 1503,
81, 88, 124702, 4270, 6111, 2012.5, 93.5, 90, 215820, 4555, 3101,
1727.5, 102, 109, 131316, 4284, 6638, 2009, 95.5, 111.5, 175474,
12665, 17213, 1532, 87.5, 84.5, 117568, 4098, 6100, 1436, 83,
91, 118472, 4067.5, 6114, 1651.5, 83, 82, 127308, 4150, 6277,
2028.5, 85.5, 89, 74816, 896.5, 7697, 2698, 84, 92.5, 99431,
1273, 9182.5, 1833.5, 100, 104, 163604, 15582, 12146, 2359, 102,
109, 159301, 17229, 9822.5, 1857, 86, 88, 130319, 4354.5, 6266.5,
1887, 87, 87, 133386, 11639.5, 8931, 2304.5, 86.5, 87, 91022,
1011, 14524, 1353, 84, 88, 114282, 3935, 5944, 1487, 83, 87,
125507, 4138, 5804, 3379, 86.5, 88, 63703.5, 331, 1167, 1778,
87, 83.5, 123988, 4366, 6670, 1862, 94.5, 92, 134174, 4558, 6881,
2388.5, 82, 91.5, 174744, 8570, 10677, 4374, 94, 94, 179579,
12753, 10869, 3747.5, 115, 144.5, 133809, 3710, 5406, 5062, 93.5,
92, 207843, 13220, 6774, 3294, 78, 82.5, 149764, 3774, 5582,
5303, 93, 100, 93479.5, 803, 6709, 2969, 86.5, 101, 149011, 4043,
5407, 5488, 106, 118.5, 191053, 9990.5, 12194, 4308, 89, 85,
143087, 3926.5, 5370.5, 5168, 87, 91.5, 137415, 4028, 5671, 4649.5,
91, 90, 147328, 4102, 5614.5, 7225, 87, 85, 179052, 15612, 16908,
5815.5, 84, 88, 200883, 13229, 11482, 3551, 101, 125, 224012,
20461, 16149.5, 3992, 98, 83, 134744, 3569, 5068, 4817, 97, 92,
142087, 4203, 5678, 5436, 108, 84.5, 195104, 11299, 13246), .Dim = c(6L,
51L), .Dimnames = list(NULL, c("US23502326_253482110017_S01_GE2_1105_Oct12_1_1",
"US23502326_253482110017_S01_GE2_1105_Oct12_2_1", "US23502326_253482110017_S01_GE2_1105_Oct12_2_2",
"US23502326_253482110017_S01_GE2_1105_Oct12_2_3", "US23502326_253482110017_S01_GE2_1105_Oct12_2_4",
"US23502326_253482110027_S01_GE2_1105_Oct12_1_1", "US23502326_253482110027_S01_GE2_1105_Oct12_1_2",
"US23502326_253482110027_S01_GE2_1105_Oct12_1_3", "US23502326_253482110027_S01_GE2_1105_Oct12_1_4",
"US23502326_253482110027_S01_GE2_1105_Oct12_2_1", "US23502326_253482110027_S01_GE2_1105_Oct12_2_2",
"US23502326_253482110027_S01_GE2_1105_Oct12_2_3", "US23502326_253482110027_S01_GE2_1105_Oct12_2_4",
"US23502326_253482110028_S01_GE2_1105_Oct12_1_1", "US23502326_253482110028_S01_GE2_1105_Oct12_1_2",
"US23502326_253482110028_S01_GE2_1105_Oct12_1_4", "US23502326_253482110028_S01_GE2_1105_Oct12_2_1",
"US23502326_253482110028_S01_GE2_1105_Oct12_2_2", "US23502326_253482110028_S01_GE2_1105_Oct12_2_3",
"US23502326_253482110029_S01_GE2_1105_Oct12_1_1", "US23502326_253482110029_S01_GE2_1105_Oct12_1_2",
"US23502326_253482110029_S01_GE2_1105_Oct12_1_3", "US23502326_253482110029_S01_GE2_1105_Oct12_1_4",
"US23502326_253482110029_S01_GE2_1105_Oct12_2_1", "US23502326_253482110029_S01_GE2_1105_Oct12_2_2",
"US23502326_253482110029_S01_GE2_1105_Oct12_2_3", "US23502326_253482110029_S01_GE2_1105_Oct12_2_4",
"US23502326_253482110030_S01_GE2_1105_Oct12_1_1", "US23502326_253482110030_S01_GE2_1105_Oct12_1_2",
"US23502326_253482110030_S01_GE2_1105_Oct12_1_3", "US23502326_253482110030_S01_GE2_1105_Oct12_1_4",
"US23502326_253482110030_S01_GE2_1105_Oct12_2_1", "US23502326_253482110030_S01_GE2_1105_Oct12_2_2",
"US23502326_253482110030_S01_GE2_1105_Oct12_2_3", "US23502326_253482110030_S01_GE2_1105_Oct12_2_4",
"US23502326_253482110031_S01_GE2_1105_Oct12_1_1", "US23502326_253482110031_S01_GE2_1105_Oct12_1_2",
"US23502326_253482110031_S01_GE2_1105_Oct12_1_3", "US23502326_253482110031_S01_GE2_1105_Oct12_1_4",
"US23502326_253482110031_S01_GE2_1105_Oct12_2_1", "US23502326_253482110031_S01_GE2_1105_Oct12_2_2",
"US23502326_253482110031_S01_GE2_1105_Oct12_2_3", "US23502326_253482110031_S01_GE2_1105_Oct12_2_4",
"US23502326_253482110049_S01_GE2_1105_Oct12_1_1", "US23502326_253482110049_S01_GE2_1105_Oct12_1_2",
"US23502326_253482110049_S01_GE2_1105_Oct12_1_3", "US23502326_253482110049_S01_GE2_1105_Oct12_1_4",
"US23502326_253482110049_S01_GE2_1105_Oct12_2_1", "US23502326_253482110049_S01_GE2_1105_Oct12_2_2",
"US23502326_253482110049_S01_GE2_1105_Oct12_2_3", "US23502326_253482110049_S01_GE2_1105_Oct12_2_4"
)))
dput(head(RG$G))
structure(c(2324, 58, 52, 98015, 9800, 5284, 1472, 114, 92.5,
27879, 2296, 3272.5, 3637, 216, 204.5, 34898, 731, 5084, 3466,
77, 74, 32543, 497, 7416, 1344, 79.5, 99, 52753, 2363, 3457,
686, 39, 44.5, 32866, 2937, 4324, 910, 42, 40, 42361, 2780, 4072,
1587, 83.5, 97, 79659, 7667, 10103, 754, 49.5, 44, 23664, 2962,
4166, 1390.5, 136, 156.5, 70132.5, 7914, 4876, 1609, 99, 125,
25923.5, 610, 5125, 1526, 198.5, 157, 94640.5, 10408, 9233, 1060,
42, 37, 70033, 3144, 4355.5, 1465, 89, 91, 99188, 9587, 7547,
743, 61.5, 60, 65888, 3247, 4676.5, 1931.5, 89, 84, 65967, 11226,
7757, 873.5, 56, 66, 20126.5, 3291, 4736, 1339.5, 298, 300, 75324,
6712, 8500, 894, 65, 86, 26341.5, 3132.5, 4647, 2372, 80, 81.5,
73418.5, 5026, 7612, 1564, 70, 73, 77180, 7802.5, 9454, 1315,
90, 85, 20562, 340, 5337, 868.5, 49, 55, 64712.5, 2947, 4260,
798, 46, 48, 52505, 3380, 4663.5, 904, 69.5, 80, 33371.5, 3300,
4997, 813, 73, 81, 29552, 2932, 4632.5, 1696.5, 187, 324, 63647,
6407, 8571.5, 872, 39.5, 52, 24518, 3094, 4387, 752.5, 54, 52,
48299.5, 3221, 4278, 2631, 61, 72, 27229, 513, 5019, 1256.5,
61, 63, 74560, 11016, 9019, 942, 57, 55, 70933.5, 3526.5, 5383,
1457.5, 162, 193.5, 86276, 8154, 12084, 1590, 213, 293, 66871,
6580, 9535, 833.5, 57, 62.5, 36416, 3229, 4600, 2161.5, 53.5,
42.5, 39157.5, 2952, 3977, 3481, 67, 68, 18675, 152, 536, 1977,
57, 55.5, 32861, 2785, 3812, 4739.5, 112.5, 113.5, 104923, 6231,
8198, 1907, 57.5, 69, 76674.5, 3219, 4244, 3879.5, 183.5, 171,
110822, 9582, 8426, 1746, 74.5, 74, 33327, 2774, 4017, 3333,
187, 270.5, 83696, 6616, 7080, 4737, 38, 37, 30041, 429.5, 3970,
3347, 45, 46, 106822, 8003.5, 7137.5, 2431, 32, 35, 32985, 3121,
4179, 2535.5, 28, 34, 36131.5, 3135, 4126, 1929, 42, 65, 47428,
3300, 4626.5, 5371, 54.5, 43.5, 108175, 9983, 6182, 5139.5, 34,
28, 26774, 152, 518, 2621, 48, 32, 44499, 3409, 4643), .Dim = c(6L,
51L), .Dimnames = list(NULL, c("US23502326_253482110017_S01_GE2_1105_Oct12_1_1",
"US23502326_253482110017_S01_GE2_1105_Oct12_2_1", "US23502326_253482110017_S01_GE2_1105_Oct12_2_2",
"US23502326_253482110017_S01_GE2_1105_Oct12_2_3", "US23502326_253482110017_S01_GE2_1105_Oct12_2_4",
"US23502326_253482110027_S01_GE2_1105_Oct12_1_1", "US23502326_253482110027_S01_GE2_1105_Oct12_1_2",
"US23502326_253482110027_S01_GE2_1105_Oct12_1_3", "US23502326_253482110027_S01_GE2_1105_Oct12_1_4",
"US23502326_253482110027_S01_GE2_1105_Oct12_2_1", "US23502326_253482110027_S01_GE2_1105_Oct12_2_2",
"US23502326_253482110027_S01_GE2_1105_Oct12_2_3", "US23502326_253482110027_S01_GE2_1105_Oct12_2_4",
"US23502326_253482110028_S01_GE2_1105_Oct12_1_1", "US23502326_253482110028_S01_GE2_1105_Oct12_1_2",
"US23502326_253482110028_S01_GE2_1105_Oct12_1_4", "US23502326_253482110028_S01_GE2_1105_Oct12_2_1",
"US23502326_253482110028_S01_GE2_1105_Oct12_2_2", "US23502326_253482110028_S01_GE2_1105_Oct12_2_3",
"US23502326_253482110029_S01_GE2_1105_Oct12_1_1", "US23502326_253482110029_S01_GE2_1105_Oct12_1_2",
"US23502326_253482110029_S01_GE2_1105_Oct12_1_3", "US23502326_253482110029_S01_GE2_1105_Oct12_1_4",
"US23502326_253482110029_S01_GE2_1105_Oct12_2_1", "US23502326_253482110029_S01_GE2_1105_Oct12_2_2",
"US23502326_253482110029_S01_GE2_1105_Oct12_2_3", "US23502326_253482110029_S01_GE2_1105_Oct12_2_4",
"US23502326_253482110030_S01_GE2_1105_Oct12_1_1", "US23502326_253482110030_S01_GE2_1105_Oct12_1_2",
"US23502326_253482110030_S01_GE2_1105_Oct12_1_3", "US23502326_253482110030_S01_GE2_1105_Oct12_1_4",
"US23502326_253482110030_S01_GE2_1105_Oct12_2_1", "US23502326_253482110030_S01_GE2_1105_Oct12_2_2",
"US23502326_253482110030_S01_GE2_1105_Oct12_2_3", "US23502326_253482110030_S01_GE2_1105_Oct12_2_4",
"US23502326_253482110031_S01_GE2_1105_Oct12_1_1", "US23502326_253482110031_S01_GE2_1105_Oct12_1_2",
"US23502326_253482110031_S01_GE2_1105_Oct12_1_3", "US23502326_253482110031_S01_GE2_1105_Oct12_1_4",
"US23502326_253482110031_S01_GE2_1105_Oct12_2_1", "US23502326_253482110031_S01_GE2_1105_Oct12_2_2",
"US23502326_253482110031_S01_GE2_1105_Oct12_2_3", "US23502326_253482110031_S01_GE2_1105_Oct12_2_4",
"US23502326_253482110049_S01_GE2_1105_Oct12_1_1", "US23502326_253482110049_S01_GE2_1105_Oct12_1_2",
"US23502326_253482110049_S01_GE2_1105_Oct12_1_3", "US23502326_253482110049_S01_GE2_1105_Oct12_1_4",
"US23502326_253482110049_S01_GE2_1105_Oct12_2_1", "US23502326_253482110049_S01_GE2_1105_Oct12_2_2",
"US23502326_253482110049_S01_GE2_1105_Oct12_2_3", "US23502326_253482110049_S01_GE2_1105_Oct12_2_4"
)))
从dput中你可以通过new("RGList")
创建一个RGList我知道它是关于大量数据但是我之前asked我不知道如何缩短输出。
答案 0 :(得分:0)
我最终得到的解决方案几乎一样:
RG$G <- ifelse(RG$R>R.cut, RG$G, NA)
RG$R <- ifelse(RG$G>G.cut, RG$R, NA)
删除这些值似乎会增加每个基因的倍数变化,因为已经发生了比较原始RG和RG以及问题中删除值的情况。