### Example: Rank Normalization of Chi-squared Data Source: https://cran.r-project.org/web/packages/RNOmni/refman/RNOmni.html Demonstrates the usage of the RankNorm function by applying it to data drawn from a chi-1 distribution and plotting the density of the transformed measurements. ```R # Draw from chi-1 distribution y <- stats::rchisq(n = 1e3, df = 1) # Rank normalize z <- RankNorm(y) # Plot density of transformed measurement plot(stats::density(z)) ``` -------------------------------- ### Basic Association Test Example Source: https://cran.r-project.org/web/packages/RNOmni/refman/RNOmni.html Demonstrates how to perform a basic association test using the BAT function. Requires setting up a design matrix, genotype matrix, and phenotype vector. ```R set.seed(100) # Design matrix X <- cbind(1, stats::rnorm(1e3)) # Genotypes G <- replicate(1e3, stats::rbinom(n = 1e3, size = 2, prob = 0.25)) storage.mode(G) <- "numeric" # Phenotype y <- as.numeric(X %*% c(1, 1)) + stats::rnorm(1e3) # Association test p <- BAT(y = y, G = G, X = X) ``` -------------------------------- ### Rank Normalization of Sample Data Source: https://cran.r-project.org/web/packages/RNOmni/vignettes/RNOmni.html Demonstrates how to apply the RankNorm function to sample data drawn from a chi-squared distribution to transform it into a standard normal distribution. ```R library(RNOmni) # Sample from the chi-1 square distribution. y <- rchisq(n = 1000, df = 1) # Rank-normalize. z <- RankNorm(y) ``` -------------------------------- ### Simulating Genotypes and Phenotypes Source: https://cran.r-project.org/web/packages/RNOmni/vignettes/RNOmni.html Simulates genetic data, including genotypes, principal components, covariates, and two types of phenotypes (normal and heavy-tailed residuals) for association testing. ```R set.seed(100) # Sample size. n <- 1e3 # Simulate genotypes. maf <- runif(n = 1e3, min = 0.05, max = 0.50) G <- sapply(maf, function(x) {rbinom(n = n, size = 2, prob = x)}) storage.mode(G) <- "numeric" G <- scale(G) # Genetic principal components. pcs <- svd(G, nu = 4, nv = 0)$u[,1:4] # Covariates. Z <- matrix(rnorm(n * 4), nrow = n) Z <- scale(Z) # Overall design matrix. X <- cbind(1, Z, pcs) # Coefficients. b <- c( 1, rnorm(n = 4, sd = 1/sqrt(15)), rnorm(n = 4, sd = 1/sqrt(60)) ) # Linear predictor. h <- as.numeric(X %*% b) # Normal phenotype. y_norm <- h + rnorm(n) # Heavy-tailed phenotype. y_tail <- h + rt(n, df = 3) / sqrt(3) ``` -------------------------------- ### CauchyToP: Convert Cauchy Random Variable to P Source: https://cran.r-project.org/web/packages/RNOmni/refman/RNOmni.html Converts a numeric Cauchy random variable to its corresponding p-value. ```APIDOC ## Convert Cauchy Random Variable to P ### Description Convert Cauchy Random Variable to P ### Usage ```R CauchyToP(z) ``` ### Arguments `z` | Numeric Cauchy random variable. ### Value Numeric p-value. ``` -------------------------------- ### Direct INT Test on Normal and Heavy-tailed Phenotypes Source: https://cran.r-project.org/web/packages/RNOmni/vignettes/RNOmni.html Applies the Direct INT method to both normal and heavy-tailed phenotypes. Shows the output including score, standard error, Z-score, and p-value for each. ```R # Direct INT Test, Normal Phenotype. cat("D-INT Applied to Normal Phenotype:\n") dint_y_norm <- DINT(y = y_norm, G = G, X = X) round(head(dint_y_norm), digits = 3) cat("\n\n") # Direct INT Test, Heavy-tailed Phenotype. cat("D-INT Applied to Heavy-tailed Phenotype:\n") dint_y_tail <- DINT(y = y_tail, G = G, X = X) round(head(dint_y_tail), digits = 3) ``` ```text ## D-INT Applied to Normal Phenotype: ## Score SE Z P ## 1 30.544 33.944 0.900 0.368 ## 2 -12.230 34.153 -0.358 0.720 ## 3 26.580 34.201 0.777 0.437 ## 4 -36.773 34.237 -1.074 0.283 ## 5 62.961 33.767 1.865 0.062 ## 6 -16.303 33.893 -0.481 0.631 ## ## ## D-INT Applied to Heavy-tailed Phenotype: ## Score SE Z P ## 1 8.917 35.725 0.250 0.803 ## 2 -70.214 35.944 -1.953 0.051 ## 3 12.055 35.995 0.335 0.738 ## 4 -24.941 36.033 -0.692 0.489 ## 5 62.189 35.539 1.750 0.080 ## 6 -15.625 35.671 -0.438 0.661 ``` -------------------------------- ### Ordinary Least Squares (FitOLS) Source: https://cran.r-project.org/web/packages/RNOmni/refman/RNOmni.html Fits the standard Ordinary Least Squares (OLS) model. ```APIDOC ## Ordinary Least Squares ### Description Fits the standard OLS model. ### Usage ```R FitOLS(y, X) ``` ### Arguments `y` | Nx1 Numeric vector. `X` | NxP Numeric matrix. ### Value List containing the following: `Beta` | Regression coefficient. `V` | Outcome variance. `Ibb` | Information matrix for beta. `Resid` | Outcome residuals. ``` -------------------------------- ### Omnibus INT Test on Normal and Heavy-tailed Phenotypes Source: https://cran.r-project.org/web/packages/RNOmni/vignettes/RNOmni.html Applies the Omnibus INT method to both normal and heavy-tailed phenotypes. Shows the output including DINT-p, IINT-p, and OINT-p values. ```R # Omnibus INT Test, Normal Phenotype. cat("O-INT Applied to Normal Phenotype:\n") oint_y_norm <- OINT(y = y_norm, G = G, X = X) round(head(oint_y_norm), digits = 3) cat("\n\n") # Omnibus INT Test, Heavy-tailed Phenotype. cat("O-INT Applied to Heavy-tailed Phenotype:\n") oint_y_tail <- OINT(y = y_tail, G = G, X = X) round(head(oint_y_tail), digits = 3) ``` ```text ## O-INT Applied to Normal Phenotype: ## DINT-p IINT-p OINT-p ## 1 0.368 0.380 0.374 ## 2 0.720 0.627 0.678 ## 3 0.437 0.415 0.426 ## 4 0.283 0.231 0.255 ## 5 0.062 0.064 0.063 ## 6 0.631 0.599 0.615 ## ## ## O-INT Applied to Heavy-tailed Phenotype: ## DINT-p IINT-p OINT-p ## 1 0.803 0.680 0.753 ## 2 0.051 0.097 0.067 ## 3 0.738 0.596 0.676 ## 4 0.489 0.675 0.590 ## 5 0.080 0.080 0.080 ## 6 0.661 0.681 0.672 ``` -------------------------------- ### Indirect INT Test on Normal and Heavy-tailed Phenotypes Source: https://cran.r-project.org/web/packages/RNOmni/vignettes/RNOmni.html Applies the Indirect INT method to both normal and heavy-tailed phenotypes. Shows the output including score, standard error, Z-score, and p-value for each. ```R # Indirect INT Test, Normal Phenotype. cat("I-INT Applied to Normal Phenotype:\n") iint_y_norm <- IINT(y = y_norm, G = G, X = X) round(head(iint_y_norm), digits = 3) cat("\n\n") # Indirect INT Test, Heavy-tailed Phenotype. cat("I-INT Applied to Heavy-tailed Phenotype:\n") iint_y_tail <- IINT(y = y_tail, G = G, X = X) round(head(iint_y_tail), digits = 3) ``` ```text ## I-INT Applied to Normal Phenotype: ## Score SE Z P ## 1 27.391 31.204 0.878 0.380 ## 2 -15.266 31.395 -0.486 0.627 ## 3 25.637 31.439 0.815 0.415 ## 4 -37.707 31.473 -1.198 0.231 ## 5 57.583 31.041 1.855 0.064 ## 6 -16.402 31.156 -0.526 0.599 ## ## ## I-INT Applied to Heavy-tailed Phenotype: ## Score SE Z P ## 1 12.867 31.204 0.412 0.680 ## 2 -52.078 31.395 -1.659 0.097 ## 3 16.650 31.439 0.530 0.596 ## 4 -13.190 31.473 -0.419 0.675 ## 5 54.267 31.041 1.748 0.080 ## 6 -12.796 31.156 -0.411 0.681 ``` -------------------------------- ### Fit Ordinary Least Squares Model Source: https://cran.r-project.org/web/packages/RNOmni/refman/RNOmni.html Fits a standard Ordinary Least Squares (OLS) model. This is a utility function for regression analysis. ```R FitOLS(y, X) ``` -------------------------------- ### Rank-Normalize Numeric Vector Source: https://cran.r-project.org/web/packages/RNOmni/refman/RNOmni.html Applies the rank-based inverse normal transform (INT) to a numeric vector. Allows customization of offset and tie-breaking methods. ```R RankNorm(u, k = 0.375, ties.method = "average") ``` -------------------------------- ### Partition Data by Genotype Missingness Source: https://cran.r-project.org/web/packages/RNOmni/refman/RNOmni.html Partitions residual vector 'e' and covariate matrix 'X' based on the missingness pattern of genotype vector 'g'. ```R PartitionData(e, g, X) ``` -------------------------------- ### Omnibus INT Association Test Source: https://cran.r-project.org/web/packages/RNOmni/refman/RNOmni.html Performs an omnibus association test combining Direct INT and Indirect INT tests using the Cauchy combination method. Use this to synthesize results from both DINT and IINT approaches. ```R set.seed(100) # Design matrix X <- cbind(1, rnorm(1e3)) # Genotypes G <- replicate(1e3, rbinom(n = 1e3, size = 2, prob = 0.25)) storage.mode(G) <- "numeric" # Phenotype y <- exp(as.numeric(X %*% c(1, 1)) + rnorm(1e3)) # Omnibus p <- OINT(y = y, G = G, X = X, simple = TRUE) ``` -------------------------------- ### Basic Association Test on Heavy-tailed Phenotype Source: https://cran.r-project.org/web/packages/RNOmni/vignettes/RNOmni.html Applies the Basic Association Test (BAT) to a phenotype with heavy-tailed residuals. This demonstrates BAT's application to non-normal trait distributions. ```R # Basic Association Test, Heavy-tailed Phenotype cat("BAT Applied to Heavy-tailed Phenotype:\n") bat_y_tail <- BAT(y = y_tail, G = G, X = X) round(head(bat_y_tail), digits = 3) ``` -------------------------------- ### Omnibus P-value Combination Source: https://cran.r-project.org/web/packages/RNOmni/refman/RNOmni.html Calculates an omnibus p-value from a vector of p-values using Cauchy combination. Handles optional weights. ```R OmniP(p, w = NULL) ``` -------------------------------- ### Omnibus INT Test (OINT) Source: https://cran.r-project.org/web/packages/RNOmni/refman/RNOmni.html Performs an omnibus association test that combines the Direct INT (DINT) and Indirect INT (IINT) tests using the Cauchy combination method for p-values. ```APIDOC ## Omnibus-INT ### Description Association test that synthesizes the `DINT` and `IINT` tests. The first approach is most powerful for traits that could have arisen from a rank-preserving transformation of a latent normal trait. The second approach is most powerful for traits that are linear in covariates, yet have skewed or kurtotic residual distributions. During the omnibus test, the direct and indirect tests are separately applied, then the p-values are combined via the Cauchy combination method. ### Usage ```R OINT( y, G, X = NULL, k = 0.375, ties.method = "average", weights = c(1, 1), simple = FALSE ) ``` ### Arguments `y` | Numeric phenotype vector. `G` | Genotype matrix with observations as rows, SNPs as columns. `X` | Model matrix of covariates and structure adjustments. Should include an intercept. Omit to perform marginal tests of association. `k` | Offset applied during rank-normalization. See `RankNorm`. `ties.method` | Method of breaking ties, passed to `base::rank`. `weights` | Respective weights to allocate the DINT and IINT tests. `simple` | Return the OINT p-values only? ### Value A numeric matrix of p-values, three for each column of `G`. ### See Also * Basic association test `BAT`. * Direct INT test `DINT`. * Indirect INT test `IINT`. ### Examples ```R set.seed(100) # Design matrix X <- cbind(1, rnorm(1e3)) # Genotypes G <- replicate(1e3, rbinom(n = 1e3, size = 2, prob = 0.25)) storage.mode(G) <- "numeric" # Phenotype y <- exp(as.numeric(X %*% c(1, 1)) + rnorm(1e3)) # Omnibus p <- OINT(y = y, G = G, X = X, simple = TRUE) ``` ``` -------------------------------- ### Indirect INT Test (IINT) Source: https://cran.r-project.org/web/packages/RNOmni/refman/RNOmni.html Performs a two-stage indirect rank-based inverse normal transformation (INT) association test. It first obtains residuals by regressing phenotype and genotype on covariates, then regresses transformed phenotypic residuals on genotypic residuals. ```APIDOC ## Indirect-INT ### Description Two-stage association testing procedure. In the first stage, phenotype `y` and genotype `G` are each regressed on the model matrix `X` to obtain residuals. The phenotypic residuals are transformed using `RankNorm`. In the next stage, the INT-transformed residuals are regressed on the genotypic residuals. ### Usage ```R IINT(y, G, X = NULL, k = 0.375, ties.method = "average", simple = FALSE) ``` ### Arguments `y` | Numeric phenotype vector. `G` | Genotype matrix with observations as rows, SNPs as columns. `X` | Model matrix of covariates and structure adjustments. Should include an intercept. Omit to perform marginal tests of association. `k` | Offset applied during rank-normalization. See `RankNorm`. `ties.method` | Method of breaking ties, passed to `base::rank`. `simple` | Return the p-values only? ### Value If `simple = TRUE`, returns a vector of p-values, one for each column of `G`. If `simple = FALSE`, returns a numeric matrix, including the Wald or Score statistic, its standard error, the Z-score, and the p-value. ### See Also * Basic association test `BAT`. * Direct INT test `DINT`. * Omnibus INT test `OINT`. ### Examples ```R set.seed(100) # Design matrix X <- cbind(1, stats::rnorm(1e3)) # Genotypes G <- replicate(1e3, stats::rbinom(n = 1e3, size = 2, prob = 0.25)) storage.mode(G) <- "numeric" # Phenotype y <- exp(as.numeric(X %*% c(1,1)) + stats::rnorm(1e3)) # Association test p <- IINT(y = y, G = G, X = X) ``` ``` -------------------------------- ### Direct INT Association Test Source: https://cran.r-project.org/web/packages/RNOmni/refman/RNOmni.html Performs a direct rank-based inverse normal transformation (INT) association test. Use this for traits that could have arisen from a rank-preserving transformation of a latent normal trait. ```R set.seed(100) # Design matrix X <- cbind(1, stats::rnorm(1e3)) # Genotypes G <- replicate(1e3, stats::rbinom(n = 1e3, size = 2, prob = 0.25)) storage.mode(G) <- "numeric" # Phenotype y <- exp(as.numeric(X %*% c(1, 1)) + stats::rnorm(1e3)) # Association test p <- DINT(y = y, G = G, X = X) ``` -------------------------------- ### Convert P-value to Cauchy Random Variable Source: https://cran.r-project.org/web/packages/RNOmni/refman/RNOmni.html Converts a numeric p-value into its corresponding Cauchy random variable. ```R PtoCauchy(p) ``` -------------------------------- ### Direct INT Test (DINT) Source: https://cran.r-project.org/web/packages/RNOmni/refman/RNOmni.html Performs a direct rank-based inverse normal transformation (INT) association test. It tests for association between a phenotype and genotype, optionally adjusting for covariates. ```APIDOC ## DINT ### Description Performs a direct rank-based inverse normal transformation (INT) association test. ### Usage ```R DINT(y, G, X = NULL, k = 0.375, ties.method = "average", simple = FALSE) ``` ### Arguments `y` | Numeric phenotype vector. `G` | Genotype matrix with observations as rows, SNPs as columns. `X` | Model matrix of covariates and structure adjustments. Should include an intercept. Omit to perform marginal tests of association. `k` | Offset applied during rank-normalization. See `RankNorm`. `ties.method` | Method of breaking ties, passed to `base::rank`. `simple` | Return the p-values only? ### Value If `simple = TRUE`, returns a vector of p-values, one for each column of `G`. If `simple = FALSE`, returns a numeric matrix, including the Wald or Score statistic, its standard error, the Z-score, and the p-value. ### See Also * Basic association test `BAT`. * Indirect INT test `IINT`. * Omnibus INT test `OINT`. ### Examples ```R set.seed(100) # Design matrix X <- cbind(1, stats::rnorm(1e3)) # Genotypes G <- replicate(1e3, stats::rbinom(n = 1e3, size = 2, prob = 0.25)) storage.mode(G) <- "numeric" # Phenotype y <- exp(as.numeric(X %*% c(1, 1)) + stats::rnorm(1e3)) # Association test p <- DINT(y = y, G = G, X = X) ``` ``` -------------------------------- ### DINT: Direct-INT Source: https://cran.r-project.org/web/packages/RNOmni/refman/RNOmni.html Applies the rank-based inverse normal transformation to the phenotype and conducts association tests between genetic loci and the transformed phenotype, adjusting for covariates. Supports Score and Wald tests. ```APIDOC ## DINT: Direct-INT ### Description Applies the rank-based inverse normal transformation (`RankNorm`) to the phenotype `y`. Conducts tests of association between the loci in `G` and transformed phenotype, adjusting for the model matrix `X`. ### Usage ```R DINT( y, G, X = NULL, k = 0.375, test = "Score", ties.method = "average", simple = FALSE ) ``` ### Arguments `y` | Numeric phenotype vector. `G` | Genotype matrix with observations as rows, SNPs as columns. `X` | Model matrix of covariates and structure adjustments. Should include an intercept. Omit to perform marginal tests of association. `k` | Parameter for the rank-based inverse normal transformation. `test` | Either Score or Wald. `ties.method` | Method for handling ties in the rank transformation. `simple` | Return the p-values only? ### Value If `simple = TRUE`, returns a vector of p-values, one for each column of `G`. If `simple = FALSE`, returns a numeric matrix, including the Wald or Score statistic, its standard error, the Z-score, and the p-value. ### See Also * Basic Association Test `BAT` * Indirect INT `IINT` * Omnibus INT `OINT` ``` -------------------------------- ### Basic Association Test on Normal Phenotype Source: https://cran.r-project.org/web/packages/RNOmni/vignettes/RNOmni.html Applies the Basic Association Test (BAT) to a phenotype with normal residuals. The output includes score statistics, standard errors, Z-scores, and p-values for each genetic variant. ```R # Basic Association Test, Normal Phenotype bat_y_norm <- BAT(y = y_norm, G = G, X = X) cat("BAT Applied to Normal Phenotype:\n") round(head(bat_y_norm), digits = 3) ``` -------------------------------- ### BAT: Basic Association Test Source: https://cran.r-project.org/web/packages/RNOmni/refman/RNOmni.html Conducts tests of association between genetic loci and an untransformed phenotype, adjusting for covariates. It supports Score and Wald tests and can return only p-values or a detailed statistic matrix. ```APIDOC ## BAT: Basic Association Test ### Description Conducts tests of association between the loci in `G` and the untransformed phenotype `y`, adjusting for the model matrix `X`. ### Usage ``` BAT(y, G, X = NULL, test = "Score", simple = FALSE) ``` ### Arguments `y` | Numeric phenotype vector. `G` | Genotype matrix with observations as rows, SNPs as columns. `X` | Model matrix of covariates and structure adjustments. Should include an intercept. Omit to perform marginal tests of association. `test` | Either Score or Wald. `simple` | Return the p-values only? ### Value If `simple = TRUE`, returns a vector of p-values, one for each column of `G`. If `simple = FALSE`, returns a numeric matrix, including the Wald or Score statistic, its standard error, the Z-score, and the p-value. ### See Also * Direct INT `DINT` * Indirect INT `IINT` * Omnibus INT `OINT` ### Examples ```R set.seed(100) # Design matrix X <- cbind(1, stats::rnorm(1e3)) # Genotypes G <- replicate(1e3, stats::rbinom(n = 1e3, size = 2, prob = 0.25)) storage.mode(G) <- "numeric" # Phenotype y <- as.numeric(X %*% c(1, 1)) + stats::rnorm(1e3) # Association test p <- BAT(y = y, G = G, X = X) ``` ``` -------------------------------- ### Indirect INT Association Test Source: https://cran.r-project.org/web/packages/RNOmni/refman/RNOmni.html Performs an indirect rank-based inverse normal transformation (INT) association test. Use this for traits that are linear in covariates but may have skewed residual distributions. ```R set.seed(100) # Design matrix X <- cbind(1, stats::rnorm(1e3)) # Genotypes G <- replicate(1e3, stats::rbinom(n = 1e3, size = 2, prob = 0.25)) storage.mode(G) <- "numeric" # Phenotype y <- exp(as.numeric(X %*% c(1,1)) + stats::rnorm(1e3)) # Association test p <- IINT(y = y, G = G, X = X) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.