简体   繁体   English

这是什么样的R对象? 矩阵列表,或矩阵矩阵或其他内容

[英]What kind of R object is this ? List of matrices, or matrix of matrices or something else

My colleague created this R object, but he does not work here any more. 我的同事创建了这个R对象,但他不再在这里工作。

I need to work with his R code, but I'm not able to figure out if the object he created is a List of matrices, or matrix of matrices or something else. 我需要使用他的R代码,但是我无法弄清楚他创建的对象是矩阵列表还是矩阵列表或其他东西。

I did some queries on the object and a screen shot, hopefully this will give you an idea about the R object. 我对对象和屏幕快照进行了一些查询,希望这可以使您对R对象有个了解。

> dim(fmr.seg.crc)
[1] 10 22
> dimnames(fmr.seg.crc)
[[1]]
 [1] "s1"  "s2"  "s3"  "s4"  "s5"  "s6"  "s7"  "s8"  "s9"  "s10"

[[2]]
 [1] "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12" "13" "14" "15" "16" "17" "18"
[19] "19" "20" "21" "22"
> head(fmr.seg.crc[[1]])
     start  end    value
[1,]     1  576 2.030296
[2,]   577 1112 1.945320
[3,]  1113 1511 1.929819
[4,]  1512 2113 1.868648
[5,]  2114 2573 1.938822
[6,]  2574 3992 1.966110

> fmr.seg.crc[1,2]
[[1]]
       start    end    value
 [1,]      1   1683 2.009863
 [2,]   1684   3683 1.943753
 [3,]   3684   7272 2.004721
 [4,]   7273   7823 1.909030
 [5,]   7824  12166 2.021245
 [6,]  12167  13125 1.909732
 [7,]  13126  15006 2.040557
 [8,]  15007  16044 1.965647
 [9,]  16045  16598 2.039992
[10,]  16599  17470 2.107079
[11,]  17471  17521 2.021539
[12,]  17522  18364 1.942838
[13,]  18365  19195 2.094474
[14,]  19196  21016 2.021019
[15,]  21017  22644 1.970473
[16,]  22645  23065 2.030463
[17,]  23066  23689 2.134962
[18,]  23690  23823 2.037685
[19,]  23824  28197 2.012424
[20,]  28198  33313 2.042131
[21,]  33314  35797 1.991916
[22,]  35798  35824 2.025841
[23,]  35825  37962 2.062941
[24,]  37963  41552 2.021660
[25,]  41553  46006 2.046230
[26,]  46007  50217 2.014589
[27,]  50218  51558 1.945273
[28,]  51559  57890 2.019592
[29,]  57891  58896 2.117450
[30,]  58897  59443 2.052708
[31,]  59444  59533 2.029076
[32,]  59534  62300 1.971623
[33,]  62301  64252 2.047004
[34,]  64253  66429 1.980032
[35,]  66430  70187 2.039259
[36,]  70188  72583 1.999711
[37,]  72584  74952 2.037337
[38,]  74953  75459 1.994685
[39,]  75460  76248 1.907432
[40,]  76249  77551 1.974716
[41,]  77552  82026 2.026742
[42,]  82027  83915 1.971480
[43,]  83916  87782 2.021381
[44,]  87783  90469 2.059347
[45,]  90470  91817 2.000065
[46,]  91818  93625 2.080138
[47,]  93626  94351 2.033229
[48,]  94352  97927 2.002070
[49,]  97928 107217 2.059019
[50,] 107218 115066 2.033657
[51,] 115067 118643 2.082806
[52,] 118644 123727 2.043857
[53,] 123728 125791 2.095192
[54,] 125792 126639 2.056129
[55,] 126640 129253 2.025997
[56,] 129254 132674 2.071402
[57,] 132675 133815 1.993041
[58,] 133816 136346 2.053994
[59,] 136347 136743 1.997972
[60,] 136744 139120 1.963982
[61,] 139121 140701 2.059231
[62,] 140702 142317 1.983171
[63,] 142318 147205 2.032126
[64,] 147206 149266 1.958569
[65,] 149267 151682 2.007082
[66,] 151683 153611 1.956822

Screen shot of the object in R looks like this: R中对象的屏幕截图如下所示:

在此处输入图片说明

My task is to convert a regular input file with 4 columns into this R object. 我的任务是将具有4列的常规输入文件转换为该R对象。 My input data looks like this : 我的输入数据如下所示:

> head(seg2b)
     Chromosome     Start       End     value
[1,]          1     62920    462795 2.2251460
[2,]          1    462894  54574132 1.5044123
[3,]          1  54574878  54575365 0.2056125
[4,]          1  54576652 112147704 1.5074394
[5,]          1 112153343 112154768 2.4605827
[6,]          1 112163334 116601768 1.5106820

It is a matrix whose entries are lists consisting of one element, which is again a matrix. 它是一个矩阵,其条目是由一个元素组成的列表,这又是一个矩阵。 For instance, 例如,

m <- matrix(1:4, 2, 2)
(obj <- matrix(list(m, m, m, m), 2, 2))
#      [,1]      [,2]     
# [1,] Integer,4 Integer,4
# [2,] Integer,4 Integer,4

obj[1, 1]
# [[1]]
#      [,1] [,2]
# [1,]    1    3
# [2,]    2    4

Without further information it's not really clear what to do with your new input. 没有更多信息,还不清楚如何处理新输入。 Perhaps there is a separate submatrix for each new value of Chromosome . 也许每个新的Chromosome值都有一个单独的子矩阵。 In your example you have only a single value of it, so then 在您的示例中,您只有一个值,因此

(obj <- matrix(list(seg2b[, -1]), 1, 1))
#      [,1]  
# [1,] List,3

obj[1,1]
# [[1]]
#          Start       End     value
# [1,]     62920    462795 2.2251460
# [2,]    462894  54574132 1.5044123
# [3,]  54574878  54575365 0.2056125
# [4,]  54576652 112147704 1.5074394
# [5,] 112153343 112154768 2.4605827
# [6,] 112163334 116601768 1.5106820

But I guess in your full input data there are multiple Chromosome values. 但是我想您的完整输入数据中会有多个Chromosome值。 As to give a full answer, it is necessary to know what columns and rows of obj represent. 为了给出完整的答案,有必要知道obj列和行代表什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM