scan_motifs {GCModeller} R Documentation

Parallel Motif Site Scanning

Description

Scans given upstream sequences against a motif Position Weight Matrix (PWM) database in parallel. The function processes motif families independently, performs motif matching with customizable statistical thresholds, and aggregates the results into a single dataframe.

Usage

scan_motifs(db, seqs,
    pval.cutoff = 0.05,
    minW = 0.85,
    top = 3,
    scan.reverse = TRUE,
    workdir = './',
    n.threads = 8);

Arguments

db

\code{character}. The file path to the motif PWM database.

seqs

\code{character}. The file path to the FASTA file containing TSS upstream sequences for motif site matching.

identities.cutoff

\code{numeric}. The minimum identity/similarity cutoff required for a valid motif match. Default is \code{0.8}.

minW

\code{numeric}. The minimum weight or score threshold for a motif match. Default is \code{0.85}.

top

\code{integer}. The number of top matches to retain for each search region or motif. Default is \code{3}.

permutation

\code{integer}. The number of permutations to perform for calculating the statistical significance (e.g., p-value) of the motif matches. Default is \code{2500}.

workdir

\code{character}. The working directory where intermediate files and a \code{results/} subdirectory will be created. Default is \code{"./"}.

n.threads

\code{integer}. The number of CPU threads to use for parallel processing. Default is \code{8}.

Details

The function executes in two main stages: \enumerate{ \item \strong{Parallel Search}: It first reads the motif families from the database. Using a parallel backend (via \code{snowFall}), it distributes the search tasks across \code{n_threads}. Each thread scans the upstream sequences for a specific motif family and writes the intermediate results to individual CSV files in \code{<workdir>/results/}. \item \strong{Aggregation}: After all parallel tasks complete, the function reads all generated CSV files from the results directory and row-binds them into a single unified dataframe using \code{dplyr::bind_rows}. }

Authors

xieguigang

Value

A consolidated \code{data.frame} (or \code{tibble}) containing the motif site match results from all motif families. The exact columns depend on the output generated by the underlying \code{TRN.builder::motif_search} function.

Examples

#\dontrun{

# Define paths to your database and sequence file
motif_db <- "path/to/motif_database"
upstream_fasta <- "path/to/upstream_sequences.fasta"
# Run the parallel motif scanning
results <- scan_motifs(
db = motif_db,
seqs = upstream_fasta,
identities_cutoff = 0.85,
minW = 0.9,
top = 5,
permutation = 5000,
workdir = "./motif_scan_workspace",
n_threads = 16
)
head(results)

#}

[Package GCModeller version 1.1.0-beta Index]