This vignette explains:
For those who want an in-depth understanding of the workflow, we explain:
inst/extdata/.Two input modes are available:
By default, cacti_peak_window() runs genome-wide
(chr = "All"), iterating through all chromosomes present in
file_pheno_meta and performing FDR correction.
file_vcf, orfile_geno + file_snp_posfile_pheno)ID)file_pheno_meta)phe_idphe_chrphe_fromphe_tofile_cov)For genome-wide analysis, keep genotype, phenotype, and metadata as
all-chromosome inputs. Chromosome iteration is controlled by
chr.
These inputs follow standard QTL mapping conventions used by MatrixEQTL and
QTLtools (genotype, phenotype, and covariates with matched sample IDs), with
CACTI-specific phenotype metadata columns (phe_id, phe_chr, phe_from,
phe_to) used for window-based grouping and chromosome iteration.
library(cacti)
file_pheno_meta <- system.file("extdata", "test_cacti_peak_chr5_pheno_meta.bed", package = "cacti")
file_pheno <- system.file("extdata", "test_cacti_peak_chr5_pheno.txt", package = "cacti")
file_cov <- system.file("extdata", "test_cacti_peak_chr5_covariates.txt", package = "cacti")
file_vcf <- system.file("extdata", "test_cacti_peak_chr5_geno.vcf", package = "cacti")
head(data.table::fread(file_pheno_meta))
head(data.table::fread(file_pheno))[, 1:5]
head(data.table::fread(file_cov))[, 1:5]
If you already have cis-QTL summary stats, you can provide:
qtl_files (or qtl_file) with required
columns:
phe_idvar_idzqtl_file <- system.file("extdata", "test_cacti_peak_chr5_matrixqtl_sumstats.txt.gz", package = "cacti")
head(data.table::fread(qtl_file))
Use one function: cacti_peak_window().
window_size controls how peaks are grouped into non-overlapping genomic windows before testing (for example, "50kb" means 50,000-bp windows).
This runs MatrixEQTL first, then standard CACTI automatically.
library(cacti)
res <- cacti_peak_window(
window_size = "50kb",
file_pheno_meta = file_pheno_meta,
file_pheno = file_pheno,
file_cov = file_cov,
file_vcf = file_vcf,
cis_dist = 100000, # 100 kb cis window for MatrixEQTL
chr = "All", # default; can be omitted
do_fdr = TRUE, # default; can be omitted
out_prefix = tempfile("cacti_peak_window_")
)
res
If you already have QTL summary statistics, pass
qtl_files (or qtl_file). In this mode,
MatrixEQTL is skipped.
res_summary <- cacti_peak_window(
window_size = "50kb",
file_pheno_meta = file_pheno_meta,
file_pheno = file_pheno,
file_cov = file_cov,
chr = "All",
do_fdr = TRUE,
qtl_file = qtl_file, # optional summary-stat mode
out_prefix = tempfile("cacti_peak_window_summary_")
)
res_summary
cacti_peak_window() returns the same output structure as
cacti_run_genome():
file_peak_group
file_peak_group_peaklevel
file_pheno_cov_residual
file_p_peak_group
(group, snp, pval) filesfile_fdr_out
names(res_summary)
res_summary$file_fdr_out
For detailed low-level APIs, see:
cacti_peak_window()
file_vcf or
file_geno + file_snp_pos) to run MatrixEQTL
first, then CACTI.qtl_file /
qtl_files) to skip MatrixEQTL.chr = "All" (iterate over
all chromosomes in file_pheno_meta).do_fdr controls FDR correction.cacti_run_chr()
qtl_file = NULL.cacti_run_genome()
qtl_files = NULL.cacti_matrixqtl_cis(): runs MatrixEQTL and writes
CACTI-compatible summary stats.cacti_group_peak_window(): groups peaks into
windows.cacti_pheno_cov_residual(): residualizes phenotypes by
covariates.cacti_cal_p(): computes per-window p-values.cacti_add_fdr(): aggregates p-values and adds FDR.file_vcf or file_geno +
file_snp_pos), phenotype, metadata, and covariates.phe_id, var_id, z,
pval).chr = "All"), iterate over all chromosomes
and aggregate with FDR.qtl_file/qtl_files).library(cacti)
file_pheno_meta <- system.file("extdata", "test_cacti_peak_chr5_pheno_meta.bed", package = "cacti")
file_pheno <- system.file("extdata", "test_cacti_peak_chr5_pheno.txt", package = "cacti")
file_cov <- system.file("extdata", "test_cacti_peak_chr5_covariates.txt", package = "cacti")
file_vcf <- system.file("extdata", "test_cacti_peak_chr5_geno.vcf", package = "cacti")
res <- cacti_peak_window(
window_size = "50kb",
file_pheno_meta = file_pheno_meta,
file_pheno = file_pheno,
file_cov = file_cov,
file_vcf = file_vcf,
chr = "All",
do_fdr = TRUE,
cis_dist = 100000,
out_prefix = tempfile("cacti_peak_window_in_depth_")
)
res
qtl_file <- system.file("extdata", "test_cacti_peak_chr5_matrixqtl_sumstats.txt.gz", package = "cacti")
res_qtl <- cacti_peak_window(
window_size = "50kb",
file_pheno_meta = file_pheno_meta,
file_pheno = file_pheno,
file_cov = file_cov,
qtl_file = qtl_file,
chr = "All",
do_fdr = TRUE,
out_prefix = tempfile("cacti_peak_window_in_depth_qtl_")
)
res_qtl
# Genome-wide wrapper (+ FDR)
res_genome <- cacti_run_genome(
window_size = "50kb",
file_pheno_meta = file_pheno_meta,
file_pheno = file_pheno,
file_cov = file_cov,
chrs = paste0("chr", 1:22),
qtl_files = qtl_file,
out_prefix = tempfile("cacti_run_genome_"),
min_peaks = 1,
do_fdr = TRUE
)
# Optional: single chromosome in the same high-level API
res_chr <- cacti_peak_window(
window_size = "50kb",
file_pheno_meta = file_pheno_meta,
file_pheno = file_pheno,
file_cov = file_cov,
file_vcf = file_vcf,
chr = "chr5",
do_fdr = FALSE, # or TRUE
out_prefix = tempfile("cacti_peak_window_chr5_")
)