Workflow requirements

Reference preparation, LD computation, model fitting, and scoring have separate resource requirements. Check disk and memory capacity before computing genome-wide LD. Runtime depends on marker counts, reference sample size, model settings, and thread limits. Measurements of a tutorial example do not establish completion of every analysis reported in a manuscript.

Use Glist from the 1000G preparation example. The reference already selects markers available in the gact database.

library(gbase)
library(gact)
library(data.table)

GAlist <- readRDS("C:/Users/gact/hsa.0.0.1/GAlist_hsa.0.0.1.rds")

for (ancestry in c("eur", "eas", "sas")) {
  descriptor <- file.path(GAlist$dirs["marker"],
    paste0("Glist_1000G_", ancestry, "_filtered.rds"))
  Glist <- readRDS(descriptor)
  Glist <- gprep(Glist, task="sparseld", msize=1000,
    ldfiles=file.path(GAlist$dirs["marker"], paste0("g1000_", ancestry, ".ld")),
    nthreads=4)
  saveRDS(Glist, descriptor)

  markers <- data.frame(rsids=unlist(Glist$rsids, use.names=FALSE),
    chr=unlist(Glist$chr), pos=unlist(Glist$pos),
    ea=unlist(Glist$a1), nea=unlist(Glist$a2),
    eaf=unlist(Glist$af), maf=unlist(Glist$maf), map=unlist(Glist$map))
  markers$ldscores <- getLDscores(Glist)[markers$rsids]
  fwrite(markers, file.path(GAlist$dirs["marker"],
    paste0("markers_1000G_", ancestry, "_filtered.txt.gz")))
}

msize=1000 retains a 1,000-marker distance window, with no base-pair window or r² cutoff. LD scores are computed in the same pass. To store fewer correlations, supply an explicit r2 cutoff. ldfiles names the output prefix; gbase writes its own sparse-resource files. Keep those files with Glist for analyses that read LD.

For eigenvalues of supplied marker sets, use gprep(Glist, task="eigen", sets=sets). See genetic correlation for methods that reuse stored LD scores and regional moments.