filter_low_coverage: Remove high-missingness features from an HDF5Matrix

View source: R/S3_omics.R

filter_low_coverageR Documentation

Remove high-missingness features from an HDF5Matrix

Description

Removes columns (SNPs) or rows (samples) whose proportion of missing values (NAs) exceeds pcent. Writes result to a new dataset.

When out_group/out_dataset are NULL (default) the result is written alongside the input dataset with the suffix "_filtered".

Usage

filter_low_coverage(x, ...)

## S3 method for class 'HDF5Matrix'
filter_low_coverage(
  x,
  out_group = NULL,
  out_dataset = NULL,
  pcent = 0.05,
  by_cols = TRUE,
  overwrite = FALSE,
  ...
)

Arguments

x

An HDF5Matrix containing SNP data.

...

Ignored.

out_group

Output group. NULL (default) = same group as input.

out_dataset

Output dataset name. NULL (default) = input name + "_filtered".

pcent

Numeric in [0,1]. Maximum allowed NA proportion (default 0.05). Features above this are removed.

by_cols

Logical. Filter columns (TRUE, default) or rows.

overwrite

Logical. Overwrite existing output. Default FALSE.

Value

HDF5Matrix pointing to the filtered dataset.

Examples


fn <- tempfile(fileext = ".h5")
snps <- matrix(sample(c(0, 1, 2, NA), 200, replace = TRUE,
                       prob = c(.25, .25, .25, .25)), 20, 10)
X   <- hdf5_create_matrix(fn, "geno/raw", data = snps)

# Filter with auto output path (adds "_filtered" suffix)
out <- filter_low_coverage(X, pcent = 0.1)

# Filter with explicit output
out2 <- filter_low_coverage(X, out_group = "geno",
                             out_dataset = "filtered", overwrite = TRUE)
hdf5_close_all()
unlink(fn)



BigDataStatMeth documentation built on May 15, 2026, 1:07 a.m.