workflow4metabolomics / metaMS

Move to https://github.com/workflow4metabolomics/tools-metabolomics
2 stars 2 forks source link

Error with CDF and DB #39

Open jsaintvanne opened 5 years ago

jsaintvanne commented 5 years ago

During the runGC with CDF files and comparing with a DB, we obtain this error :

Error in x[, settings$timeComparison] : incorrect number of dimensions
Calls: runGC ... match.unannot.patterns -> sapply -> sapply -> lapply -> FUN -> mean

https://github.com/rwehrens/metaMS/blob/master/R/matchSamples2Samples.R#L173 It looks that due to a list of 1 element that is not a list but a matrix (probably because there is only one element in it)... So I should modify how the list has been made just here https://github.com/rwehrens/metaMS/blob/master/R/matchSamples2Samples.R#L31

jsaintvanne commented 5 years ago

After investigate a little, this parameter should be a list and in this case with cdf we obtain a matrix... For CDF :

> print(class(noannot.idx))
[1] "matrix"
>     print(noannot.idx)
      ./0205065_1.CDF ./0205065_2.CDF ./0205065_3.CDF ./0205065_4.CDF
 [1,]               2               2               2               2
 [2,]               8               8               8               8
 [3,]               9               9               9               9
 [4,]              10              10              10              10
 [5,]              11              11              11              11
 [6,]              12              12              12              12
 [7,]              13              13              13              13
 [8,]              14              14              14              14
 [9,]              15              15              15              15
[10,]              16              16              16              16
[11,]              17              17              17              17
[12,]              18              18              18              18
[13,]              19              19              19              19
[14,]              20              20              20              20
[15,]              21              21              21              21
[16,]              22              22              22              22
[17,]              23              23              23              23
[18,]              24              24              24              24
[19,]              25              25              25              25
[20,]              26              26              26              26
[21,]              27              27              27              27
[22,]              28              28              28              28
[23,]              29              29              29              29
[24,]              30              30              30              30
[25,]              31              31              31              31
[26,]              32              32              32              32
[27,]              33              33              33              33
[28,]              34              34              34              34
[29,]              35              35              35              35
[30,]              36              36              36              36
[31,]              37              37              37              37
[32,]              38              38              38              38
[33,]              39              39              39              39
[34,]              40              40              40              40
[35,]              41              41              41              41
[36,]              42              42              42              42
[37,]              43              43              43              43
[38,]              44              44              44              44
[39,]              45              45              45              45
[40,]              46              46              46              46
[41,]              47              47              47              47
[42,]              48              48              48              48
[43,]              49              49              49              49

For others like mzData :

[1] "list"
>     print(noannot.idx)
$`./alg3.mzData`
 [1]  1  5  6  8 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
[26] 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
[51] 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
[76] 82

$`./alg8.mzData`
 [1]  2  7  8  9 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
[26] 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
[51] 57 58 59 60 61 62 63 64 65 66 67 68

$`./alg7.mzData`
 [1]  2  6  7  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
[26] 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
[51] 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76

$`./alg9.mzData`
 [1]  3  5  6  8 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
[26] 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
[51] 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76

$`./alg11.mzData`
 [1]  2  6  7  8 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
[26] 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
[51] 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
[76] 81 82 83 84 85

$`./alg2.mzData`
 [1]  1  4  5  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
[26] 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
[51] 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
[76] 81 82 83
jsaintvanne commented 5 years ago

So, after investigation, we obtain a matrix with this mapply function : https://github.com/rwehrens/metaMS/blob/master/R/matchSamples2Samples.R#L38

BUT apparently, we obtain a matrix only when ALL lists have the same length !

So, I should probably just add something to transform matrix into list like

as.list(as.data.frame(x))

This can be a problem when columns haven't the same length but we just said that we obtain a matrix ONLY when columns have the same length... !

jsaintvanne commented 5 years ago

PR https://github.com/rwehrens/metaMS/pull/14