Skip to content

Commit

Permalink
feat: add dropFilledChromPeaks,XcmsExperimentHdf5
Browse files Browse the repository at this point in the history
  • Loading branch information
jorainer committed Nov 29, 2024
1 parent d62c5c6 commit fe2c689
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
10 changes: 5 additions & 5 deletions R/XcmsExperimentHdf5.R
Original file line number Diff line number Diff line change
Expand Up @@ -489,10 +489,10 @@ setMethod("dropFilledChromPeaks", "XcmsExperimentHdf5", function(object) {
for (msl in object@gap_peaks_ms_level) {
for (id in object@sample_id) {
pks <- .h5_read_data(
object@hdf5_file, id, msl, "chrom_peaks",
read_colnames= TRUE, read_rownames= TRUE)[[1L]]
object@hdf5_file, id, "chrom_peaks", msl,
read_colnames = TRUE, read_rownames = TRUE)[[1L]]
pkd <- .h5_read_data(
object@hdf5_file, id, msl, "chrom_peak_data",
object@hdf5_file, id, "chrom_peak_data", msl,
read_colnames = TRUE)[[1L]]
keep <- which(!pkd$is_filled)
l <- list(pks[keep, , drop = FALSE])
Expand All @@ -507,10 +507,10 @@ setMethod("dropFilledChromPeaks", "XcmsExperimentHdf5", function(object) {
replace = TRUE, write_rownames = FALSE)
fmap <- .h5_read_data(
object@hdf5_file, id, "feature_to_chrom_peaks", msl)[[1L]]
l <- list(fmap[!fmap[, 2L] %in% keep, , drop = FALSE])
l <- list(fmap[fmap[, 2L] %in% keep, , drop = FALSE])
names(l) <- id
mc <- .h5_write_data(
x@hdf5_file, l, name = "feature_to_chrom_peaks",
object@hdf5_file, l, name = "feature_to_chrom_peaks",
write_colnames = FALSE, write_rownames = FALSE,
ms_level = msl)
}
Expand Down
13 changes: 12 additions & 1 deletion tests/testthat/test_XcmsExperimentHdf5.R
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,18 @@ test_that("fillChromPeaks,XcmsExperimentHdf5,PeakAreaParam", {
tmp <- featureValues(res, msLevel = 1L, filled = FALSE)
expect_equal(tmp, fvals)

## LLLLL test dropFille
## dropFilledChromPeaks
res <- dropFilledChromPeaks(res)
expect_equal(res@hdf5_mod_count, 66L)
expect_false(hasFilledChromPeaks(res))
cps_res <- chromPeaks(res)
expect_equal(cps_res, cps)
cpd_res <- chromPeakData(res)
expect_true(all(!cpd_res$is_filled))

fvals_res <- featureValues(res, msLevel = 1L)
expect_equal(fvals, fvals_res)
expect_equal(res@processHistory, x@processHistory)

rm(tf)
})
Expand Down

0 comments on commit fe2c689

Please sign in to comment.