@@ -72,15 +72,15 @@ test_that(".h5_chrom_peaks_chunk works", {
72
72
c(" chrom_peak_data" , " chrom_peaks" ,
73
73
" chrom_peaks_colnames" , " chrom_peaks_rownames" ))
74
74
H5Fclose(h5 )
75
- a <- .h5_read_data(h5_file , index = " S2" , name = " chrom_peaks" ,
75
+ a <- .h5_read_data(h5_file , id = " S2" , name = " chrom_peaks" ,
76
76
ms_level = 1L , read_colnames = TRUE ,
77
77
read_rownames = TRUE )[[1L ]]
78
78
# # add = TRUE
79
79
res <- .h5_find_chrom_peaks_chunk(
80
80
sps , msLevel = 1L , param = p , h5_file = h5_file , add = TRUE ,
81
81
sample_id = xmse_h5 @ sample_id )
82
82
expect_equal(res , 4L )
83
- b <- .h5_read_data(h5_file , index = " S2" , name = " chrom_peaks" ,
83
+ b <- .h5_read_data(h5_file , id = " S2" , name = " chrom_peaks" ,
84
84
ms_level = 1L , read_colnames = TRUE ,
85
85
read_rownames = TRUE )[[1L ]]
86
86
expect_equal(nrow(b ), 2 * nrow(a ))
@@ -205,14 +205,14 @@ test_that(".h5_xmse_merge_neighboring_peaks works", {
205
205
h5f <- tempfile()
206
206
ref <- loadXcmsData(" faahko_sub2" )
207
207
x <- .xcms_experiment_to_hdf5(ref , h5f )
208
- ref <- .h5_read_data(x @ hdf5_file , index = x @ sample_id ,
208
+ ref <- .h5_read_data(x @ hdf5_file , id = x @ sample_id ,
209
209
ms_level = rep(1L , length(x )),
210
210
read_colnames = TRUE , read_rownames = TRUE )
211
211
.h5_xmse_merge_neighboring_peaks(x )
212
212
mod_count <- as.vector(rhdf5 :: h5read(h5f , " /header/modcount" ))
213
213
expect_true(mod_count > x @ hdf5_mod_count )
214
214
# # Check that content was changed.
215
- res <- .h5_read_data(x @ hdf5_file , index = x @ sample_id ,
215
+ res <- .h5_read_data(x @ hdf5_file , id = x @ sample_id ,
216
216
ms_level = rep(1L , length(x )),
217
217
read_colnames = TRUE , read_rownames = TRUE )
218
218
expect_true(nrow(ref [[1L ]]) > nrow(res [[1L ]]))
@@ -235,7 +235,7 @@ test_that(".h5_xmse_merge_neighboring_peaks works", {
235
235
res <- .xcms_experiment_to_hdf5(ref , h5f )
236
236
237
237
.h5_xmse_merge_neighboring_peaks(res )
238
- res <- .h5_read_data(res @ hdf5_file , index = res @ sample_id ,
238
+ res <- .h5_read_data(res @ hdf5_file , id = res @ sample_id ,
239
239
ms_level = rep(1L , length(res )),
240
240
read_colnames = TRUE , read_rownames = TRUE )
241
241
ref <- .xmse_merge_neighboring_peaks(ref )
@@ -250,7 +250,7 @@ test_that(".h5_xmse_merge_neighboring_peaks works", {
250
250
251
251
test_that(" .h5_read_matrix works" , {
252
252
h5f <- tempfile()
253
- xcms ::: .h5_initialize_file(h5f )
253
+ .h5_initialize_file(h5f )
254
254
255
255
a <- cbind(a = c(1.2 , 1.4 ), b = c(3.5 , 3.6 ), c = c(5.3 , 5.1 ))
256
256
rownames(a ) <- c(" CP1" , " CP2" )
@@ -319,6 +319,26 @@ test_that(".h5_read_matrix works", {
319
319
file.remove(h5f )
320
320
})
321
321
322
+ test_that(" .h5_read_chrom_peaks_matrix works" , {
323
+ res <- .h5_read_chrom_peaks_matrix(
324
+ " /S2/ms_1/chrom_peaks" , xmse_h5 @ hdf5_file ,
325
+ read_colnames = FALSE , read_rownames = FALSE )
326
+ expect_true(is.matrix(res ))
327
+ expect_true(is.numeric(res ))
328
+ res <- .h5_read_chrom_peaks_matrix(
329
+ " /S2/ms_1/chrom_peaks" , xmse_h5 @ hdf5_file ,
330
+ read_colnames = TRUE , read_rownames = FALSE ,
331
+ mz = c(300 , 350 ), rt = c(3000 , 3500 ), type = " within" )
332
+ expect_true(all(res [, " mz" ] > 300 & res [, " mz" ] < 350 ))
333
+ expect_true(all(res [, " rt" ] > 3000 & res [, " rt" ] < 3500 ))
334
+
335
+ res <- .h5_read_chrom_peaks_matrix(
336
+ " /S2/ms_1/chrom_peaks" , xmse_h5 @ hdf5_file ,
337
+ read_colnames = TRUE , read_rownames = FALSE ,
338
+ mz = c(300 , 350 ), type = " within" )
339
+ expect_true(all(res [, " mz" ] > 300 & res [, " mz" ] < 350 ))
340
+ })
341
+
322
342
test_that(" .h5_read_data_frame works" , {
323
343
h5f <- tempfile()
324
344
.h5_initialize_file(h5f )
@@ -401,32 +421,32 @@ test_that(".h5_read_data works", {
401
421
# # chrom peaks
402
422
res <- .h5_read_data(h5f )
403
423
expect_equal(res , list ())
404
- res <- .h5_read_data(h5f , index = 2 , name = " chrom_peaks" , ms_level = 2L )
424
+ res <- .h5_read_data(h5f , id = 2 , name = " chrom_peaks" , ms_level = 2L )
405
425
expect_equal(length(res ), 1L )
406
426
expect_equal(res [[1L ]], unname(b2 ))
407
- res <- .h5_read_data(h5f , index = 1 , name = " chrom_peaks" , ms_level = 2L ,
427
+ res <- .h5_read_data(h5f , id = 1 , name = " chrom_peaks" , ms_level = 2L ,
408
428
read_colnames = TRUE )
409
429
expect_equal(unname(res [[1L ]]), unname(a2 ))
410
430
expect_equal(colnames(res [[1L ]]), colnames(a2 ))
411
431
expect_true(is.null(rownames(res [[1L ]])))
412
- res <- .h5_read_data(h5f , index = 1 , name = " chrom_peaks" , ms_level = 2L ,
432
+ res <- .h5_read_data(h5f , id = 1 , name = " chrom_peaks" , ms_level = 2L ,
413
433
read_rownames = TRUE )
414
434
expect_equal(unname(res [[1L ]]), unname(a2 ))
415
435
expect_equal(rownames(res [[1L ]]), rownames(a2 ))
416
436
expect_true(is.null(colnames(res [[1L ]])))
417
437
# # single column
418
- res <- .h5_read_data(h5f , index = c(2 , 1 ), name = " chrom_peaks" ,
438
+ res <- .h5_read_data(h5f , id = c(2 , 1 ), name = " chrom_peaks" ,
419
439
ms_level = c(2L , 2L ), j = 2 )
420
440
expect_equal(length(res ), 2L )
421
441
expect_true(ncol(res [[1L ]]) == 1L )
422
442
expect_equal(res [[1L ]][, 1 ], unname(b2 [, 2 ]))
423
- res <- .h5_read_data(h5f , index = c(2 , 1 ), name = " chrom_peaks" ,
443
+ res <- .h5_read_data(h5f , id = c(2 , 1 ), name = " chrom_peaks" ,
424
444
ms_level = c(2L , 2L ), j = 2 , read_colnames = TRUE ,
425
445
read_rownames = TRUE )
426
446
expect_equal(length(res ), 2L )
427
447
expect_true(ncol(res [[1L ]]) == 1L )
428
448
expect_equal(res [[1L ]][, 1 , drop = FALSE ], b2 [, 2 , drop = FALSE ])
429
- res <- .h5_read_data(h5f , index = c(1 , 2 , 1 ), name = " chrom_peaks" ,
449
+ res <- .h5_read_data(h5f , id = c(1 , 2 , 1 ), name = " chrom_peaks" ,
430
450
ms_level = c(2 , 2 , 2 ), j = 1L ,
431
451
read_colnames = TRUE ,
432
452
read_rownames = TRUE )
@@ -435,7 +455,7 @@ test_that(".h5_read_data works", {
435
455
expect_equal(res [[2 ]], b2 [, 1 , drop = FALSE ])
436
456
437
457
# # selected rows.
438
- res <- .h5_read_data(h5f , index = c(1 , 2 , 1 ), name = " chrom_peaks" ,
458
+ res <- .h5_read_data(h5f , id = c(1 , 2 , 1 ), name = " chrom_peaks" ,
439
459
ms_level = c(2 , 2 , 2 ), j = 1L , i = c(2 , 1 , 2 ),
440
460
read_colnames = TRUE ,
441
461
read_rownames = TRUE )
@@ -445,13 +465,13 @@ test_that(".h5_read_data works", {
445
465
expect_equal(res [[1 ]], a2 [c(2 , 1 , 2 ), 1 , drop = FALSE ])
446
466
447
467
# # chrom peak data
448
- res <- .h5_read_data(h5f , index = c(2 , 1 ), name = " chrom_peak_data" ,
468
+ res <- .h5_read_data(h5f , id = c(2 , 1 ), name = " chrom_peak_data" ,
449
469
ms_level = c(2L , 2L ), read_colnames = TRUE ,
450
470
read_rownames = TRUE )
451
471
expect_equal(length(res ), 2 )
452
472
rownames(b ) <- c(" CP3" , " CP4" , " CP5" )
453
473
expect_equal(unname(res [[1L ]]), unname(b ))
454
- res <- .h5_read_data(h5f , index = 1 , name = " chrom_peak_data" ,
474
+ res <- .h5_read_data(h5f , id = 1 , name = " chrom_peak_data" ,
455
475
ms_level = 2L , j = " is_filled" )
456
476
expect_equal(length(res ), 1L )
457
477
expect_equal(res [[1L ]][, 1 ], a $ is_filled )
0 commit comments