ras_scan_external: RAS Scan with External Weights on All Samples

View source: R/sumstats.R

ras_scan_externalR Documentation

RAS Scan with External Weights on All Samples

Description

Runs the Stage-1 forward scan with weights taken from an independent external GWAS instead of a within-sample training split. Because the weights are independent of the target cohort, no 50/50 split is drawn and no repetitions are averaged: every sample is scanned once. Genotypes are streamed from a .rasbin file in chunks. The in-memory implementation is ras_scan_external_original.

Usage

ras_scan_external(
  geno,
  phenotype,
  covariates,
  covariate_cols,
  weights,
  is_continuous = TRUE,
  skip1 = 10,
  skip2 = 20,
  min_window_size = 5,
  max_window_size = 100,
  chunk_snps = 5000,
  chrom = 1,
  save_dir = NULL
)

Arguments

geno

Either the path to a .rasbin genotype file (see geno_to_rasbin, bed_to_rasbin) or an in-memory numeric genotype matrix, which is converted to a temporary .rasbin file for the run.

phenotype

Numeric vector of length n, in the sample order of geno.

covariates

Data frame with n rows, in the same sample order.

covariate_cols

Character vector of covariate column names.

weights

Numeric vector of length N, one weight per variant in the order of geno, typically ras_harmonize_sumstats(...)$weights. Non-finite entries count as zero.

is_continuous

Logical. TRUE for a quantitative trait.

skip1

Integer. Stride of the profile grid in SNPs: the profile has one value every skip1 SNPs. Default 10.

skip2

Integer. Step, in SNPs, by which the scan window grows from min_window_size to max_window_size at each grid position. Default 20.

min_window_size, max_window_size

Integer. Smallest and largest scan window, in SNPs. Default 5 and 100.

chunk_snps

Integer. SNP columns held in memory at a time. Bounds peak memory at roughly n * chunk_snps * 8 bytes per worker. Default 5000.

chrom

Integer or character. Chromosome label used in the output file names. Default 1.

save_dir

Character or NULL. Directory in which to save the profile as ext_scan_chr<chrom>.rds; NULL (default) saves nothing.

Details

The thresholds of the changepoint detector were set on averaged profiles, whose noise floor is lower than that of a single-pass profile; calibrate before treating a detection from this scan as a finding (for the box-scan detector, ras_box_calibrate on permuted phenotypes).

Value

A list with x (the SNP index of each grid point) and y (the -\log_{10}(p) profile).

See Also

ras_harmonize_sumstats to build weights; ras_scan for the split-based scan; ras_box_detect and ras_detect to detect regions on the profile.


RAS documentation built on Nov. 3, 2026, 1:07 a.m.