Package: HTRX 1.2.4

Yaoling Yang

HTRX: Haplotype Trend Regression with eXtra Flexibility (HTRX)

Detection of haplotype patterns that include single nucleotide polymorphisms (SNPs) and non-contiguous haplotypes that are associated with a phenotype. Methods for implementing HTRX are described in Yang Y, Lawson DJ (2023) <doi:10.1093/bioadv/vbad038> and Barrie W, Yang Y, Irving-Pease E.K, et al (2024) <doi:10.1038/s41586-023-06618-z>.

Authors:Yaoling Yang [aut, cre], Daniel Lawson [aut]

HTRX_1.2.4.tar.gz
HTRX_1.2.4.tar.gz(r-4.5-noble)HTRX_1.2.4.tar.gz(r-4.4-noble)
HTRX_1.2.4.tgz(r-4.4-emscripten)HTRX_1.2.4.tgz(r-4.3-emscripten)
HTRX.pdf |HTRX.html
HTRX/json (API)

# Install 'HTRX' in R:
install.packages('HTRX', repos = 'https://cloud.r-project.org')
Datasets:

On CRAN:

Conda:

This package does not link to any Github/Gitlab/R-forge repository. No issue tracker or development information is available.

2.70 score 256 downloads 19 exports 99 dependencies

Last updated 1 years agofrom:79df34a6d8. Checks:1 OK, 2 NOTE. Indexed: yes.

TargetResultLatest binary
Doc / VignettesOKMar 06 2025
R-4.5-linuxNOTEMar 06 2025
R-4.4-linuxNOTEMar 06 2025

Exports:computeR2do_cumulative_htrxdo_cumulative_htrx_step1do_cvdo_cv_directdo_cv_step1extend_hapshtrx_maxhtrx_nfeaturesinfer_fixedfeaturesinfer_step1kfold_splitmake_cumulative_htrxmake_htrmake_htrxmake_snpmypredictthemodeltwofold_split

Dependencies:BHbigmemorybigmemory.sricaretclasscliclockcodetoolscolorspacecpp11data.tablediagramdialsDiceDesigndigestdoFuturedplyre1071fansifarverfastglmforeachfurrrfuturefuture.applygenericsggplot2glmnetglobalsgluegowerGPfitgtablehardhatipredisobanditeratorsKernSmoothlabelinglatticelavalhslifecyclelistenvlubridatemagrittrMASSMatrixmgcvmodelenvModelMetricsmunsellnlmennetnumDerivparallellyparsnippillarpkgconfigplyrprettyunitspROCprodlimprogressrproxypurrrR6RColorBrewerRcppRcppEigenrecipesreshape2rlangrpartrsamplescalessfdshapeslidersparsevctrsSQUAREMstringistringrsurvivaltibbletidyrtidyselecttimechangetimeDatetunetzdbutf8uuidvctrsviridisLitewarpwithrworkflowsyardstick

HTRX: an R package for learning non-contiguous haplotypes

Rendered fromHTRX_vignette.Rmdusingknitr::rmarkdownon Mar 06 2025.

Last update: 2024-02-10
Started: 2023-02-14

Citation

To cite package ‘HTRX’ in publications use:

Yang Y, Lawson D (2024). HTRX: Haplotype Trend Regression with eXtra Flexibility (HTRX). R package version 1.2.4, https://CRAN.R-project.org/package=HTRX.

Corresponding BibTeX entry:

  @Manual{,
    title = {HTRX: Haplotype Trend Regression with eXtra Flexibility
      (HTRX)},
    author = {Yaoling Yang and Daniel Lawson},
    year = {2024},
    note = {R package version 1.2.4},
    url = {https://CRAN.R-project.org/package=HTRX},
  }

Readme and manuals

Haplotype Trend Regression with eXtra flexibility (HTRX)

This is the location for the HTRX tool that was firstly proposed by Barrie, W., Yang, Y., Irving-Pease, E.K. et al. Elevated genetic risk for multiple sclerosis emerged in steppe pastoralist populations. Nature 625, 321–328 (2024).
and then illustrated in detail by
Yang Y, Lawson DJ. HTRX: an R package for learning non-contiguous haplotypes associated with a phenotype. Bioinformatics Advances 3.1 (2023): vbad038.

Introduction:

Haplotype Trend Regression with eXtra flexibility (HTRX) searches a pre-defined set of SNPs for haplotype patterns that include single nucleotide polymorphisms (SNPs) and non-contiguous haplotypes.

We search over all possible templates which give a value for each SNP being ‘0’ or ‘1’, reflecting whether the reference allele of each SNP is present or absent, or an ‘X’ meaning either value is allowed.

We used a two-stage procedure to select the best HTRX model (function “do_cv”).
Stage 1: select candidate models;
Stage 2: select the best model using 10-fold cross-validation.

Longer haplotypes are important for discovering interactions. However, there are $3^k-1$ haplotypes in HTRX if the region contains $k$ SNPs, making it unrealistic for regions with large numbers of SNPs. To address this issue, we proposed “cumulative HTRX” (function “do_cumulative_htrx”) that enables HTRX to run on longer haplotypes, i.e. haplotypes which include at least 7 SNPs (we recommend). Besides, we provide a parameter “max_int” which controls the maximum number of SNPs that can interact.

Install R package “HTRX”

devtools::install_github("https://github.com/YaolingYang/HTRX")

This package is also available from CRAN. You can install it by

install.packages("HTRX")

Tutorial

A tutorial of package HTRX can be found in vignettes/HTRX_vignette.pdf

Examples

library(HTRX)

## use dataset "example_hap1", "example_hap2" and "example_data_nosnp"
## "example_hap1" and "example_hap2" are both genomes of 8 SNPs for 5,000 individuals (diploid data) 
## "example_data_nosnp" is an example dataset which contains the outcome (binary), sex, age and 18 PCs

## visualise the covariates data
head(HTRX::example_data_nosnp)

## visualise the genotype data for the first genome
head(HTRX::example_hap1)

## we perform HTRX on the first 4 SNPs
## we first generate all the haplotype data, as defined by HTRX
HTRX_matrix=make_htrx(HTRX::example_hap1[,1:4],HTRX::example_hap2[,1:4])

## If the data is haploid, please set
## HTRX_matrix=make_htrx(HTRX::example_hap1[,1:4],HTRX::example_hap1[,1:4])

## next compute the maximum number of independent features
featurecap=htrx_max(nsnp=4)

## then perform HTRX using 2-step cross-validation
## to compute additional variance explained by haplotypes
## If you want to compute total variance explained, please set gain=FALSE
htrx_results <- do_cv(HTRX::example_data_nosnp,
                      HTRX_matrix,train_proportion=0.5,
                      sim_times=3,featurecap=featurecap,usebinary=1,
                      method="stratified",criteria="BIC",
                      gain=TRUE,runparallel=FALSE)

## If we want to compute the total variance explained
## we can set gain=FALSE in the above example

## we perform cumulative HTRX on all the 8 SNPs using 2-step cross-validation
## to compute additional variance explained by haplotypes
## If the data is haploid, please set hap2=HTRX::example_hap1
## If you want to compute total variance explained, please set gain=FALSE
## For Linux/MAC users, we strongly encourage you to set runparallel=TRUE
cumu_htrx_results <- do_cumulative_htrx(data_nosnp=HTRX::example_data_nosnp,
                                        hap1=HTRX::example_hap1,
                                        hap2=HTRX::example_hap2,
                                        train_proportion=0.5,sim_times=1,
                                        featurecap=6,usebinary=1,
                                        randomorder=TRUE,method="stratified",
                                        criteria="BIC",runparallel=FALSE)

Help Manual

Help pageTopics
HTRX: Haplotype Trend Regression with eXtra flexibilityHTRX-package HTRX
Compute variance explained by modelscomputeR2 mypredict
Data splitdata_split kfold_split twofold_split
Cumulative HTRX on long haplotypesdo_cumulative_htrx do_cumulative_htrx_step1 extend_haps make_cumulative_htrx
Two-stage HTRX: Model selection on short haplotypesdo_cv do_cv_step1 infer_fixedfeatures infer_step1
Direct HTRX: k-fold cross-validation on short haplotypesdo_cv_direct
Example covariate dataexample_data_nosnp
Example genotype data for the first genomeexample_hap1
Example genotype data for the second genomeexample_hap2
Maximum independent features for HTRXhtrx_max
Total number of features for HTRXhtrx_nfeatures
Generate haplotype datamake_htr make_htrx make_snp
Model fittingthemodel