
Filter markers/SNP based on their position on the read
Source:R/filter_snp_position_read.R
filter_snp_position_read.RdThis filter removes markers/SNPs based on their position on the read. The data requires snp, locus and col information (e.g. from a VCF file).
The impact of assembly artifacts can be tested in downstream analysis with the whitelist and blacklist generated by this function.
Filter target: Markers.
Statistics: The position of the SNPs on the read.
Usage
filter_snp_position_read(
data,
strata = NULL,
interactive.filter = TRUE,
filter.snp.position.read = NULL,
filename = NULL,
parallel.core = parallel::detectCores() - 1,
verbose = TRUE,
...
)Arguments
- data
A tidy genomic data frame or another genomic object supported by the calling function.
- strata
Optional strata file or object containing individual and group information. Default:
strata = NULL.- interactive.filter
Logical indicating whether an interactive filtering session may display diagnostics and ask for thresholds. Default:
interactive.filter = TRUE.- filter.snp.position.read
(character) Options are:
"outliers", "q75", "iqr", c(min value,max value). For a safe and conservative value, use"outliers", this will remove SNPs with outlier position on the reads. Default:filter.snp.position.read = NULL.- filename
(optional) Name of the filtered tidy data frame file written to the working directory (ending with
.tsv) Default:filename = NULL.- parallel.core
Number of workers available for parallel operations. Default:
parallel.core = parallel::detectCores() - 1.- verbose
Logical. Display progress messages. Default:
verbose = TRUE.- ...
Additional arguments passed to lower-level screening or filtering functions.
Value
The filtered data in the same representation as the input. GDS marker metadata and active variants are updated in place. Diagnostic files, marker lists, and filtering parameters are written to the output folder.
Interactive version
The function first displays and writes the distribution of SNP positions on reads. It then asks the user to choose one of the following options:
1: all positions, which turns this filter off;2: boxplot outlier limits;3: the third-quartile rule;4: the interquartile-range rule;5: user-defined minimum and maximum positions.
With option 5, the function asks
"Enter the min position of SNP on the read:" followed by
"Enter the max position of SNP on the read:". Positions inside the
inclusive interval are retained. Use interactive.filter = FALSE and
provide filter.snp.position.read explicitly for reproducibility.
Examples
if (FALSE) { # \dontrun{
genome <- genometranslator::read_genome(
data = "turtle.vcf",
strata = "turtle.strata.tsv"
)
# Inspect SNP positions and choose a rule interactively.
genome <- radr::filter_snp_position_read(data = genome)
# Alternatively, use a separate unfiltered GDS for a scripted run.
scripted_genome <- genometranslator::read_genome("turtle_scripted.gds")
scripted_genome <- radr::filter_snp_position_read(
data = scripted_genome,
interactive.filter = FALSE,
filter.snp.position.read = "outliers"
)
} # }