| filter_low_coverage | R Documentation |
Removes columns (SNPs) or rows (samples) that carry too many missing values. Writes the result to a new dataset.
Missing values are the entries equal to 3, the missing-data code of
the 0/1/2/3 genotype encoding shared by the omics functions; NA or
NaN entries are not counted, so recode them to 3
beforehand. A column (or row) is removed when its proportion of 3s is
greater than or equal to pcent.
Row and column names of x, when present, are carried over to the
result: the names of the filtered axis are subset to the surviving elements.
When out_group/out_dataset are NULL (default) the result
is written alongside the input dataset with the suffix "_filtered".
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,
...
)
x |
An |
... |
Ignored. |
out_group |
Output group. |
out_dataset |
Output dataset name. |
pcent |
Numeric in [0,1]. Missing-data threshold
(default |
by_cols |
Logical. Filter columns ( |
overwrite |
Logical. Overwrite existing output. Default |
HDF5Matrix pointing to the filtered dataset, carrying the
dimension names of the surviving elements.
set.seed(42)
fn <- tempfile(fileext = ".h5")
# 0/1/2 genotypes with about 10% missing values, coded as 3
snps <- matrix(sample(c(0, 1, 2, 3), 200, replace = TRUE,
prob = c(.3, .3, .3, .1)), 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.2)
# Filter with explicit output
out2 <- filter_low_coverage(X, pcent = 0.2, out_group = "geno",
out_dataset = "filtered", overwrite = TRUE)
hdf5_close_all()
unlink(fn)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.