| Type: | Package |
| Title: | Statistical Genetics Data Objects and Loaders |
| Version: | 0.4.3 |
| Description: | Loads and manages statistical genetics data objects including reference panels, genotypes, LD matrices, annotations, and summary statistics. Follows the 'statgen' specification for use across 'Python', 'R', and 'MATLAB'/'Octave' runtimes. |
| License: | MIT + file LICENSE |
| URL: | https://github.com/precimed/statgen |
| BugReports: | https://github.com/precimed/statgen/issues |
| Encoding: | UTF-8 |
| Depends: | R (≥ 4.1) |
| Imports: | Matrix, jsonlite, digest, bit64, methods, data.table |
| Suggests: | R.utils, testthat (≥ 3.0.0), knitr, rmarkdown |
| Config/testthat/edition: | 3 |
| VignetteBuilder: | knitr |
| NeedsCompilation: | no |
| Packaged: | 2026-11-24 13:09:23 UTC; andrewmorris |
| Author: | Oleksandr Frei [aut, cph], Andrew Morris [cre, ctb] |
| Maintainer: | Andrew Morris <a.h.morris@mn.uio.no> |
| Repository: | CRAN |
| Date/Publication: | 2026-11-24 13:30:11 UTC |
Statistical Genetics Data Objects and Loaders
Description
CRAN-compatible R runtime for statgen statistical genetics data objects.
Details
statgen provides R objects and loaders for reference-aligned statistical genetics data: reference variants, genotypes, linkage disequilibrium (LD), annotations, and GWAS summary statistics. The package is designed for analysis workflows where genome build, chromosome names, and DNA strand have already been harmonized upstream.
The central object is a ReferencePanel, which defines the ordered SNP
axis used by the other panel types. LDPanel, GenotypePanel,
AnnotationPanel, and Sumstats objects expose data in those
reference coordinates. See allele_matching for how loading adjusts
allele orientation.
Typical workflows start by loading or caching a reference panel with
load_reference, then loading aligned data with functions such as
load_ld, load_genotype,
load_annotations, or load_sumstats. Panel objects
provide accessors for aligned vectors and matrices, select_shards
for canonical chromosome subsetting, and cache helpers for repeated analyses.
LD distributions are directory-based runtime artifacts discovered through
ld_manifest.json; they are loaded with load_ld rather than
as individual shard files. R reads the Python .npz LD shard format
directly after prepare_ld_npz_for_r adds an R reference-cache
sidecar. R-native object caches use RDS files, while portable source inputs
such as PLINK BIM/BED/FAM, BED annotations, and summary-statistics TSV files
remain external inputs.
See Also
allele_matching,
load_reference, load_ld,
load_genotype, load_annotations,
load_sumstats, version,
set_verbosity
Allele Matching and Orientation
Description
How loading makes summary statistics and genotype counts consistent with your reference panel.
Preparing your data
For genomic-position matching, prepare files with the same genome build, chromosome names, and DNA strand. ID matching allows different builds and strands for eligible SNVs when IDs identify the same biological variants. statgen does not verify those ID assignments, normalize chromosome names or alleles, perform liftover, or check a genome FASTA. Alleles must be uppercase DNA strings.
Which allele do results describe?
Your reference panel is a table of variants that determines the order of results and which allele they describe. The allele columns have different meanings depending on the file:
In the reference panel's BIM file,
a1(column 5) is the alternative allele (ALT), anda2(column 6) is the genome reference allele (REF).In a genotype BIM file,
a1is the allele counted by genotype calls, anda2is the other allele.In summary statistics,
a1(orEffectAllele) is the allele described by the effect size, Z score, and effect allele frequency (EAF).a2(orOtherAllele) is the other allele.
Loaded effects, EAF, and genotype counts describe the reference panel's
a1 (ALT) allele. create_sumstats() expects vectors already in the
reference panel's order and allele orientation; it does not match or swap
alleles.
Genomic-position matching
load_sumstats() and load_genotype() default to
match_by = "genomic_position", using chromosome, position, and alleles;
marker IDs do not affect this mode. They
prefer a row whose allele order already matches the reference panel, even
when its optional statistics or calls are missing. Otherwise, they can use
a row with reversed alleles. Sumstats rows with missing p are validated
and dropped before matching, so a valid swapped row can match when an exact
row has missing p. Each remaining row is used at most once.
Single nucleotide variants (SNVs) are swapped automatically, including A/T
and C/G pairs, assuming your files already use the same strand. Swapping
insertions and deletions is off by default. Enable it with
allow_indel_swaps = TRUE on either loading function only when you know
the reversed alleles describe the same biological variant. For example:
trait <- load_sumstats(path, reference, allow_indel_swaps = TRUE) genotype <- load_genotype(bfile_prefix, reference, allow_indel_swaps = TRUE)
This option applies to pairs with exactly one single-base and one longer allele. Pairs where both alleles have multiple bases must already match the reference panel's allele order.
load_reference() rejects repeated variants and SNPs listed with both
allele orders, such as A/G and G/A at the same position. Indels with reversed
allele orders can be listed as separate entries.
When multiple rows in your data compete to match one reference variant, loading fails. A row with matching allele order takes priority over rows with reversed alleles. Duplicate summary-statistics rows that cannot match any reference variant are ignored; genotype loading may still reject duplicate BIM entries.
ID matching
Set match_by = "id" to match marker IDs and alleles instead of positions:
trait <- load_sumstats(path, reference, match_by = "id") genotype <- load_genotype(bfile_prefix, reference, match_by = "id")
Both matching modes require allele matching. ID mode accepts distinct
single-base A/C/G/T alleles, excluding palindromic A/T and C/G pairs. It accepts
allele exchange, strand complementation, or both: A/G, G/A, T/C, and C/T form
one equivalence group. A/C and its equivalents form a different group, so one
ID may identify a variant in each group. Multi-base alleles are excluded even
when their order matches exactly. allow_indel_swaps = TRUE cannot be
combined with ID matching.
IDs must contain 1–32 printable non-whitespace ASCII characters. Empty,
missing, overlength, or invalid-character IDs and the placeholders .,
NA, and NaN are excluded; 0 is an ordinary ID. Comparison is exact and case-sensitive:
rs123 and RS123 do not match. There is no coordinate fallback.
Eligibility applies to IDs returned by the existing readers, including their
quoting and whitespace handling. Original reference strings and row order
are preserved.
Summary statistics require SNP, the allele columns, and P;
coordinate columns are optional and ignored. Rows with missing P are validated,
then dropped before matching. All remaining source rows are searched across
the supplied reference panel. Genotype loading retains chromosome-based file,
sample, and ploidy handling, searching only the corresponding chromosome.
Thus source rows with the same ID/allele key on two chromosomes are ambiguous
for sumstats, but only the same-chromosome row competes for a genotype slot.
Repeated reference ID/allele keys are assessed across the entire supplied panel; all slots in those groups are excluded with a warning. Selecting a reference subset before loading defines that assessment scope. Multiple eligible source rows for a remaining slot are an error, even if values agree or genotype calls are all missing. There is no exact-match priority in ID mode. Unmatched or excluded slots remain missing.
Adjusted values and swap information
When a match requires allele-count/effect inversion, Z and beta change sign and EAF becomes
1 - EAF. Other statistics (p, n, se, and info) and missing values are
preserved. Genotype hardcalls are flipped as 2 - x before any ploidy
scaling. Missing calls and calls for absent subjects remain missing.
is_allele_swapped(genotype) returns a logical vector in reference panel
order. It is true when counts are inverted and false for absent variants.
Strand complementation alone leaves values unchanged and the flag false;
complementation plus allele exchange requires inversion. A swapped variant can still have missing
genotype calls. Summary-statistics objects expose adjusted values without a
swap mask.
Loading messages
In genomic-position mode at the default "info" verbosity, loading reports
nonzero counts of swapped variants, with an A/T or C/G subset, by input file and chromosome
shard. It also reports unused indel rows that could match an otherwise
unmatched reference variant if indel swaps were enabled. Reversed rows
superseded by exact matches are not reported.
In ID mode, loading reports nonzero counts of excluded palindromic and multi-base variants, and matched rows requiring inversion or complementation. Unusable IDs and ambiguous reference keys produce warnings.
Use set_verbosity("quiet") to hide progress messages and loading
summaries. Warnings remain visible.
Long alleles and historical reference caches
Source loaders validate and preserve complete uppercase DNA sequences. Matching hashes use the first 1,000,000 bases of each allele. Longer alleles produce one warning per input file. Matching and hash-key duplicate checks cannot distinguish alleles that share this prefix but differ afterwards.
Older reference caches, including those inside older LD distributions, may use only the first 150 bases. They may fail to match alleles longer than 150 bases in newly loaded sources, despite unchanged reference checksums. Cache loading retains stored hashes and mappings. Rebuild the reference or its cache from canonical sources to use the new hashes. When rebuilding an LD distribution's reference cache, preserve reference row order and allele orientation.
Genotype caches and BED overrides
New genotype caches use genotype_cache/0.2 and preserve swap information.
Historical /0.1 caches remain readable with their original mappings
and calls, treating all stored variants as unswapped. Loading an old cache
does not find additional matches; reload the original files to obtain them.
Saving a loaded old cache writes /0.2 while retaining its mappings.
Summary-statistics caches keep their existing schema and adjusted values.
The allow_indel_swaps and match_by options apply when loading
source data and are not stored in caches. Cache loads and chromosome subsets
retain the stored values, mappings, and allele orientation. To change matching
options, load the original files again and save a new cache.
Genotype caches contain metadata, so BED files are still needed when fetching
calls. If you move a BED file, supply its new location with bed_path.
A replacement must preserve the original variant and sample layout and
allele order, including any chromosome-specific sample subsets. Stored swap
information still applies to the replacement BED data.
See Also
load_reference, load_sumstats,
create_sumstats, load_genotype,
is_allele_swapped, fetch_genotypes,
load_genotype_cache, set_verbosity
AnnotationPanel objects
Description
Paint binary BED and continuous BED-like interval annotations onto a reference panel, inspect sparse annotation matrices, and save or load R-native annotation caches.
Usage
load_annotations(bed_paths, reference, annotation_metadata = NULL,
annotation_metadata_paths = NULL)
load_annotation(path, reference, has_header = FALSE, value_columns = NULL,
group_column = NULL, annotation_names = NULL, annotation_metadata = NULL,
annotation_metadata_path = NULL)
create_annotations(reference, annotation_matrix, annotation_names,
is_binary = NULL, annotation_metadata = NULL)
create_annotation(reference, annovec, annotation_name,
is_binary = NULL, annotation_metadata = NULL)
save_annotations_cache(panel, path)
load_annotations_cache(path, shards = NULL)
annomat(x, ...)
annonames(x, ...)
num_annot(x, ...)
is_binary(x, ...)
annotation_metadata(x, ...)
select_annotations(x, names, ...)
union_annotations(x, other, mode = "by_name", ...)
Arguments
bed_paths |
Character path or character vector of 3-column BED files. |
path |
Character scalar annotation source or cache path. |
reference |
A |
has_header |
Logical scalar; whether |
value_columns |
Optional value columns for |
group_column |
Optional single grouping column for grouped binary annotations; R uses a one-based physical column index or a header name. |
annotation_matrix |
A finite numeric matrix with SNPs as rows and annotations as columns. |
annotation_names, names |
Character annotation names. |
annovec |
Finite numeric annotation vector aligned to |
annotation_name |
Character scalar annotation name. |
is_binary |
Optional logical vector marking columns that must contain only
|
annotation_metadata |
Optional character vector with one metadata string per annotation column. |
annotation_metadata_paths |
Optional character vector of sidecar paths for
|
annotation_metadata_path |
Optional sidecar path for |
panel, x, other |
Annotation panel objects. |
shards |
Optional character vector of shard labels in canonical order. |
mode |
Union mode. Currently only |
... |
Reserved for S3 methods. |
Details
BED intervals are interpreted as 0-based half-open intervals and are matched to
reference chromosome labels exactly. load_annotations() treats each BED
file as one binary annotation. load_annotation() loads one source file
that may be a 3-column binary BED file, a grouped binary BED-like file, or a
BED-like file with numeric value columns.
For load_annotation(), a 3-column input with value_columns = NULL
produces one binary annotation. A 4-column input with
value_columns = NULL uses column 4 as one continuous annotation.
Inputs with five or more columns require explicit value_columns; for
headerless files they also require annotation_names. Integer
value_columns are one-based physical file columns and must select
columns 4 or later. Named selectors require has_header = TRUE.
group_column is mutually exclusive with value_columns; each
distinct non-empty group value becomes one binary annotation named exactly from
that group value.
is_binary marks columns that should be treated as binary membership
annotations. When omitted in create_annotations(), it is inferred by
checking each sparse matrix column: a column is binary when all stored non-zero
values are exactly 1; implicit zeros are allowed. Declared binary
columns must contain only 0 and 1.
annotation_metadata contains opaque per-column strings. When metadata is
omitted, loaders generate compact JSON provenance strings containing the source
file and selected source column. For load_annotations(),
annotation_metadata_paths entries are file-level sidecars whose full
contents are preserved. For column-valued load_annotation() inputs,
annotation_metadata_path must contain one non-empty physical line per
physical input column; metadata for selected value columns is taken from the
matching sidecar lines.
Value
load_annotations(), load_annotation(), create_annotations(),
create_annotation(), and load_annotations_cache() return
AnnotationPanel S3 objects. annomat(x) returns a sparse numeric
Matrix::dgCMatrix with column names equal to annonames(x).
Examples
ref_path <- system.file("extdata", "reference_chr1.bim", package = "statgen")
bed_path <- system.file("extdata", "anno1.bed", package = "statgen")
ref <- load_reference(ref_path)
ann <- load_annotations(bed_path, ref)
dim(annomat(ann))
is_binary(ann)
continuous_path <- tempfile(fileext = ".annot")
writeLines(c(
"chrom\tstart0\tend0\tscore",
"1\t99\t200\t0.5",
"1\t299\t400\t1.5"
), continuous_path)
continuous <- load_annotation(
continuous_path,
ref,
has_header = TRUE,
value_columns = "score"
)
is_binary(continuous)
annotation_metadata(continuous)
grouped_path <- tempfile(fileext = ".annot")
writeLines(c(
"chrom\tstart0\tend0\tgroup",
"1\t99\t200\tcoding",
"1\t299\t400\tcoding"
), grouped_path)
grouped <- load_annotation(
grouped_path,
ref,
has_header = TRUE,
group_column = "group"
)
annonames(grouped)
cache <- tempfile(fileext = ".rds")
save_annotations_cache(ann, cache)
ann_cached <- load_annotations_cache(cache)
dim(annomat(ann_cached))
GenotypePanel objects
Description
Load PLINK bfile-backed genotype metadata, inspect reference-aligned genotype panels, cache metadata, and fetch hardcall genotype slices from BED files.
Usage
load_genotype(bfile_prefix, reference, allow_indel_swaps = FALSE,
match_by = "genomic_position")
save_genotype_cache(panel, path)
load_genotype_cache(path, shards = NULL, bed_path = NULL)
num_sample(x, ...)
fid(x, ...)
iid(x, ...)
father_id(x, ...)
mother_id(x, ...)
sex(x, ...)
is_male(x, ...)
is_female(x, ...)
ploidy_male(x, ...)
ploidy_female(x, ...)
source_layout(x, ...)
source_row0(x, ...)
is_allele_swapped(x, ...)
is_subject_present(x, shard, ...)
fetch_genotypes_int8(x, snp_indices, ...)
fetch_genotypes(x, snp_indices, haploid_mode = NULL, ...)
Arguments
bfile_prefix |
Character scalar PLINK bfile prefix, without suffixes.
Use |
reference |
A |
allow_indel_swaps |
Logical scalar enabling indel swaps. Default is
|
match_by |
Character scalar selecting the position ( |
panel, x |
A |
path |
Character scalar path to an RDS genotype metadata cache. |
shards |
Optional character vector of shard labels in canonical order. |
shard |
A loaded shard label for subject-presence lookup. |
snp_indices |
One-based panel-global SNP indices. |
bed_path |
Optional cache-load BED path override. A sharded override may
contain |
haploid_mode |
Optional output mode, |
... |
Reserved for S3 methods. |
Details
Genotype panels read hardcalls from BED files on demand. Position mode prefers
exact matches, swaps SNVs automatically, and uses allow_indel_swaps for
indels. ID mode replaces position with the BIM marker ID and searches only the
corresponding chromosome. ID comparison is exact and case-sensitive; only
non-palindromic SNVs are eligible, including strand complements.
Counts describe the reference panel's a1 (ALT) allele.
is_allele_swapped() marks variants requiring count inversion, including
strand complementation plus allele exchange. It is false for complementation
alone and absent variants.
Value
load_genotype() and load_genotype_cache() return
GenotypePanel S3 objects. Metadata accessors return ordinary R vectors.
fetch_genotypes_int8() returns an integer matrix with samples as rows
and requested SNPs as columns, counting reference a1 and using
-1 for missing hardcalls.
fetch_genotypes() returns a numeric matrix with missing calls as
NaN.
See Also
allele_matching, load_reference, load_sumstats, set_verbosity
Examples
ref_path <- system.file("extdata", "reference_chr1.bim", package = "statgen")
geno_bed <- system.file("extdata", "genotype_1.bed", package = "statgen")
geno_prefix <- sub("\\.bed$", "", geno_bed)
ref <- load_reference(ref_path)
g <- load_genotype(geno_prefix, ref)
geno <- fetch_genotypes(g, c(1, 2))
dim(geno)
head(geno)
head(is_allele_swapped(g))
cache <- tempfile(fileext = ".rds")
save_genotype_cache(g, cache)
g_cached <- load_genotype_cache(cache)
num_sample(g_cached)
sum(is_present(g_cached))
LD panel loading, preparation, and operations
Description
Prepare Python LD .npz distributions for R loading, validate their
manifests and sparse CSC payloads, load LD panels, and run the core LD
operations.
Usage
load_ld(path, shards = NULL, default_chrX_sex = NULL, retain_ld_r = TRUE)
load_ld_reference(path, shards = NULL)
validate_ld_distribution(path, check_payload_structure = FALSE)
prepare_ld_npz_for_r(npz_root, extract_npz = FALSE)
a1freq(x, chrX_sex = NULL, ...)
multiply_r2(ld_panel, M, chrX_sex = NULL, ...)
fast_prune(logpvec, ld_panel, r2_threshold = 0.2, chrX_sex = NULL)
reference(x, ...)
default_chrX_sex(x, ...)
Arguments
path |
Path to a Python |
shards |
Optional character vector of canonical shard labels to load. |
default_chrX_sex |
Default chrX LD shard selector, one of |
retain_ld_r |
Logical; retain raw signed LD |
check_payload_structure |
Logical; perform expensive sparse payload checks during distribution validation. |
npz_root |
Path to a Python |
extract_npz |
Logical; when |
x |
An LD panel or shard object. |
ld_panel |
An |
M |
A numeric vector or matrix with rows aligned to the LD panel reference. |
logpvec |
Numeric vector of signed or unsigned log-p values aligned to the LD panel reference. |
r2_threshold |
Finite non-negative pruning threshold; defaults to |
chrX_sex |
Optional chrX LD shard selector for operations. Ignored when chrX is absent. |
... |
Reserved for S3 method dispatch. |
Details
R reads Python LD .npz shard files directly. R-loadable distributions use
ld_manifest.json, bundled reference BIM files, Python .npz LD
shards, and an R reference cache sidecar recorded in manifest fields
r_reference_cache and r_reference_cache_md5. load_ld()
constructs Matrix::dgCMatrix objects in memory and derives the
elementwise squared LD matrix used by multiply_r2() and
fast_prune().
prepare_ld_npz_for_r() builds or refreshes the R reference cache sidecar
from the bundled BIM files for all shards described in the existing Python
manifest and updates that manifest in place. With extract_npz = TRUE, it
also creates or refreshes extracted *.npz.d cache directories next to the
manifest-declared shard files. The operation is idempotent.
Value
load_ld() returns an LDPanel. load_ld_reference() returns
the paired ReferencePanel. validate_ld_distribution() returns a
list with ok = TRUE on success. prepare_ld_npz_for_r() returns the
updated manifest invisibly.
a1freq() returns aligned allele frequencies, multiply_r2() returns
a vector or matrix with the same shape as M, and fast_prune()
returns a numeric vector or one-dimensional matrix with pruned entries set to
NaN.
Examples
ld_root <- system.file("extdata", "ld", package = "statgen")
ld <- load_ld(ld_root)
num_snp(ld)
head(a1freq(ld))
scores <- seq_len(num_snp(ld))
multiply_r2(ld, scores)
logp <- rev(seq_len(num_snp(ld)))
fast_prune(logp, ld, r2_threshold = 0.35)
ReferencePanel objects
Description
Load PLINK BIM reference panels as statgen ReferencePanel S3 objects,
inspect aligned reference vectors, and save or load R-native reference caches.
Usage
# Constructors and cache I/O
load_reference(path, shards = NULL)
load_reference_cache(path, shards = NULL)
save_reference_cache(panel, path)
# Accessors
num_snp(x, ...)
shards(x, ...)
chr(x, ...)
snp(x, ...)
bp(x, ...)
a1(x, ...)
a2(x, ...)
a1_hash64(x, ...)
a2_hash64(x, ...)
is_single_nucleotide_variant(x, ...)
is_strand_ambiguous(x, ...)
shard_offsets(x, ...)
# Operations
select_shards(x, shards, ...)
is_object_compatible(reference, object, ...)
validate_checksums(x, ...)
save_cache(x, path, ...)
Arguments
path |
Character scalar path. For |
shards |
Optional character vector of shard labels in canonical order. |
panel, reference, x, object |
Reference panel or compatible statgen object. |
... |
Reserved for S3 methods. |
Details
Reference panels are represented as ReferencePanel S3 objects backed by
an ordered list of reference shards. Reference BIM a1 is ALT and
a2 is REF; other loading functions use this panel's allele orientation.
Most exported functions in this API are S3 generics operating on
ReferencePanel objects and other reference-aligned statgen objects.
Users should access panel data through accessor functions such as bp(x)
and a1(x) rather than directly accessing internal fields.
is_object_compatible(reference, object) dispatches on the first argument,
which should be a ReferencePanel. Other reference-aligned panel classes
participate by providing shards() methods that return their ordered shard
objects.
shards(x) returns the ordered shard objects. save_cache() is the
cross-object cache-writing generic; save_reference_cache() is the
explicit reference-panel cache writer.
Value
load_reference() and load_reference_cache() return a
ReferencePanel S3 object. Accessors return ordinary R vectors or data
frames; allele hashes are bit64::integer64 vectors.
See Also
Examples
path <- system.file("extdata", "reference_chr1.bim", package = "statgen")
ref <- load_reference(path)
num_snp(ref)
head(snp(ref))
sum(is_strand_ambiguous(ref))
cache <- tempfile(fileext = ".rds")
save_reference_cache(ref, cache)
ref_cached <- load_reference_cache(cache)
num_snp(ref_cached)
save_cache(ref, cache)
Sumstats objects
Description
Load, create, inspect, and cache reference-aligned GWAS summary statistics.
Usage
load_sumstats(path, reference, allow_indel_swaps = FALSE,
match_by = "genomic_position")
create_sumstats(reference, p, z = NULL, n = NULL,
beta = NULL, se = NULL, eaf = NULL, info = NULL)
save_sumstats_cache(sumstats, path)
load_sumstats_cache(path, shards = NULL)
logpvec(x, ...)
zvec(x, ...)
nvec(x, ...)
is_present(x, ...)
beta_vec(x, ...)
se_vec(x, ...)
eaf_vec(x, ...)
info_vec(x, ...)
Arguments
path |
Character scalar path to a summary-statistics TSV or RDS cache. |
reference |
A |
allow_indel_swaps |
Logical scalar enabling indel swaps. Default is
|
match_by |
Character scalar selecting the position ( |
sumstats, x |
A |
p, z, n, beta, se, eaf, info |
Aligned
numeric vectors. Optional vectors may be |
shards |
Optional character vector of shard labels in canonical order. |
... |
Reserved for S3 methods. |
Details
Position mode prefers exact matches, swaps SNVs automatically, and uses
allow_indel_swaps for indels. ID mode requires SNP, the allele
columns, and P; it ignores coordinates and searches all source rows
across the supplied reference panel. ID comparison is exact and case-sensitive.
Only non-palindromic SNVs are eligible, including strand complements.
Effects and EAF describe the reference
panel's a1 (ALT) allele. create_sumstats() takes vectors already
in that order and orientation; it performs no allele matching or swapping.
The TSV p column is required; empty fields, NA, and NaN
are missing values. Rows with missing p are validated, then dropped
before matching. At info verbosity, loading reports the number dropped.
Missing reference variants are represented by
NaN in logpvec(x) and by is_present(x) == FALSE.
Gzipped TSV input requires the suggested R.utils package so
data.table::fread() can read compressed files portably.
Value
load_sumstats(), create_sumstats(), and
load_sumstats_cache() return Sumstats S3 objects. Accessors
return ordinary R vectors, with NULL for absent optional fields.
See Also
allele_matching, load_reference, load_genotype, set_verbosity
Examples
ref_path <- system.file("extdata", "reference_chr1.bim", package = "statgen")
sum_path <- system.file("extdata", "traits_complete.tsv.gz", package = "statgen")
ref <- load_reference(ref_path)
s <- load_sumstats(sum_path, ref)
head(logpvec(s))
cache <- tempfile(fileext = ".rds")
save_sumstats_cache(s, cache)
s_cached <- load_sumstats_cache(cache)
head(logpvec(s_cached))
Get or Set Runtime Verbosity
Description
Controls the package-wide statgen runtime verbosity setting. Use
"quiet" to suppress progress messages and loading summaries.
Warnings remain visible.
Usage
get_verbosity()
set_verbosity(level)
Arguments
level |
Character scalar, either |
Value
get_verbosity() returns the current verbosity level. set_verbosity()
returns the selected level invisibly.
See Also
Examples
old <- get_verbosity()
set_verbosity("quiet")
get_verbosity()
set_verbosity(old)
Return the statgen Package Version
Description
Returns the installed statgen R package version.
Usage
version()
Value
A character scalar containing the installed package version.
Examples
version()